HUB
Sign inSign up

hateum/android-ci-box

By hateum

•Updated 1 day ago

Fast, rootless Android CI/CD image with AGP 9.x, SDK 35/36/37, JDK 17/21, GMD & Auto-Detection.

Image
Integration & delivery
Developer tools
0

10K+

hateum/android-ci-box repository overview

⁠Android CI/CD Build Box (hateum/android-ci-box)

Multi-Arch Security Gradle Android SDK Java Fastlane License: MIT

A battle-tested, high-performance, and rootless Docker container engineered for Android CI/CD automation across GitHub Actions, GitLab CI, Jenkins, and Bitbucket Pipelines.

Features a dual-mode network engine (public internet & enterprise intranet with auto-proxy, custom CA certificates, and Nexus mirrors), native multi-arch compilation (amd64 and arm64), and zero-config dynamic auto-detection of project SDK and Java toolchains.


⁠📦 Image Variants Matrix (:slim vs :latest)

Choose the variant that best balances download speed and emulator capabilities:

Feature / Tool:slim (Fast Builds):latest / :full (Batteries-Included)
Download Size (Compressed)~2.2 GB (~35% smaller!)~3.5 GB
Android SDKs (API 35, 36, 37)✅ Yes✅ Yes
Build-Tools (35, 36, 37)✅ Yes✅ Yes
Dual OpenJDK (17 & 21)✅ Yes (switch-jdk)✅ Yes (switch-jdk)
Ruby 4.0.9 + Fastlane 2.241.2✅ Yes✅ Yes
Bundletool 1.18.3 & Android CLI✅ Yes✅ Yes
Dual-Mode Enterprise Network✅ Yes✅ Yes
Sigstore Cosign & SPDX SBOM✅ Yes✅ Yes
Android Emulator (GMD & UI Tests)❌ No (Stripped for speed)✅ Yes (Preinstalled on amd64)
Recommended ForLinting, Unit Tests, Assemble, Fastlane DeployEnd-to-End Instrumented Tests & GMD

⁠⚖️ Why hateum/android-ci-box? (Feature Comparison)

CapabilityStandard Android CI Imageshateum/android-ci-box
Silicon Architecturex86_64 only (Emulated on ARM via slow QEMU)Native Multi-Arch (amd64 + arm64) (Full native silicon speed on Apple Silicon & AWS Graviton)
Project SetupManual SDK/JDK setup scripts per repoZero-Config Dynamic Auto-Detection (compileSdk, buildTools, Java 17/21) in <50ms
Java RuntimesSingle JDK version (fixed at build time)Dual-JDK (OpenJDK 21 + 17) with instant CLI/Env toggle (switch-jdk)
Security & PermissionsHardcoded root (fails on OpenShift/K8s)Universal Rootless (777 permissions), runs safely under any UID (1000:0, 1001:1001)
Vulnerability AuditOften contains unpatched high/critical CVEsZero Unfixed Critical CVEs (strictly audited via Trivy SARIF gates)
Enterprise NetworkCustom Dockerfiles required for proxies & certsAuto-imported CA certs, automatic HTTP proxy & Nexus/Artifactory mirror derivation
Deployment ToolsSlow gem install fastlane on every buildPrecompiled Ruby 4.0.9 + Fastlane 2.241.2 ready out-of-the-box in /opt/rbenv
C/C++ NDK & CMakeMissing or forces massive 4GB+ image sizeDynamic On-Demand Engine (install-ndk-version & INSTALL_NDK_VERSION)
GitHub Action IntegrationRaw container scripting requiredOfficial Composite Action (uses: hatem-noureddine/android-ci@v1)
Build Performance TuningDefault Gradle daemon issues in DockerAuto-injected CI Optimization Init-Script (Parallel, Caching, VFS off)
Testing & EmulationComplex X11/VNC setup or broken displayNative Gradle Managed Devices (GMD) with SwiftShader Headless GPU acceleration
Health DiagnosticsNo diagnostic toolingBuilt-in ci-doctor & detect-android-project CLI utilities with JSON reporting

⁠🏛️ Architecture & 6-Tier Dependency Schema

+-----------------------------------------------------------------------------------------+
|                        Tier 1: Base Operating System (Ubuntu 26.04 LTS)                 |
|             Native Multi-Arch Matrix: linux/amd64 (x86_64) | linux/arm64 (aarch64)      |
+-----------------------------------------------------------------------------------------+
       |                                   |                                   |
       v                                   v                                   v
