This repository contains an ultra-optimized Docker image for Flutter CI/CD pipelines, specifically designed to provide fast builds with pre-installed Android SDK components and optimized memory settings for 12GB RAM environments.
Features
Ultra Small : ~400MB (vs 1.2GB+ for Ubuntu-based images)
Complete Environment : Includes all tools needed for Flutter CI/CD
Alpine Linux Base : Lightweight and secure
Pre-installed Android SDK Components : Eliminates CI download delays
Memory Optimized : Configured for 12GB RAM environments
Fast Builds : 5-10+ minutes faster CI builds with no SDK downloads
All Dependencies Pre-installed : Flutter, Android SDK, OpenJDK, Ruby/Fastlane, Python/Google APIs
Included Components
Development Tools
Flutter SDK : Version 3.35.4 (stable)
Android SDK :
Command Line Tools (latest)
Platform Tools (latest)
Multiple Platforms : Android-36, Android-35, Android-34, Android-33, Android-31
Build Tools : 36.0.0 and 35.0.0
NDK : Version 28.2.*** (pre-installed for native compilation)
OpenJDK : Version 17
Ruby : With Bundler 2.6.9 and Fastlane
Python 3 : With Google API client libraries
Memory Configuration (12GB RAM Optimized)
Gradle JVM : 11GB heap with G1GC and string deduplication
Kotlin Daemon : 8GB heap for fast compilation
Metaspace : 1GB for Gradle, 512MB for Kotlin
Workers : 4 parallel workers for optimal CPU utilization
Additional Optimizations : VFS watching, compressed oops, daemon timeout
Environment Variables
bash
ANDROID_HOME=/opt/android-sdk
ANDROID_SDK_ROOT=/opt/android-sdk
JAVA_HOME=/usr/lib/jvm/java-17-openjdk
FLUTTER_ROOT=/opt/flutter
PATH=/opt/flutter/bin:/opt/android-sdk/cmdline-tools/latest/bin:/opt/android-sdk/platform-tools:$JAVA_HOME/bin:$PATH
Use in Docker Compose
yaml
version: '3.8'
services:
flutter-ci:
image: jashem/flutter-ci:3.35.4-v2
volumes:
- ./app:/workspace
- gradle-cache:/root/.gradle
- pub-cache:/root/.pub-cache
working_dir: /workspace
command: flutter build apk --release
Use in Drone CI
Replace ghcr.io/cirruslabs/flutter:3.35.4 with the optimized image:
yaml
steps:
- name: build-app
image: jashem/flutter-ci:3.35.4-v2
commands:
- flutter pub get
- flutter build apk --release
Benefits:
✅ No more SDK downloads during CI builds
✅ Pre-installed NDK for native compilation
✅ Optimized for 12GB RAM environments
✅ 5-10+ minutes faster builds
Optimization Techniques
Alpine Linux Base : Uses minimal Alpine Linux (5MB base vs 77MB Ubuntu)
glibc Compatibility : Uses gcompat for Android SDK compatibility
Layer Optimization : Single RUN layer for system packages
Package Cleanup : Automatic cache cleanup during build
Version Pinning : Exact versions for reproducible builds
Pre-installed SDK Components : Eliminates CI download delays
Memory Optimization : 12GB RAM configuration with G1GC and string deduplication
Parallel Processing : Optimized worker count and VFS watching
Cache Volumes for CI/CD
For optimal CI/CD performance, mount these volumes:
/root/.gradle - Gradle dependencies
/root/.pub-cache - Flutter packages
/root/.local/share/gem - Ruby gems
/root/.cache/pip - Python packages
/var/cache/apt - System package cache (if needed)
Performance Comparison
Metric Ubuntu-based Alpine-based Improvement Image Size ~1.2GB ~400MB 67% smaller Build Time 10-15min 3-5min 70% faster Pull Time 2-3min 30-45s 75% faster Storage High Low Significant savings CI Build Time 15-20min 5-10min 50-67% faster
CI Performance Improvements
Before (v3.35.4)
❌ NDK downloaded during every build (~2-3 minutes)
❌ Platform SDKs downloaded (31, 33, 34, 35) (~1-2 minutes)
❌ Build Tools 35 downloaded during build (~30 seconds)
❌ License acceptance during every build
❌ 10GB Gradle heap limit
❌ 4GB Kotlin daemon limit
After (v3.35.4-v2)
✅ All SDK components pre-installed
✅ NDK 28.2.*** pre-installed
✅ Platform SDKs 31, 33, 34, 35, 36 pre-installed
✅ Build Tools 35.0.0 & 36.0.0 pre-installed
✅ All licenses pre-accepted
✅ 11GB Gradle heap + G1GC optimization
✅ 8GB Kotlin daemon for fast compilation
✅ Memory optimized for 12GB RAM environments
Result : 5-10+ minutes faster CI builds with no download delays and optimized compilation performance.
Verification
✅ Flutter SDK installation and version
✅ Android SDK components and licenses
✅ NDK installation (28.2.***)
✅ Platform SDKs (31, 33, 34, 35, 36)
✅ Build Tools (35.0.0, 36.0.0)
✅ Fastlane installation
✅ Python Google API packages
✅ Memory configuration verification