Skip to content

Instantly share code, notes, and snippets.

@xrviv
Created February 8, 2025 09:52
Show Gist options
  • Save xrviv/4d868dd13154453dcd5eda18afaccf7e to your computer and use it in GitHub Desktop.
Save xrviv/4d868dd13154453dcd5eda18afaccf7e to your computer and use it in GitHub Desktop.
com.cakewallet.cake_wallet.dockerfile.alpha.001
# Filename: com.cakewallet.cake_wallet.dockerfile
# Location: <walletScrutinyCom>/scripts/test/android/com.cakewallet.cake_wallet.dockerfile
# -------------------------------------------------------------------------------
# Builds a container with everything needed to compile and sign Cake Wallet from source.
# 1) Start from a base Android+SDK image you trust.
# `walletscrutiny/android:5` is an example. If it lacks some tools, we’ll install them.
FROM docker.io/walletscrutiny/android:5
# 2) Install additional packages needed by Cake Wallet’s scripts
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
wget curl unzip automake build-essential file pkg-config git python3 \
libtool libtinfo5 cmake openjdk-8-jre-headless clang sudo xz-utils \
&& rm -rf /var/lib/apt/lists/*
# 3) Install Flutter (version 3.24.4) manually
ENV FLUTTER_VERSION=3.24.4
RUN wget -O /tmp/flutter.tar.xz "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${FLUTTER_VERSION}-stable.tar.xz" \
&& tar -xf /tmp/flutter.tar.xz -C /usr/local \
&& rm /tmp/flutter.tar.xz
ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}"
# 4) Install Rust via rustup
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
# 5) At runtime (podman run ...), do the entire build process in an ENTRYPOINT script.
ENTRYPOINT ["/bin/bash", "-c", "\
set -euo pipefail; \
echo '=== Container runtime: Cloning and building Cake Wallet ==='; \
\
# Clone the main branch of Cake Wallet
cd /root && git clone --branch main https://github.com/cake-tech/cake_wallet.git && cd cake_wallet; \
\
# Build the native libraries (Monero, Haven, etc.) inside scripts/android
echo '=== Running Cake Wallet scripts ==='; \
cd scripts/android; \
if [ -f ./install_ndk.sh ]; then \
echo 'Installing NDK...'; \
./install_ndk.sh; \
fi; \
\
# Choose either \"cakewallet\" or \"monero.com\" flavor
source ./app_env.sh cakewallet; \
./app_config.sh; \
./build_all.sh; \
\
# Return to repo root, run Flutter steps
cd ../../; \
flutter pub get; \
dart run tool/generate_new_secrets.dart; \
\
# Provide keystore credentials via env vars (STORE_PASS, KEY_PASS)
# If none provided, defaults won't sign properly, but won't fail here
echo '=== Generating android key properties ==='; \
dart run tool/generate_android_key_properties.dart \
keyAlias=key \
storeFile=/root/key.jks \
storePassword=\"${STORE_PASS:-storePasswordHere}\" \
keyPassword=\"${KEY_PASS:-keyPasswordHere}\"; \
\
dart run tool/generate_localization.dart; \
./model_generator.sh; \
\
echo '=== Building AAB (release) ==='; \
flutter build appbundle --release; \
\
AAB_PATH=build/app/outputs/bundle/release/app-release.aab; \
if [ ! -f \"$AAB_PATH\" ]; then \
echo 'ERROR: app-release.aab not found!'; \
exit 1; \
fi; \
\
# Download bundletool to produce split APKs
echo '=== Downloading bundletool ==='; \
BUNDLETOOL_JAR=/root/bundletool.jar; \
wget -O \"$BUNDLETOOL_JAR\" https://github.com/google/bundletool/releases/download/1.14.1/bundletool-all-1.14.1.jar; \
APKS_FILE=/root/app-release.apks; \
\
echo '=== Building APKS with bundletool ==='; \
java -jar \"$BUNDLETOOL_JAR\" build-apks \
--bundle=\"$AAB_PATH\" \
--output=\"$APKS_FILE\" \
--ks=/root/key.jks \
--ks-key-alias=key \
--ks-pass=pass:\"${STORE_PASS:-storePasswordHere}\" \
--key-pass=pass:\"${KEY_PASS:-keyPasswordHere}\" \
--mode=default; \
\
# Now extract split APKs. If DEVICE_SPEC is present, we use it, else universal
echo '=== Extracting split APKs ==='; \
mkdir -p /output/built-split_apks; \
if [ -n \"${DEVICE_SPEC:-}\" ]; then \
echo \"Using deviceSpec: $DEVICE_SPEC\"; \
echo \"(At runtime, mount a file or set a path to read that. This example expects /output/device-spec.json if you want to use it.)\"; \
java -jar \"$BUNDLETOOL_JAR\" extract-apks \
--apks=\"$APKS_FILE\" \
--device-spec=\"${DEVICE_SPEC:-}\" \
--output-dir=/output/built-split_apks; \
else \
# By default extract all splits
java -jar \"$BUNDLETOOL_JAR\" extract-apks \
--apks=\"$APKS_FILE\" \
--output-dir=/output/built-split_apks; \
fi; \
\
# Rename base-master.apk to base.apk
cd /output/built-split_apks; \
if [ -f base-master.apk ]; then \
mv base-master.apk base.apk; \
fi; \
# Optionally rename other splits to match split_config.*.apk
for f in *.apk; do \
if [ \"$f\" = \"base.apk\" ]; then continue; fi; \
case \"$f\" in \
split_config.*.apk) ;; \
*) mv \"$f\" \"split_config.$f\" ;; \
esac; \
done; \
\
echo '=== Build container finished successfully. Check /output/built-split_apks ==='; \
"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment