Dockerfile 2.7 KB

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