Files
easy-wallet/contrib/android/Dockerfile
Davide Grilli e785179ee4 feat(android): add Capacitor APK build with pure-JS crypto layer
Introduces a platform abstraction so the React app runs on both
Electron (desktop) and Android (WebView via Capacitor) without any
Python backend:

- frontend/src/services/crypto-service.js: pure-JS reimplementation of
  all address types (P2PKH, P2WPKH, P2TR, P2PK, P2SH multisig) and HD
  wallet generation (BIP-32/39/44/49/84/86) using @noble/curves,
  @noble/hashes, @scure/bip32, @scure/bip39, bech32, bs58.
  AES-256-CBC encryption via Web Crypto API, Electrum-compatible key
  derivation (SHA256(SHA256(password))).
- frontend/src/services/api.js: detects Electron (window.electronAPI)
  vs Android (Capacitor Filesystem) at runtime; components are
  unchanged in behaviour.
- frontend/src/components/{HDWallet,SingleAddress,WalletViewer}.jsx:
  import api instead of window.electronAPI directly.
- frontend/package.json: @noble/*, @scure/*, bech32, bs58,
  @capacitor/core, @capacitor/filesystem, @capacitor/cli,
  @capacitor/android; cap:sync script.
- frontend/capacitor.config.json: appId com.walletgen.app, webDir dist.
- contrib/android/Dockerfile + build.sh: JDK 17, Android SDK 34,
  cap add/sync, ./gradlew assembleDebug; outputs wallet-gen-debug.apk
2026-03-10 14:09:58 +01:00

56 lines
2.6 KiB
Docker

FROM node:22.14.0-bookworm
# ── System deps: JDK 17 + tooling ─────────────────────────────────────────────
RUN apt-get update && apt-get install -y --no-install-recommends \
default-jdk \
wget unzip \
&& rm -rf /var/lib/apt/lists/*
# ── Android SDK command-line tools ────────────────────────────────────────────
# https://developer.android.com/studio#command-line-tools-only
ENV ANDROID_SDK_ROOT=/opt/android-sdk
ENV PATH="${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