docker-flutter-sdk/Dockerfile
Mathias Beaulieu-Duncan 4827388738
All checks were successful
Build and Push Flutter SDK Image / build-and-push (Flutter SDK for Linux desktop CI builds, Dockerfile.linux, linux) (release) Successful in 1h8m47s
Build and Push Flutter SDK Image / build-and-push (Flutter SDK for Android CI builds, Dockerfile.android, android) (release) Successful in 1h11m0s
Build and Push Flutter SDK Image / build-and-push (Minimal Flutter SDK for Web/WASM CI builds, Dockerfile, web) (release) Successful in 6m49s
Migrate to Wolfi base image and optimize SDK size
- Switch all Dockerfiles from debian:bookworm-slim to svrnty/base-distro:flutter-sdk-latest (Wolfi)
- Use non-root user (UID 65532) instead of custom flutter user
- Strip wrong-platform engine artifacts per variant (web, android, linux)
- Remove dev/, examples/ and compact .git with git gc --prune=all
- Android: multi-stage build for JDK 17 + Android SDK 36 from Debian
- Linux: multi-stage build for clang/cmake/ninja/GTK3 with glibc conflict resolution
- Update Android SDK from 35 to 36 (required by Flutter 3.38.9)

Image sizes: web 1.32 GB, linux 2.43 GB, android 4.22 GB
(down from 4.9 GB, 3.69 GB, 4.15 GB respectively)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 17:55:20 -05:00

50 lines
1.4 KiB
Docker

FROM svrnty/base-distro:flutter-sdk-latest
ARG FLUTTER_VERSION=3.38.9
LABEL org.opencontainers.image.title="flutter-sdk-web"
LABEL org.opencontainers.image.description="Minimal Flutter SDK for Web/WASM CI builds"
LABEL org.opencontainers.image.version="${FLUTTER_VERSION}"
USER 0
# Download Flutter SDK and strip unnecessary files in a single layer
RUN curl -fsSL "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${FLUTTER_VERSION}-stable.tar.xz" \
-o /tmp/flutter.tar.xz && \
tar xf /tmp/flutter.tar.xz -C /opt && \
rm /tmp/flutter.tar.xz && \
rm -rf /opt/flutter/dev \
/opt/flutter/examples \
/opt/flutter/bin/cache/artifacts/engine/android-* \
/opt/flutter/bin/cache/artifacts/engine/linux-* && \
chown -R 65532:65532 /opt/flutter
# Mark git directory as safe and compact git history
RUN git config --global --add safe.directory /opt/flutter && \
cd /opt/flutter && git gc --prune=all
USER 65532
# Configure for web-only (disable everything else)
RUN flutter config --enable-web \
--no-enable-android \
--no-enable-ios \
--no-enable-linux-desktop \
--no-enable-macos-desktop \
--no-enable-windows-desktop
# Precache only web artifacts
RUN flutter precache --web \
--no-android \
--no-ios \
--no-linux \
--no-macos \
--no-windows \
--no-fuchsia \
--no-universal
# Verify installation
RUN flutter doctor -v
WORKDIR /app