+------------------------+      +------------------------+      +------------------------+
|  Tier 2: Java Runtimes |      |  Tier 2: Ruby Runtime  |      | Tier 2: System Tools   |
| - OpenJDK 21 (Default) |      | - Ruby 4.0.9 (rbenv)   |      | - Python 3 & Pip (PEP) |
| - OpenJDK 17 (Instant) |      | - Bundler 4.0.23       |      | - GitHub CLI (gh)      |
| - switch-jdk helper    |      | - Fastlane 2.241.2     |      | - curl, git-lfs, zip   |
+------------------------+      +------------------------+      +------------------------+
       |                                   |                                   |
       +-----------------------------------+-----------------------------------+
                                           |
                                           v
+-----------------------------------------------------------------------------------------+
|                    Tier 3: Android Build Engine & Standalone CLI Tooling                |
| - Gradle 9.8.2 Standalone + Dynamic Gradle Wrapper Auto-Execution                       |
| - Android Gradle Plugin (AGP) 8.x & 9.x Fully Supported                                 |
| - Android SDK Platforms: android-35, android-36, android-37 (Pre-installed)             |
| - Android Build-Tools: 35.0.0, 36.0.0, 37.0.0 (Pre-installed)                           |
| - Google Android CLI ('android') & standalone Bundletool 1.18.3                         |
+-----------------------------------------------------------------------------------------+
                                           |
                                           v
+-----------------------------------------------------------------------------------------+
|                 Tier 4: Zero-Config Dynamic Project Auto-Detection Engine               |
| - detect-android-project: Scans build.gradle(.kts) & libs.versions.toml (<50ms)         |
| - Multi-module maximum aggregation: automatically resolves highest compileSdk           |
| - Auto-switches Java 17/21 and installs missing SDKs/build-tools on container startup   |
| - Cross-compatibility: Automatically forces Java 17 if Gradle Wrapper < 8.5 is detected|
+-----------------------------------------------------------------------------------------+
                                           |
                                           v
+-----------------------------------------------------------------------------------------+
|                      Tier 5: Automated Testing & Deployment Tooling                     |
| - Fastlane 2.241.2: Native Google Play Console deployment & lane automation             |
| - Gradle Managed Devices (GMD): SwiftShader Headless GPU & KVM Hardware Acceleration    |
| - Unit Testing, Android Lint & ProGuard/R8 bytecode optimization                        |
+-----------------------------------------------------------------------------------------+
                                           |
                                           v
+-----------------------------------------------------------------------------------------+
|                 Tier 6: Dual-Mode Universal Network & Rootless Security                 |
| - Mode 1: Public Internet (Direct unthrottled access to Google & Maven Central)         |
| - Mode 2: Enterprise Intranet (Auto-Proxy, Custom CA Import, Nexus/Artifactory Mirrors) |
| - Rootless Hardened: Universal 777 permissions (Runs under UID 1000:0, OpenShift, K8s)  |
| - Trivy Certified: 0 Unfixed Critical CVEs                                             |
+-----------------------------------------------------------------------------------------+

⁠⚡ Quick Start by Developer Objective

⁠1. Interactive Debugging & System Healthcheck

Verify container health, Java versions, SDK packages, and network connectivity in seconds:

# Run full interactive diagnostic with network connectivity probes
docker run --rm -v "$(pwd)":/project hateum/android-ci-box:latest ci-doctor

# Inspect project requirements vs installed components (<50ms)
docker run --rm -v "$(pwd)":/project hateum/android-ci-box:latest detect-android-project

# Launch interactive shell
docker run -it --rm -v "$(pwd)":/project -w /project hateum/android-ci-box:latest /bin/bash
⁠2. Build Release APK and Android App Bundle (AAB)

Zero manual setup: the container auto-configures JDK and SDK matching your project:

# Build Release APK
docker run --rm \
  -v "$(pwd)":/project \
  -v "$HOME/.gradle":/home/runner/.gradle \
  -w /project \
  hateum/android-ci-box:latest \
  ./gradlew assembleRelease --no-daemon

# Build Release AAB and extract universal APK with Bundletool
docker run --rm \
  -v "$(pwd)":/project \
  -w /project \
  hateum/android-ci-box:latest \
  bash -c "./gradlew bundleRelease --no-daemon && \
    bundletool build-apks --bundle=app/build/outputs/bundle/release/app-release.aab --output=/tmp/app.apks --mode=universal"
⁠3. Instrumented UI Testing: Gradle Managed Devices (GMD)

Native headless emulator execution with SwiftShader GPU acceleration and KVM support:

docker run --rm \
  --device /dev/kvm \
  -v "$(pwd)":/project \
  -w /project \
  hateum/android-ci-box:latest \
  ./gradlew pixel8api35DebugAndroidTest --no-daemon
⁠4. Continuous Deployment with Fastlane

Deploy directly to Google Play Internal track without installing Ruby gems:

