This repository provides Docker images for building Flutter applications across multiple platforms. These pre-configured images allow developers to build Flutter projects without installing Flutter and its dependencies locally.
Image | Purpose | GitHub Package |
---|---|---|
flutter-web-builder |
Build Flutter web applications | View on GHCR |
flutter-android-builder |
Build Flutter Android applications | View on GHCR |
- Docker installed on your machine
- A Flutter project you want to build
Pull the image:
docker pull ghcr.io/iarunsaragadam/flutter-web-builder:latest
# Or specify a version
# docker pull ghcr.io/iarunsaragadam/flutter-web-builder:v3.29.0
Run the container to build your web app (make sure you're in your Flutter project directory):
docker run -it --rm -v $(pwd):/app ghcr.io/iarunsaragadam/flutter-web-builder:latest
This will:
- Mount your current directory to
/app
in the container - Run the default command which executes
flutter clean && flutter pub get && flutter build web --release
The output web build will be available in your project at:
build/web/
If you want to run a different Flutter command:
docker run -it --rm -v $(pwd):/app ghcr.io/iarunsaragadam/flutter-web-builder:latest flutter analyze
To serve the built web app on your host machine:
# Using Nginx for production-like serving
docker run -it --rm -v $(pwd)/build/web:/usr/share/nginx/html -p 8080:80 nginx:alpine
Then open http://localhost:8080 in your browser.
Pull the image:
docker pull ghcr.io/iarunsaragadam/flutter-android-builder:latest
# Or specify a version
# docker pull ghcr.io/iarunsaragadam/flutter-android-builder:v3.29.0
Run the container to build your Android app (make sure you're in your Flutter project directory):
docker run -it --rm -v $(pwd):/app ghcr.io/iarunsaragadam/flutter-android-builder:latest
This will:
- Mount your current directory to
/app
in the container - Run the default command which executes
flutter clean && flutter pub get && flutter build apk --release
The output APK will be available in your project at:
build/app/outputs/flutter-apk/app-release.apk
To build an App Bundle instead:
docker run -it --rm -v $(pwd):/app ghcr.io/iarunsaragadam/flutter-android-builder:latest flutter build appbundle --release
After the build completes, you'll find the APK or AAB in:
- APK:
build/app/outputs/flutter-apk/app-release.apk
- App Bundle:
build/app/outputs/bundle/release/app-release.aab
If you need to run multiple commands or debug your build:
docker run -it --rm -v $(pwd):/app ghcr.io/iarunsaragadam/flutter-web-builder:latest bash
or for Android:
docker run -it --rm -v $(pwd):/app ghcr.io/iarunsaragadam/flutter-android-builder:latest bash
Then you can run Flutter commands interactively:
flutter pub get
flutter test
flutter build web # or flutter build apk
Building for iOS requires macOS and cannot be done inside a Docker container due to Apple's platform restrictions. For iOS builds, developers typically use:
- A Mac with Xcode installed
- macOS-based CI/CD runners (GitHub Actions, CircleCI, etc.)
- Specialized Flutter CI/CD services
If you want to build these Docker images locally:
# Clone the repository
git clone https://github.com/iarunsaragadam/flutter-docker.git
cd flutter-docker
# Build the web image
docker build -t flutter-web-builder:local .
# Build the Android image
docker build -f Dockerfile.android -t flutter-android-builder:local .
To build with a specific Flutter version:
docker build --build-arg FLUTTER_VERSION=3.29.0 -t flutter-web-builder:local .
Built from ubuntu:22.04
with:
- Flutter SDK
- Web dependencies
- Web port exposed on 5000
Built from ubuntu:22.04
with:
- Flutter SDK
- Java 17
- Android SDK
- Build tools
- NDK
Both images are built for:
linux/amd64
- For Intel/AMD-based systems (Windows, Intel Macs)linux/arm64
- For ARM-based systems (Apple Silicon Macs)
Images are tagged with the Flutter version they contain:
latest
- Points to the most recent releasev3.29.0
- Specific Flutter version
Here's a complete example to create a new Flutter app and build it using these Docker images:
# Create a directory for your app
mkdir my_flutter_app
cd my_flutter_app
# Create a sample Flutter app using the web builder
docker run -it --rm -v $(pwd):/app ghcr.io/iarunsaragadam/flutter-web-builder:latest flutter create .
# Build the web app (will run automatically with the default command)
docker run -it --rm -v $(pwd):/app ghcr.io/iarunsaragadam/flutter-web-builder:latest
# Your web build is now available in build/web/
# You can serve it with Nginx:
docker run -it --rm -v $(pwd)/build/web:/usr/share/nginx/html -p 8080:80 nginx:alpine
Then open http://localhost:8080 in your browser.
# From the same app directory
docker run -it --rm -v $(pwd):/app ghcr.io/iarunsaragadam/flutter-android-builder:latest
# Your APK is now available at build/app/outputs/flutter-apk/app-release.apk
For a typical development workflow:
-
Create your app:
docker run -it --rm -v $(pwd):/app ghcr.io/iarunsaragadam/flutter-web-builder:latest flutter create .
-
Work on your code locally using your favorite editor
-
Run tests:
docker run -it --rm -v $(pwd):/app ghcr.io/iarunsaragadam/flutter-web-builder:latest flutter test
-
Build for Web:
docker run -it --rm -v $(pwd):/app ghcr.io/iarunsaragadam/flutter-web-builder:latest flutter build web
-
Build for Android:
docker run -it --rm -v $(pwd):/app ghcr.io/iarunsaragadam/flutter-android-builder:latest