Skip to content

docker-android provides general purpose docker images to run CI steps of Android project.

Notifications You must be signed in to change notification settings

faberNovel/docker-android

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

docker-android

docker-android

Run test & large tests daily License: GPL v3 Release

docker-android provides general purpose docker images to run CI steps of Android project. Docker allows you to provide a replicable environment, which does not change with the host machine or the CI service. It should work out of the box on any CI/CD service providing docker support. The image is providing standard tools to build and test Android application:

CI/CD service support

CI/CD service Tested
GitHub Actions
GitLab CI
Circle CI 🚧
Travis CI 🚧

Fastlane first-class support

Images are built to have first class support for Fastlane. Ruby versions in normal maintenance mode are installed using rbenv. If you are using a Fastlane plugin which requires a native library:

  • Install it using apt-get update && apt-get -y install <lib> in your CI workflow.
  • Comment #78 so that we can keep track of missing native libraries and add them to the next image version.

JDK support

Images support multiple JDK, using Jenv. The default JDK is JDK 17, but JDK 11 and 8 are also supported (i.e. use jenv global 1.8 to set JDK to verion 8). To choose a JDK, make sure the script executes on a bash shell, then use Jenv to set the desired version:

jobs:
  my_android_job:
    defaults:
      run:
        shell: bash

    steps:
      - name: Jenv
        run: |
          eval "$(jenv init -)"
          jenv global {VERSION}

🐙 GitHub Workflow Sample

Github workflows can run inside Docker images using container attribute after runs-on:

name: GitHub Action sample

on:
  push:
    branches:
      - develop

jobs:
  my_android_job:
    runs-on: ubuntu-22.04 # Works also with self hosted runner supporting docker
    container:
      image: docker://fabernovel/android:api-29-v1.1.0

  steps:
    - name: Checkout
      uses: actions/checkout@v2.1.0

    - name: Ruby Setup
      uses: ruby/setup-ruby@v1
      with:
        bundler-cache: true
      env:
        ImageOS: ubuntu20

    - name: Gradle cache
      uses: actions/cache@v3
      with:
        path: |
          /root/.gradle/caches
          /root/.gradle/wrapper
        key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
        restore-keys: |
          ${{ runner.os }}-gradle-

    - name: Fastlane
      run: bundle exec fastlane my_lane

You can also use the provided Github Action. However, caching won't work and you can expect longer build times. docker-android-tag should be one of the tags found in Fabernovel Hub Registry Tags:

name: GitHub Action sample

on:
  push:
    branches:
      - develop

jobs:
  my_android_job:
    runs-on: ubuntu-22.04 # Works also with self hosted runner supporting docker

  steps:
    - name: Checkout
      uses: actions/checkout@v2.1.0

    - name: Exec fastlane
      uses: fabernovel/docker-android
      with:
        docker-android-tag: api-29-ndk-v1.1.0
        exec: |
          bundle install;
          bundle exec fastlane my_lane

📦 Container Registry

docker-android images are hosted on DockerHub.

🔤 Naming

We provide stable and snapshot variants for latest Android API levels, including or not native SDK. We use the following tagging policy: API-NDK-GCLOUD-VERSION

  • API the Android API to use, like api-28, api-29
  • NDK is the presence or not of the Android NDK in the image
  • GCLOUD is the presence or not of the Google Cloud SDK in the image. (the gcloud sdk is needed for Firebase Test Lab for example).
  • VERSION is the image version. Check Versions

🔢 Versions

  • snapshot versions are build on each push on develop branch
  • Release versions v* on each GitHub Release

📝 Image description

Image description (software and their versions) is provided as md files.

✏️ Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

You can change image settings via its Dockerfile. You can build, test, and deploy image using ci_cd.sh script. You need to install docker first. All scripts must be POSIX compliants.

usage: ./ci_cd.sh [--android-api 29] [--build-tools "29.0.3"] [--build] [--test]
  --android-api <androidVersion> Use specific Android version from `sdkmanager --list`
  --build-tools <version>        Use specific build tools version
  --android-ndk                  Install Android NDK
  --gcloud                       Install Google Cloud SDK
  --ndk-version <version>        Install a specific Android NDK version from `sdkmanager --list`
  --build                        Build image
  --test                         Test image
  --large-test                   Run large tests on the image (Firebase Test Lab for example)
  --deploy                       Deploy image
  --desc                         Generate a .md file in /desc/ouput folder describing the builded image, on host machine

License

GNU GPLv3