docker run --rm \
  -v "$(pwd)":/project \
  -w /project \
  -e SUPPLY_JSON_KEY_DATA="${PLAY_STORE_JSON_KEY}" \
  hateum/android-ci-box:latest \
  bundle exec fastlane android deploy_internal

⁠🔍 Dynamic Auto-Detection & Cross-Compatibility Safeguards

The container includes a built-in static inspection engine (detect-android-project) executed by entrypoint.sh on startup:

  1. compileSdk Resolution: Scans all sub-modules and selects the maximum target SDK. If missing from /opt/android-sdk, it auto-downloads it on-the-fly.
  2. buildToolsVersion Resolution: Scans for explicit definitions or falls back to ${compileSdk}.0.0 (standard AGP behavior).
  3. Java Version Matching: Selects OpenJDK 17 or 21 matching jvmToolchain or JavaVersion.VERSION_XX.
  4. Gradle ⇄ Java Compatibility Fallback: If a project uses Gradle Wrapper < 8.5 (incompatible with Java 21), the container automatically switches to OpenJDK 17 to prevent build crashes.
  5. Air-Gapped Resiliency: A 2-second network probe tests connectivity before downloading. If running offline, it warns and proceeds without freezing.

⁠🎛️ CI Runtime Environment Variables

Explicit variables take absolute precedence over project auto-detection:

VariableValues / FormatDefaultPurpose
JAVA_VERSION17, 2121Overrides active JDK (updates JAVA_HOME and symlinks).
INSTALL_SDK_VERSION33, 34, 35, 36, 37Auto-detectedInstalls specified Android SDK platform if not present.
INSTALL_BUILD_TOOLS34.0.0, 33.0.3, ...Auto-derivedInstalls specified Android build-tools version.
INSTALL_NDK_VERSION27.2.12479018, 26.1...Auto-detectedInstalls specified Android NDK on-demand.
INSTALL_CMAKE_VERSION3.22.1, 3.28...Auto-detectedInstalls specified Android CMake on-demand.
ENABLE_CI_OPTIMIZATIONStrue, falsetrueEnables/disables automatic Gradle CI parallel & build caching init-script.
AUTO_DETECT_PROJECTtrue, falsetrueEnables/disables static analysis of project build files.
AUTO_INSTALL_SDKtrue, falsetrueAllows/disallows on-the-fly downloading of missing SDK components.
HTTP_PROXY / HTTPS_PROXYhttp://proxy:8080NoneInjected into ~/.gradle/gradle.properties automatically.
NO_PROXYlocalhost,127.0.0.1,.corpNoneConverted to Java pipe-delimited format for gradle.properties.
NEXUS_URLhttps://nexus.corp/repositoryNoneDerives mirror hooks for Google, MavenCentral, GradlePortal.
NEXUS_RUBY_URLhttps://nexus.corp/rubygemsAuto-derivedConfigures Bundler and RubyGems mirror (auto-derived from NEXUS_URL if omitted).
OFFLINE_MODEtrue, falsefalseOpt-in: enforces strict offline build execution (startParameter.offline=true).
CORPORATE_CA_URLURL stringNoneDownloads and imports corporate SSL certificate on startup.
INSECURE_CA_DOWNLOADtrue, falsefalseDisables TLS verification strictly during initial CA download if bootstrap cert is self-signed.
GRADLE_BUILD_CACHE_URLURL stringNoneConfigures remote HTTP Gradle build caching in init.d.

⁠🛠️ CLI Utilities Reference

UtilityLocationUsage ExamplePurpose
ci-doctor/usr/local/bin/ci-doctorci-doctor [--summary | --json]Complete system, Java, SDK, network, and project diagnostics.
detect-android-project/usr/local/bin/detect-android-projectdetect-android-project [path] [--json]Ultra-fast (<50ms) static parser for compileSdk, buildTools, and JDK.
switch-jdk/usr/local/bin/switch-jdkswitch-jdk 17 or source switch-jdk 21Seamlessly toggles between OpenJDK 17 and OpenJDK 21.
install-sdk-version/usr/local/bin/install-sdk-versioninstall-sdk-version 34 or 34.0.0Installs platforms or build-tools via Google Android CLI.
install-ndk-version/usr/local/bin/install-ndk-versioninstall-ndk-version 27.2.12479018 [cmake]Dynamically installs Android NDK and CMake with rootless permissions.
bundletool/usr/local/bin/bundletoolbundletool build-apks --bundle=app.aabGoogle Bundletool 1.18.3 CLI for universal APKs and testing.
android${ANDROID_HOME}/cmdline-tools/latest/bin/androidandroid sdk list, android --versionOfficial Google Android CLI.

⁠🚀 CI/CD Pipeline Recipes

