-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.android
More file actions
60 lines (43 loc) · 1.76 KB
/
Dockerfile.android
File metadata and controls
60 lines (43 loc) · 1.76 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
# Stage 1: Get artifacts from local Docker image
FROM app4dog-artifacts:latest AS artifacts
# Stage 2: Use newer Android build image with Java 21
FROM docker.io/cimg/android:2024.10.1-node
# Install pnpm globally as root
USER root
RUN npm install -g pnpm
# Set working directory and change ownership to circleci user
WORKDIR /app
RUN chown -R circleci:circleci /app
# Switch back to circleci user
USER circleci
# Copy source code (including package.json)
COPY --chown=circleci:circleci . .
# Copy artifacts from the artifacts stage
COPY --from=artifacts --chown=circleci:circleci /artifacts ./artifacts
# Copy critters directly from artifacts to public directory
COPY --from=artifacts --chown=circleci:circleci /artifacts/critters ./public/critters
# Install Node.js dependencies
RUN pnpm install --no-frozen-lockfile
# Build the web app
RUN pnpm run build
# Sync with Capacitor
RUN npx cap sync android
# Set Android environment variables
ENV ANDROID_HOME=/opt/android/sdk
ENV PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
# Check Java version and set compatibility
RUN java -version
RUN which java
# Set Java compatibility for Gradle build (use Java 17 instead of 21)
ENV GRADLE_OPTS="-Dorg.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError"
ENV ORG_GRADLE_PROJECT_android.useAndroidX=true
ENV ORG_GRADLE_PROJECT_android.enableJetifier=true
# Build the APK with increased memory and compatibility settings
WORKDIR /app/android
RUN ./gradlew assembleDebug --no-daemon --stacktrace -PjavaVersion=17
# Copy APK to output directory
RUN mkdir -p /app/output
RUN cp app/build/outputs/apk/debug/*.apk /app/output/
# Set the output directory as volume
VOLUME ["/app/output"]
CMD ["echo", "APK build complete! Check /app/output/ for the APK file."]