Dockerfile.android-builder: install Android API 36 platform + build-tools 35.0.0 alongside the existing API 34 set. Tauri 2.x mobile defaults to compileSdk 36 / build-tools 35; without these the gradle build fails with "SDK directory is not writable" because the read-only /opt/android-sdk volume can't grow at build time. Adding Node.js 20, all four Rust android targets, and tauri-cli 2.x was already in place. scripts/build-tauri-android.sh: new build wrapper for the desktop/ Tauri project (parallel to scripts/build-and-notify.sh which targets the legacy android/ Kotlin app). Pulls the branch on remote, runs cargo tauri android build inside the docker image, and sends three ntfy.sh/wzp notifications that all carry the short git hash: - STARTED [hash] — <commit subject> - OK [hash] (size) — <rustypaste apk url> - FAILED [hash] (line N) — <rustypaste log url> On failure the full /tmp/wzp-tauri-build.log is uploaded to rustypaste so the URL in the failure ntfy is directly downloadable, same place as the APK. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
107 lines
4.5 KiB
Docker
107 lines
4.5 KiB
Docker
# =============================================================================
|
|
# WZ Phone — Android build environment (Debian 12 / Bookworm)
|
|
#
|
|
# Supports both:
|
|
# 1. Legacy Kotlin+JNI Android app (via cargo-ndk + gradle)
|
|
# 2. Tauri 2.x Mobile Android app (via tauri-cli + Node/npm)
|
|
#
|
|
# Toolchain:
|
|
# - Debian 12 (cmake 3.25, no Android cross-compilation bugs)
|
|
# - JDK 17 (Gradle 8.5 + AGP 8.2.0 compatible)
|
|
# - NDK 26.1 (last stable before scudo/MTE crash on NDK 27+)
|
|
# - Node.js 20 LTS (for Tauri frontend build)
|
|
# - Rust stable with all 4 Android targets + cargo-ndk + tauri-cli 2.x
|
|
#
|
|
# Build: docker build -t wzp-android-builder -f Dockerfile.android-builder .
|
|
# =============================================================================
|
|
FROM debian:bookworm
|
|
|
|
ARG NDK_VERSION=26.1.10909125
|
|
ARG ANDROID_API=34
|
|
# Tauri 2.x mobile targets compileSdk 36 + build-tools 35 by default. Install
|
|
# both 34 (legacy Kotlin app) and 35/36 (Tauri mobile) so the same image works
|
|
# for both pipelines.
|
|
ARG ANDROID_API_TAURI=36
|
|
ARG BUILD_TOOLS_TAURI=35.0.0
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive \
|
|
ANDROID_HOME=/opt/android-sdk \
|
|
JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
|
|
|
|
ENV ANDROID_NDK_HOME=$ANDROID_HOME/ndk/$NDK_VERSION \
|
|
ANDROID_NDK=$ANDROID_HOME/ndk/$NDK_VERSION
|
|
|
|
# ── System packages ──────────────────────────────────────────────────────────
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
cmake \
|
|
curl \
|
|
git \
|
|
libssl-dev \
|
|
pkg-config \
|
|
unzip \
|
|
wget \
|
|
zip \
|
|
openjdk-17-jdk-headless \
|
|
ca-certificates \
|
|
libasound2-dev \
|
|
file \
|
|
xz-utils \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# ── Node.js 20 LTS (required by Tauri for frontend build) ────────────────────
|
|
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
|
&& apt-get install -y --no-install-recommends nodejs \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& node --version \
|
|
&& npm --version
|
|
|
|
# ── Android SDK + NDK 26.1 ──────────────────────────────────────────────────
|
|
RUN mkdir -p $ANDROID_HOME/cmdline-tools \
|
|
&& cd /tmp \
|
|
&& wget -q https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -O cmdtools.zip \
|
|
&& unzip -qo cmdtools.zip -d $ANDROID_HOME/cmdline-tools \
|
|
&& mv $ANDROID_HOME/cmdline-tools/cmdline-tools $ANDROID_HOME/cmdline-tools/latest \
|
|
&& rm cmdtools.zip
|
|
|
|
RUN yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null 2>&1 \
|
|
&& $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install \
|
|
"platforms;android-${ANDROID_API}" \
|
|
"build-tools;${ANDROID_API}.0.0" \
|
|
"platforms;android-${ANDROID_API_TAURI}" \
|
|
"build-tools;${BUILD_TOOLS_TAURI}" \
|
|
"ndk;${NDK_VERSION}" \
|
|
"platform-tools" \
|
|
2>&1 | grep -v '^\[' > /dev/null
|
|
|
|
# Make SDK world-readable so builder user can access it
|
|
RUN chmod -R a+rX $ANDROID_HOME
|
|
|
|
# ── Builder user (1000:1000) ─────────────────────────────────────────────────
|
|
RUN groupadd -g 1000 builder \
|
|
&& useradd -m -u 1000 -g 1000 -s /bin/bash builder
|
|
|
|
USER builder
|
|
WORKDIR /home/builder
|
|
|
|
# ── Rust toolchain ───────────────────────────────────────────────────────────
|
|
# Install all 4 Android targets (Tauri Mobile builds for all ABIs by default;
|
|
# cargo-ndk legacy path only needs arm64-v8a — both workflows supported).
|
|
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
|
|
| sh -s -- -y --default-toolchain stable \
|
|
&& . $HOME/.cargo/env \
|
|
&& rustup target add \
|
|
aarch64-linux-android \
|
|
armv7-linux-androideabi \
|
|
i686-linux-android \
|
|
x86_64-linux-android \
|
|
&& cargo install cargo-ndk \
|
|
&& cargo install tauri-cli --version "^2.0" --locked
|
|
|
|
ENV PATH="/home/builder/.cargo/bin:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$JAVA_HOME/bin:$PATH"
|
|
|
|
# NDK_HOME is the env var tauri-cli checks (in addition to ANDROID_NDK_HOME)
|
|
ENV NDK_HOME=$ANDROID_NDK_HOME
|
|
|
|
WORKDIR /build/source
|