Add Docker-based Android APK build tooling

Multi-stage Dockerfile.android (Bun + Android SDK + Gradle) built via
build-apk.sh, so the APK can be built reproducibly without a local
Android SDK install.
This commit is contained in:
2026-08-12 11:54:39 +02:00
parent 6c9df23659
commit 1983598e38
2 changed files with 82 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
# ── Stage 1: Tools (wird gecacht nur bei SDK-Änderungen neu gebaut) ────────
FROM eclipse-temurin:21-jdk-jammy AS tools
RUN apt-get update && apt-get install -y --no-install-recommends \
curl unzip wget ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Bun
RUN curl -fsSL https://bun.sh/install | bash
ENV PATH="/root/.bun/bin:$PATH"
# Symlink damit Tools mit #!/usr/bin/env node funktionieren
RUN ln -s /root/.bun/bin/bun /usr/local/bin/node
# Android SDK
ENV ANDROID_HOME=/opt/android-sdk
ENV PATH="$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools"
RUN mkdir -p $ANDROID_HOME/cmdline-tools && \
wget -q https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip \
-O /tmp/tools.zip && \
unzip -q /tmp/tools.zip -d $ANDROID_HOME/cmdline-tools && \
mv $ANDROID_HOME/cmdline-tools/cmdline-tools $ANDROID_HOME/cmdline-tools/latest && \
rm /tmp/tools.zip
RUN yes | sdkmanager --licenses > /dev/null 2>&1 && \
sdkmanager \
"platforms;android-35" \
"build-tools;35.0.0" \
"platform-tools"
# ── Stage 2: Build ────────────────────────────────────────────────────────────
FROM tools AS builder
WORKDIR /app
# Abhängigkeiten cachen
COPY client/package.json client/bun.lock* ./client/
RUN cd client && bun install
COPY . .
# 1. Web-App bauen (ohne PWA Service Worker für Capacitor)
RUN cd client && CAPACITOR=1 bun run build
# 2. Web-Assets in das Android-Projekt synchronisieren
# (android/ ist im Repo eingecheckt kein cap add nötig)
RUN cd client && CI=true ./node_modules/.bin/cap sync android
# 3. APK bauen
RUN cd client/android && \
chmod +x gradlew && \
GRADLE_OPTS="-Xmx3g -XX:MaxMetaspaceSize=512m" \
./gradlew assembleDebug --no-daemon
# ── Stage 3: Nur die APK (für --output) ──────────────────────────────────────
FROM scratch
COPY --from=builder \
/app/client/android/app/build/outputs/apk/debug/app-debug.apk \
/tiptoi-sync.apk
Executable
+23
View File
@@ -0,0 +1,23 @@
#!/bin/sh
set -e
if command -v podman > /dev/null 2>&1; then
DOCKER=podman
elif command -v docker > /dev/null 2>&1; then
DOCKER=docker
else
echo "Fehler: weder podman noch docker gefunden." >&2
exit 1
fi
OUT="$(pwd)/apk-output"
mkdir -p "$OUT"
# Immer ohne Cache bauen verhindert dass alte Schichten das Ergebnis verfälschen
$DOCKER build --no-cache \
-f Dockerfile.android \
--output "type=local,dest=$OUT" \
.
echo ""
echo "✓ APK bereit: $OUT/tiptoi-sync.apk"