Skip to content

Docker images for Flutter Continuous Integration (CI)

License

Notifications You must be signed in to change notification settings

gmeligio/flutter-docker-image

Repository files navigation

channel flutter-android version flutter-android pulls flutter-android size

Flutter Docker Image

Docker images for Flutter Continuous Integration (CI). The source is available on GitHub.

The images includes the minimum tools to run Flutter and build apps. The versions of the tools installed are based on the official Flutter repository. The final goal is that Flutter doesn't need to download anything like tools or SDKs when running the container.

Features:

  1. Installed Flutter SDK 3.22.1
  2. Analytics disabled by default, opt-in if ENABLE_ANALYTICS environment variable is passed when running the container.
  3. Rootless user flutter:flutter, with permissions to run on GitLab CI.
  4. Cached Fastlane gem 2.220.0
  5. Minimal image with predownloaded SDKs and tools ready to run flutter commands:
    • Android
    • iOS
    • Linux
    • Windows
    • Web

Alpha stability

The images are experimental and are in active development. They are being used for small projects but there is no confirmation of production usage yet.

flutter-android image

Predownloaded SDKs and tools:

  • Licenses accepted
  • Android SDK Platforms: 34
  • Gradle: 7.6.3

Registries:

TODO:

  • Android emulator
  • Android NDK

Running containers

On the terminal:

# From Docker Hub
docker run --rm -it gmeligio/flutter-android:3.22.1 bash

# From GitHub Container Registry
docker run --rm -it ghcr.io/gmeligio/flutter-android:3.22.1 bash

# From Quay.io
docker run --rm -it quay.io/gmeligio/flutter-android:3.22.1 bash

On a workflow in GitHub Actions:

jobs:
  build:
    runs-on: ubuntu-22.04
    container:
      image: ghcr.io/gmeligio/flutter-android:3.22.1
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Build
        run: flutter build apk

On a .gitlab-ci.yml in GitLab CI:

build:
  image: ghcr.io/gmeligio/flutter-android:3.22.1
  script:
    - flutter build apk

Fastlane:

# Ruby bundler is available in the container.
# The fastlane gem is cached but not installed
# For more information, see https://docs.fastlane.tools

# Use --prefer-local to download gems only if they are not cached
bundle install --prefer-local
bundle exec fastlane

Versions

There is no latest Docker tag on purpose. You need to specify the version of the image you want to use. The reason for that is that latest is a dynamic tag that can be confusing when reading the image URI because doesn't necessarily point to the latest image built and can cause unexpected behavior when rerunning a past CI job that runs with an overwritten latest tags. There are multiple articles explaining more about this reasoning like What's Wrong With The Docker :latest Tag? and The misunderstood Docker tag: latest.

The tag is composed of the Flutter version used to build the image. For example:

  • Docker image: gmeligio/flutter-android:3.22.1
  • Flutter version: 3.22.1

Developing locally

Running the container

The Dockerfile expects a few parameters:

  • flutter_version <string>: The version of Flutter to use when building. Example: 3.22.1
  • android_build_tools_version <string>: The version of the Android SDK Build Tools to install. Example: 30.0.3
  • android_platform_versions <list>: The versions of the Android SDK Platforms to install, separated by spaces. Example: 28 31 33
# Android
docker build --target android --build-arg flutter_version=3.22.1 --build-arg fastlane_version=2.220.0 --build-arg android_build_tools_version=30.0.3 --build-arg android_platform_versions="34" -t android-test .

Dockerfile stages

The base image is debian/debian:12-slim and from there multiple stages are created:

  1. flutter stage hast only the dependencies required to install flutter and common tools used by flutter internal commands, like git.
  2. fastlane stage has the dependencies required to install fastlane but doesn't install fastlane.
  3. android stage has the dependencies required to install the Android SDK and to develop Flutter apps for Android.

FAQ

Why not push to AWS ECR Public registry?

The storage of the images starts to cost after 50 GB and increases with every pushed image because the AWS Free Tier covers up to 50 GB of total storage for free in ECR Public.

Other Docker projects for mobile development

Acknowledgments

License

MIT License

About

Docker images for Flutter Continuous Integration (CI)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published