- Track frontend/capacitor.config.json with appId/appName/webDir for Capacitor Android setup - Unignore frontend/capacitor.config.json so config is committed with the project - Update Android Docker builder to use JDK 21 (required by current Capacitor/Gradle toolchain) - Switch Docker CMD to JSON-array form for safer signal handling - Refresh frontend package-lock.json to match Capacitor and crypto dependencies required by npm ci
60 lines
2.7 KiB
Docker
60 lines
2.7 KiB
Docker
FROM node:22.14.0-bookworm
|
|
|
|
# ── System deps + JDK 21 (required by current Capacitor Android toolchain) ───
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
ca-certificates \
|
|
wget unzip \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
ENV JAVA_HOME=/opt/java/openjdk
|
|
RUN mkdir -p "${JAVA_HOME}" && \
|
|
wget -qO- "https://api.adoptium.net/v3/binary/latest/21/ga/linux/x64/jdk/hotspot/normal/eclipse?project=jdk" \
|
|
| tar -xz -C "${JAVA_HOME}" --strip-components=1
|
|
|
|
# ── Android SDK command-line tools ────────────────────────────────────────────
|
|
# https://developer.android.com/studio#command-line-tools-only
|
|
ENV ANDROID_SDK_ROOT=/opt/android-sdk
|
|
ENV PATH="${JAVA_HOME}/bin:${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin:${ANDROID_SDK_ROOT}/platform-tools:${PATH}"
|
|
|
|
RUN mkdir -p "${ANDROID_SDK_ROOT}/cmdline-tools" && \
|
|
wget -q \
|
|
"https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip" \
|
|
-O /tmp/cmdtools.zip && \
|
|
unzip -q /tmp/cmdtools.zip -d "${ANDROID_SDK_ROOT}/cmdline-tools" && \
|
|
mv "${ANDROID_SDK_ROOT}/cmdline-tools/cmdline-tools" \
|
|
"${ANDROID_SDK_ROOT}/cmdline-tools/latest" && \
|
|
rm /tmp/cmdtools.zip
|
|
|
|
# Accept licences and install required SDK packages
|
|
RUN yes | sdkmanager --licenses > /dev/null 2>&1 && \
|
|
sdkmanager \
|
|
"platforms;android-34" \
|
|
"build-tools;34.0.0" \
|
|
"platform-tools"
|
|
|
|
WORKDIR /build
|
|
|
|
# Copy repo
|
|
COPY . .
|
|
|
|
# ── JS dependencies ───────────────────────────────────────────────────────────
|
|
RUN cd frontend && npm ci
|
|
|
|
# ── Vite production build (generates dist/) ───────────────────────────────────
|
|
RUN cd frontend && npx vite build
|
|
|
|
# ── Capacitor: generate android/ project and copy web assets ─────────────────
|
|
# cap init reads capacitor.config.json; cap add android generates the project;
|
|
# cap sync copies dist/ into android/app/src/main/assets/public/
|
|
RUN cd frontend && \
|
|
npx cap add android && \
|
|
npx cap sync android
|
|
|
|
# ── Build debug APK (self-signed with auto-generated debug keystore) ──────────
|
|
RUN cd frontend/android && \
|
|
chmod +x gradlew && \
|
|
./gradlew assembleDebug --no-daemon
|
|
|
|
# ── Export APK ────────────────────────────────────────────────────────────────
|
|
CMD ["cp", "frontend/android/app/build/outputs/apk/debug/app-debug.apk", "/out/wallet-gen-debug.apk"]
|