diff --git a/.github/workflows/build-docker-images.yml b/.github/workflows/build-docker-images.yml index 09bfb72..82b8b19 100644 --- a/.github/workflows/build-docker-images.yml +++ b/.github/workflows/build-docker-images.yml @@ -48,4 +48,32 @@ jobs: tags: ghcr.io/${{ github.repository_owner }}/cross-build-${{ matrix.arch.name }}:latest + build-android-image: + name: Build Android Docker Image + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - uses: actions/checkout@v4.1.6 + with: + fetch-depth: 0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build Docker images + uses: docker/build-push-action@v6 + with: + context: android-build + file: android-build/Dockerfile + push: true + tags: + ghcr.io/${{ github.repository_owner }}/android-build:latest diff --git a/android-build/Dockerfile b/android-build/Dockerfile new file mode 100644 index 0000000..9fbc143 --- /dev/null +++ b/android-build/Dockerfile @@ -0,0 +1,59 @@ +FROM ubuntu:22.04 + +# Set environment variables to avoid interactive prompts during installation +ENV DEBIAN_FRONTEND=noninteractive +ENV CMDLINETOOLS_VERSION=14742923 +ENV NDK_VERSION=29.0.14206865 +ENV ANDROID_HOME=/opt/android-sdk +ENV ANDROID_NDK_HOME=/opt/android-sdk/ndk/${NDK_VERSION} +ENV PATH=${PATH}:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/platform-tools:${ANDROID_NDK_HOME} + +# Install system dependencies +RUN echo 'APT::Install-Suggests "0";' >> /etc/apt/apt.conf.d/00-docker && \ + echo 'APT::Install-Recommends "0";' >> /etc/apt/apt.conf.d/00-docker && \ + apt-get update && apt-get install -y \ + curl \ + wget \ + zip \ + unzip \ + openjdk-17-jdk-headless \ + git \ + build-essential \ + ninja-build \ + && rm -rf /var/lib/apt/lists/* + +# Update cmake, 22.04 is too old. +COPY hashes.txt /tmp +RUN cd /tmp && \ + curl -LO https://github.com/Kitware/CMake/releases/download/v4.3.2/cmake-4.3.2-linux-x86_64.sh && \ + sha256sum -c hashes.txt && \ + chmod +x cmake-4.3.2-linux-x86_64.sh && \ + ./cmake-4.3.2-linux-x86_64.sh --prefix=/usr/local --skip-license && \ + rm cmake-4.3.2-linux-x86_64.sh + +# Create directory for Android SDK +RUN mkdir -p ${ANDROID_HOME} + +# Download and install Android Command Line Tools +RUN wget -q https://dl.google.com/android/repository/commandlinetools-linux-${CMDLINETOOLS_VERSION}_latest.zip -O /tmp/cmdline-tools.zip && \ + unzip -q /tmp/cmdline-tools.zip -d /tmp && \ + mkdir -p ${ANDROID_HOME}/cmdline-tools && \ + mv /tmp/cmdline-tools ${ANDROID_HOME}/cmdline-tools/latest && \ + rm /tmp/cmdline-tools.zip + +# Accept Android SDK licenses +# Install Android SDK components and NDK +RUN yes | sdkmanager --licenses && \ + sdkmanager \ + "platform-tools" \ + "ndk;${NDK_VERSION}" + +# Set up user +RUN useradd -ms /bin/bash build +USER build + +# Set working directory +WORKDIR /workspace + +# Default command +#CMD ["/bin/bash"] diff --git a/android-build/hashes.txt b/android-build/hashes.txt new file mode 100644 index 0000000..d129ab6 --- /dev/null +++ b/android-build/hashes.txt @@ -0,0 +1,2 @@ +ee0b34a9a55a0d6220eceed0eab44047bbdbdc40fae0a89ba41635548a673fac cmake-4.3.2-linux-x86_64.sh +