Dockerfile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Dockerfile for an Android compilation image, based on Debian Trixie Slim.
  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. # - `JAVA_VERSION`: Set this to the desired Java version (e.g. 21)
  9. # - `SDK_VERSION`: Set this to the desired Android SDK version (e.g. `36`)
  10. # - `NDK_VERSION`: Set this to the desired Android NDK version (e.g. `25.2.9519653`)
  11. # - `BUILD_TOOLS_VERSION`: Set this to the desired build tools version (e.g. `35.0.0`)
  12. # - `RUST_VERSION`: Set this to the desired Rust version (e.g. `1.80`)
  13. FROM docker.io/debian:trixie-slim
  14. # Arguments
  15. ARG JAVA_VERSION=21
  16. ARG SDK_VERSION=36
  17. ARG BUILD_TOOLS_VERSION=35.0.0
  18. ARG NDK_VERSION=28.2.13676358
  19. ARG RUST_VERSION
  20. # Install dependencies
  21. ARG DEBIAN_FRONTEND=noninteractive
  22. RUN apt-get update -q \
  23. && apt-get -y -q install --no-install-recommends \
  24. build-essential file "openjdk-${JAVA_VERSION}-jdk" git wget unzip rsync vim-nox cpu-checker curl python3 protobuf-compiler \
  25. && rm -rf /var/lib/apt/lists/*
  26. # Download Android command line tools
  27. RUN mkdir -p /opt/android/cmdline-tools \
  28. && cd /opt/android/cmdline-tools \
  29. && wget https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip \
  30. && unzip commandlinetools-linux-6609375_latest.zip \
  31. && rm commandlinetools-linux-6609375_latest.zip
  32. ENV ANDROID_SDK_ROOT=/opt/android
  33. # Install Android SDK
  34. RUN yes Y | /opt/android/cmdline-tools/tools/bin/sdkmanager --licenses
  35. RUN /opt/android/cmdline-tools/tools/bin/sdkmanager --install \
  36. "platform-tools" \
  37. "platforms;android-${SDK_VERSION}" \
  38. "ndk;${NDK_VERSION}" \
  39. "build-tools;${BUILD_TOOLS_VERSION}" \
  40. "emulator"
  41. # The location of the rustup-init script to install rust (rustup, rustc, cargo)
  42. ENV RUSTUP_INIT=/rust/rustup-init.sh
  43. # Set location to install rust
  44. ENV RUSTUP_HOME=/rust/rustup
  45. ENV CARGO_HOME=/rust/cargo
  46. # Copy the rust installation script
  47. COPY rustup-init.sh $RUSTUP_INIT
  48. # Install Rust
  49. RUN $RUSTUP_INIT -y --default-toolchain $RUST_VERSION
  50. ENV PATH="$CARGO_HOME/bin:$PATH"
  51. RUN rustup target add x86_64-linux-android \
  52. && rustup target add i686-linux-android \
  53. && rustup target add armv7-linux-androideabi \
  54. && rustup target add aarch64-linux-android
  55. # Allow anyone to write to the cargo directory
  56. RUN chmod a+w $CARGO_HOME
  57. # Set env variables
  58. ENV PATH="$ANDROID_SDK_ROOT/cmdline-tools/tools/bin:$ANDROID_SDK_ROOT/platform-tools:$PATH"
  59. # Create users with typical UIDs to avoid problems with Docker when remapping the UID
  60. RUN chmod a+w /home && for newuid in $(seq 1000 1010); do useradd -M -d /home -u $newuid -s /bin/bash "user$newuid"; done
  61. # Create cache directories in order to be able to control the permissions of mounted volumes
  62. RUN mkdir -p /code/build /code/app/.cxx \
  63. && chmod 777 /code/build /code/app/.cxx