Dockerfile 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Dockerfile for an Android compilation image, based on Ubuntu LTS.
  2. #
  3. # NOTE: This docker image automatically accepts the Android SDK licenses. It may only be used
  4. # from a wrapper script that explicitly asks the user to accept the license!
  5. #
  6. # Arguments:
  7. #
  8. # - `SDK_VERSION`: Set this to the desired Android SDK version (e.g. `28`)
  9. # - `BUILD_TOOLS_VERSION`: Set this to the desired build tools version (e.g. `28.0.3`)
  10. FROM ubuntu:20.04
  11. # Arguments
  12. ARG SDK_VERSION=29
  13. ARG BUILD_TOOLS_VERSION=29.0.3
  14. ARG NDK_VERSION=21.1.6352462
  15. # Install dependencies
  16. ARG DEBIAN_FRONTEND=noninteractive
  17. RUN apt-get update -q \
  18. && apt-get -y -q install --no-install-recommends \
  19. build-essential file openjdk-8-jdk git wget unzip rsync vim-nox cpu-checker \
  20. && rm -rf /var/lib/apt/lists/*
  21. # Download Android command line tools
  22. RUN mkdir -p /opt/android/cmdline-tools \
  23. && cd /opt/android/cmdline-tools \
  24. && wget https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip \
  25. && unzip commandlinetools-linux-6609375_latest.zip \
  26. && rm commandlinetools-linux-6609375_latest.zip
  27. ENV ANDROID_SDK_ROOT=/opt/android
  28. # Install Android SDK
  29. RUN yes Y | /opt/android/cmdline-tools/tools/bin/sdkmanager --licenses
  30. RUN /opt/android/cmdline-tools/tools/bin/sdkmanager --install \
  31. "tools" \
  32. "platform-tools" \
  33. "platforms;android-${SDK_VERSION}" \
  34. "ndk;${NDK_VERSION}" \
  35. "patcher;v4" \
  36. "build-tools;${BUILD_TOOLS_VERSION}" \
  37. "emulator"
  38. # Set env variables
  39. ENV PATH="$ANDROID_SDK_ROOT/cmdline-tools/tools/bin:$ANDROID_SDK_ROOT/platform-tools:$PATH"
  40. # Create users with typical UIDs to avoid problems with Docker when remapping the UID
  41. RUN chmod a+w /home && for newuid in $(seq 1000 1010); do useradd -M -d /home -u $newuid -s /bin/bash "user$newuid"; done