-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.android
More file actions
72 lines (59 loc) · 2.65 KB
/
Dockerfile.android
File metadata and controls
72 lines (59 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Extended Dockerfile with Android NDK support
# Build argument to control custom certificate installation.
# Declared globally so it can drive stage selection in the FROM below.
ARG INSTALL_CUSTOM_CERTS=false
FROM eclipse-temurin:17-jdk AS base
# Stage used when INSTALL_CUSTOM_CERTS=false: no-op, no docker-certs/ needed.
FROM base AS certs-false
# Stage used when INSTALL_CUSTOM_CERTS=true: copy and install certs from docker-certs/.
FROM base AS certs-true
RUN apt-get update && apt-get install -y openssl ca-certificates && rm -rf /var/lib/apt/lists/*
COPY docker-certs /tmp/certs-source/
RUN if [ "$(ls -A /tmp/certs-source 2>/dev/null | grep -v README)" ]; then \
echo "Installing custom CA certificates..." && \
openssl version && \
chmod +x /tmp/certs-source/*.sh 2>/dev/null || true && \
cd /tmp/certs-source && \
./install_certs.sh && \
mv splitted/*.crt /usr/local/share/ca-certificates/ 2>/dev/null || true && \
update-ca-certificates && \
echo "Custom certificates installed successfully"; \
else \
echo "Skipping custom certificate installation (no certificates found)"; \
fi && \
rm -rf /tmp/certs-source
# Final image starts from whichever cert stage matches the build arg.
# BuildKit only builds the stage actually selected, so the unused branch's
# COPY (which would fail without a local docker-certs/ dir) is never executed.
FROM certs-${INSTALL_CUSTOM_CERTS} AS final
# Install build tools
RUN apt-get update && apt-get install -y \
cmake \
build-essential \
git \
curl \
wget \
unzip \
libz-dev \
&& rm -rf /var/lib/apt/lists/*
# Install Android SDK and NDK
ENV ANDROID_HOME=/android-sdk
ENV ANDROID_NDK_HOME=/android-ndk
ENV PATH=${PATH}:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/platform-tools
# Download and install Android SDK command-line tools
RUN mkdir -p ${ANDROID_HOME}/cmdline-tools && \
cd ${ANDROID_HOME}/cmdline-tools && \
wget -q https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip && \
unzip commandlinetools-linux-9477386_latest.zip && \
rm commandlinetools-linux-9477386_latest.zip && \
mv cmdline-tools latest
# Accept licenses and install NDK
RUN yes | sdkmanager --licenses || true && \
sdkmanager "platform-tools" "platforms;android-34" "build-tools;34.0.0" "ndk;25.2.9519653"
# Link NDK to expected location
RUN ln -s ${ANDROID_HOME}/ndk/25.2.9519653 ${ANDROID_NDK_HOME}
# Set environment variables for Gradle
ENV GRADLE_USER_HOME=/gradle-cache
ENV GRADLE_OPTS="-Dorg.gradle.daemon=false -Dorg.gradle.parallel=true"
WORKDIR /workspace
CMD ["tail", "-f", "/dev/null"]