Skip to content

Commit d50728e

Browse files
feat: add web-only docker image for flutter 3.44.1
1 parent cb5a3be commit d50728e

5 files changed

Lines changed: 167 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Publish Flutter web-only image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- Dockerfile
9+
- versions.env
10+
- .github/workflows/publish.yml
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
packages: write
16+
17+
env:
18+
REGISTRY: ghcr.io
19+
IMAGE_NAME: ${{ github.repository }}-web-only
20+
21+
jobs:
22+
publish:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v6
26+
27+
- name: Load versions
28+
id: versions
29+
shell: bash
30+
run: |
31+
set -a
32+
source versions.env
33+
set +a
34+
echo "flutter=$FLUTTER_STABLE_VERSION" >> "$GITHUB_OUTPUT"
35+
36+
- name: Set up Docker Buildx
37+
uses: docker/setup-buildx-action@v4
38+
39+
- name: Log in to GHCR
40+
uses: docker/login-action@v4
41+
with:
42+
registry: ${{ env.REGISTRY }}
43+
username: ${{ github.actor }}
44+
password: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Build and push
47+
uses: docker/build-push-action@v7
48+
with:
49+
context: .
50+
push: true
51+
build-args: |
52+
FLUTTER_STABLE_VERSION=${{ steps.versions.outputs.flutter }}
53+
tags: |
54+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.versions.outputs.flutter }}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Update Flutter stable version
2+
3+
on:
4+
schedule:
5+
- cron: "23 6 * * *"
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
update:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v6
17+
18+
- name: Find latest stable Flutter version
19+
id: latest
20+
shell: bash
21+
run: |
22+
set -euo pipefail
23+
latest=$(
24+
curl --fail --silent https://api.github.com/repos/flutter/flutter/releases/latest \
25+
| jq -r '.tag_name | sub("^v"; "")'
26+
)
27+
if [ -z "$latest" ] || [ "$latest" = "null" ]; then
28+
echo "Could not resolve latest Flutter release" >&2
29+
exit 1
30+
fi
31+
echo "version=$latest" >> "$GITHUB_OUTPUT"
32+
33+
- name: Update versions.env
34+
id: update
35+
shell: bash
36+
run: |
37+
set -euo pipefail
38+
current=$(grep '^FLUTTER_STABLE_VERSION=' versions.env | cut -d= -f2- || true)
39+
if [ "$current" = "${{ steps.latest.outputs.version }}" ]; then
40+
echo "changed=false" >> "$GITHUB_OUTPUT"
41+
exit 0
42+
fi
43+
tmp=$(mktemp)
44+
awk -F= -v latest="${{ steps.latest.outputs.version }}" \
45+
'BEGIN { updated=0 } /^FLUTTER_STABLE_VERSION=/ { print "FLUTTER_STABLE_VERSION=" latest; updated=1; next } { print } END { if (!updated) print "FLUTTER_STABLE_VERSION=" latest }' \
46+
versions.env > "$tmp"
47+
mv "$tmp" versions.env
48+
echo "changed=true" >> "$GITHUB_OUTPUT"
49+
50+
- name: Create pull request
51+
if: steps.update.outputs.changed == 'true'
52+
uses: peter-evans/create-pull-request@v8
53+
with:
54+
branch: bot/update-flutter-${{ steps.latest.outputs.version }}
55+
commit-message: Update Flutter to ${{ steps.latest.outputs.version }}
56+
title: Update Flutter to ${{ steps.latest.outputs.version }}
57+
body: |
58+
Updates the base image Flutter SDK version to `${{ steps.latest.outputs.version }}`.
59+
60+
The publish workflow will build and push:
61+
- `ghcr.io/${{ github.repository }}-web-only:${{ steps.latest.outputs.version }}`
62+
labels: dependencies, flutter

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM ubuntu:24.04
2+
3+
ARG FLUTTER_STABLE_VERSION=3.44.1
4+
5+
ENV DEBIAN_FRONTEND=noninteractive \
6+
FLUTTER_HOME=/opt/flutter \
7+
PATH=/opt/flutter/bin:/opt/flutter/bin/cache/dart-sdk/bin:/root/.pub-cache/bin:$PATH
8+
9+
RUN apt-get update \
10+
&& apt-get install -y --no-install-recommends \
11+
ca-certificates \
12+
curl \
13+
file \
14+
git \
15+
jq \
16+
xz-utils \
17+
zip \
18+
&& rm -rf /var/lib/apt/lists/*
19+
20+
RUN git clone --depth 1 --branch "$FLUTTER_STABLE_VERSION" https://github.com/flutter/flutter.git "$FLUTTER_HOME" \
21+
&& flutter config --no-analytics \
22+
&& flutter precache --web \
23+
&& flutter doctor -v

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Flutter Web-Only Base Image
2+
3+
Standalone GHCR image for Flutter web-only builds.
4+
5+
Our custom version after discontinuation of the CirrusLabs image.
6+
7+
## Image tags
8+
9+
After pushing this directory as a repository, the publish workflow creates:
10+
11+
- `ghcr.io/<owner>/<repo>-web-only:<flutter-version>`
12+
13+
For this app, use for example:
14+
15+
```dockerfile
16+
FROM ghcr.io/solvro/web-flutter-docker-image-web-only:3.44.1 AS build
17+
```
18+
19+
## Versioning
20+
21+
The pinned Flutter stable version lives in `versions.env` as `FLUTTER_STABLE_VERSION`.
22+
23+
The scheduled updater checks the latest Flutter stable release and opens a PR that updates `versions.env`. Merging that PR triggers the publish workflow and pushes a new specific version tag.
24+
25+
## Contents
26+
27+
This image installs Flutter from the official Flutter git tag and pre-caches only web artifacts. It does not include the Android SDK, Java runtime, or Android command-line tools.

versions.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FLUTTER_STABLE_VERSION=3.44.1

0 commit comments

Comments
 (0)