Dockerfile 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 docker.io/ubuntu:22.04
  11. # Arguments
  12. ARG SDK_VERSION=33
  13. ARG BUILD_TOOLS_VERSION=33.0.2
  14. ARG NDK_VERSION=26.0.10792818
  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-17-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. "build-tools;${BUILD_TOOLS_VERSION}" \
  36. "emulator"
  37. # Set env variables
  38. ENV PATH="$ANDROID_SDK_ROOT/cmdline-tools/tools/bin:$ANDROID_SDK_ROOT/platform-tools:$PATH"
  39. # Create users with typical UIDs to avoid problems with Docker when remapping the UID
  40. RUN chmod a+w /home && for newuid in $(seq 1000 1010); do useradd -M -d /home -u $newuid -s /bin/bash "user$newuid"; done
  41. # Create cache directories in order to be able to control the permissions of mounted volumes
  42. RUN mkdir -p /code/build /code/app/.cxx \
  43. && chmod 777 /code/build /code/app/.cxx