Dockerfile 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. `35`)
  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=35
  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. "tools" \
  37. "platform-tools" \
  38. "platforms;android-${SDK_VERSION}" \
  39. "ndk;${NDK_VERSION}" \
  40. "build-tools;${BUILD_TOOLS_VERSION}" \
  41. "emulator"
  42. # The location of the rustup-init script to install rust (rustup, rustc, cargo)
  43. ENV RUSTUP_INIT=/rust/rustup-init.sh
  44. # Set location to install rust
  45. ENV RUSTUP_HOME=/rust/rustup
  46. ENV CARGO_HOME=/rust/cargo
  47. # Copy the rust installation script
  48. COPY rustup-init.sh $RUSTUP_INIT
  49. # Install Rust
  50. RUN $RUSTUP_INIT -y --default-toolchain $RUST_VERSION
  51. ENV PATH="$CARGO_HOME/bin:$PATH"
  52. RUN rustup target add x86_64-linux-android \
  53. && rustup target add i686-linux-android \
  54. && rustup target add armv7-linux-androideabi \
  55. && rustup target add aarch64-linux-android
  56. # Allow anyone to write to the cargo directory
  57. RUN chmod a+w $CARGO_HOME
  58. # Set env variables
  59. ENV PATH="$ANDROID_SDK_ROOT/cmdline-tools/tools/bin:$ANDROID_SDK_ROOT/platform-tools:$PATH"
  60. # Create users with typical UIDs to avoid problems with Docker when remapping the UID
  61. RUN chmod a+w /home && for newuid in $(seq 1000 1010); do useradd -M -d /home -u $newuid -s /bin/bash "user$newuid"; done
  62. # Create cache directories in order to be able to control the permissions of mounted volumes
  63. RUN mkdir -p /code/build /code/app/.cxx \
  64. && chmod 777 /code/build /code/app/.cxx