⁠1. GitHub Actions (Official 1-Line Composite Action or Container Job)
⁠Option A: Official GitHub Action (uses: hatem-noureddine/android-ci@v1)
name: Android CI
on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Build & Test Android App
        uses: hatem-noureddine/android-ci@v1
        with:
          run: |
            ci-doctor --summary
            ./gradlew lintRelease testReleaseUnitTest assembleRelease
⁠Option B: Native Container Job (container: image: hateum/android-ci-box:latest)
name: Android CI
on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-24.04
    container:
      image: hateum/android-ci-box:latest
      options: --user 1000:0
    steps:
      - uses: actions/checkout@v4
      - uses: actions/cache@v4
        with:
          path: |
            ~/.gradle/caches
            ~/.gradle/wrapper
          key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
      - name: Run Diagnostics & Lint
        run: |
          ci-doctor --summary
          ./gradlew lintRelease testReleaseUnitTest --no-daemon
      - name: Build Release Bundle
        run: ./gradlew bundleRelease --no-daemon
      - name: Fastlane Google Play Deploy (Optional)
        run: bundle exec fastlane android deploy_internal
        env:
          SUPPLY_JSON_KEY_DATA: ${{ secrets.PLAY_STORE_JSON_KEY }}
⁠2. GitLab CI/CD (.gitlab-ci.yml)
default:
  image: hateum/android-ci-box:latest
  before_script:
    - export GRADLE_USER_HOME="${CI_PROJECT_DIR}/.gradle"
  cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths:
      - .gradle/caches/
      - .gradle/wrapper/

stages: [ test, build ]

lint_and_test:
  stage: test
  script:
    - ci-doctor --summary
    - ./gradlew lintRelease testReleaseUnitTest --no-daemon

build_aab:
  stage: build
  script:
    - ./gradlew bundleRelease --no-daemon
  artifacts:
    paths:
      - app/build/outputs/bundle/release/*.aab
⁠3. Turnkey Enterprise CI Templates & GitLab Component

Production-ready, battle-tested templates are located in ci-templates/⁠:

  • GitLab CI Component: Modern parameterized GitLab 16+ catalog component (spec: inputs: ...).
  • GitLab CI Pipeline: Full multi-stage pipeline with cache, proxy, and test artifacts.
  • Jenkins Declarative Pipeline: Hardened rootless Docker agent (-u 1000:1000) with volume cache and JUnit reports.
  • Bitbucket Pipelines: Reusable step anchors with custom Gradle cache definitions.
  • GitHub Actions Reusable Pipeline: Organization-wide callable workflow (workflow_call).
⁠4. ARM64 Cloud Testing & Device Farms

When running CI on ARM64 nodes (where the Google x86_64 emulator is unavailable), use the built-in CLI dispatcher to run tests on physical Google Firebase Test Lab devices:

run-firebase-testlab --auto-build --device Pixel8 --api 34

⁠🌐 Enterprise & Corporate Intranet Setup

⁠1. SSL Inspection & Custom Corporate CA Certificates

Mount your enterprise certificates (.crt, .cer, .pem) into /certificates:

docker run --rm \
  -v /path/to/corporate-ca.crt:/certificates/corp.crt \
  hateum/android-ci-box:latest ./gradlew assembleRelease

Certificates are automatically registered in the system truststore and Java cacerts.

⁠2. Nexus / Artifactory Mirror Auto-Derivation

Pass your internal repository URL to redirect Google Maven and MavenCentral automatically:

docker run --rm \
  -e NEXUS_URL="https://nexus.corp.internal/repository" \
  -e NEXUS_USER="ci-builder" \
  -e NEXUS_PASSWORD="secretPassword123" \
  hateum/android-ci-box:latest ./gradlew assembleRelease

⁠❓ FAQ & Troubleshooting

⁠1. Can I run on OpenShift, Kubernetes, or hardened runners?

Yes. Universal read/write permissions (777) are set on /project, /builds, /opt, and /home/runner/.gradle, allowing execution under any UID (e.g. --user 1000:0 or --user 1001:1001).

⁠2. How to fix SSL PKIX path building failed?

Mount your corporate certificate into /certificates: docker run -v /path/to/corp-cert.crt:/certificates/corp.crt hateum/android-ci-box:latest ...

⁠3. What is the status of the Android Emulator on ARM64 Linux hosts?

Google compiles the Linux SDK Emulator (emulator) exclusively for x86_64. On ARM64 Linux hosts (e.g. AWS Graviton), compilation, linting, unit tests, and Fastlane run at native silicon speed, while headless emulator tests require an x86_64 runner.


⁠📄 License

This project is open-source software licensed under the MIT License⁠.

Tag summary

Content type

Image

Digest

sha256:d5ec81958…

Size

1.9 GB

Last updated

1 day ago

docker pull hateum/android-ci-box