Skip to content

Commit f5b09d2

Browse files
chore: add reproducible build verification script
1 parent 2264fc9 commit f5b09d2

4 files changed

Lines changed: 483 additions & 29 deletions

File tree

Dockerfile

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Use a base Ubuntu image
22
FROM --platform=linux/amd64 ubuntu:24.04
33

4+
# Build arguments
5+
ARG VERSION=main
6+
ARG MODE=debug
7+
ARG FORMAT=apk
8+
ARG SOURCE=github
9+
410
# Avoid prompts from apt
511
ENV DEBIAN_FRONTEND=noninteractive
612
ENV USER="docker"
@@ -28,9 +34,9 @@ RUN adduser $USER sudo
2834
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
2935

3036
USER $USER
31-
RUN sudo apt update
37+
RUN sudo apt update
3238

33-
# Install OpenJDK 17
39+
# Install OpenJDK 21
3440
RUN sudo apt-get update && sudo apt-get install -y openjdk-21-jdk && sudo rm -rf /var/lib/apt/lists/*
3541

3642
# Install Rust
@@ -40,14 +46,18 @@ ENV PATH="/home/$USER/.cargo/bin:${PATH}"
4046
# Verify Rust installation
4147
RUN rustc --version && cargo --version
4248

49+
# Install Android Rust targets for cross-compilation
50+
RUN rustup target add aarch64-linux-android
51+
RUN rustup target add armv7-linux-androideabi
52+
RUN rustup target add x86_64-linux-android
53+
RUN rustup target add i686-linux-android
54+
55+
# Set Rust flags for reproducible builds (remap absolute paths)
56+
ENV RUSTFLAGS="--remap-path-prefix=/home/docker/.cargo=/cargo --remap-path-prefix=/app=/build"
57+
4358
# Set environment variables
44-
ENV FLUTTER_HOME=/opt/flutter
4559
ENV ANDROID_HOME=/opt/android-sdk
46-
ENV PATH=$FLUTTER_HOME/bin:$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools
47-
48-
# Install Flutter
49-
RUN sudo git clone https://github.com/flutter/flutter.git $FLUTTER_HOME
50-
RUN sudo sh -c "cd $FLUTTER_HOME && git checkout stable && ./bin/flutter --version"
60+
ENV PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools
5161

5262
# Set up Android SDK
5363
RUN sudo mkdir -p ${ANDROID_HOME}/cmdline-tools && \
@@ -56,40 +66,42 @@ RUN sudo mkdir -p ${ANDROID_HOME}/cmdline-tools && \
5666
sudo mv ${ANDROID_HOME}/cmdline-tools/cmdline-tools ${ANDROID_HOME}/cmdline-tools/latest && \
5767
sudo rm android-cmdline-tools.zip
5868

59-
RUN sudo chown -R $USER /opt/flutter
6069
RUN sudo chown -R $USER /opt/android-sdk
6170

62-
RUN flutter config --android-sdk=/opt/android-sdk
63-
6471
# Accept licenses and install necessary Android SDK components
6572
RUN yes | sdkmanager --licenses
6673
RUN sdkmanager "platform-tools" "platforms;android-35" "build-tools;35.0.0"
6774

75+
# Install FVM (Flutter Version Manager)
76+
RUN cd /home/$USER && curl -fsSL https://fvm.app/install.sh | bash
77+
ENV PATH="/home/$USER/fvm/bin:/home/$USER/.pub-cache/bin:${PATH}"
78+
6879
# Clean up existing app directory
6980
RUN sudo rm -rf /app
7081

7182
RUN sudo mkdir /app
7283

7384
RUN sudo chown -R $USER /app
7485

75-
# Clone the Bull Bitcoin mobile repository
76-
RUN git clone --branch main https://github.com/SatoshiPortal/bullbitcoin-mobile /app
77-
78-
# Create device-spec.json directly in the container
79-
RUN echo '{\
80-
"supportedAbis": ["armeabi-v7a", "armeabi"],\
81-
"supportedLocales": ["en"],\
82-
"screenDensity": 280,\
83-
"sdkVersion": 31\
84-
}' > /app/device-spec.json
86+
# Get source code (clone from GitHub or copy local files)
87+
COPY . /app/local-source/
88+
RUN if [ "$SOURCE" = "local" ]; then \
89+
cp -r /app/local-source/. /app/ && rm -rf /app/local-source; \
90+
else \
91+
rm -rf /app/local-source && \
92+
git clone --branch ${VERSION} https://github.com/SatoshiPortal/bullbitcoin-mobile /app; \
93+
fi
8594

8695
WORKDIR /app
8796

97+
# Install Flutter version specified in .fvmrc
98+
RUN fvm install
99+
88100
# Setup the project
89-
RUN make clean
90-
RUN make deps
91-
RUN make build-runner
92-
RUN make l10n
101+
RUN fvm flutter clean
102+
RUN fvm flutter pub get
103+
RUN fvm dart run build_runner build --delete-conflicting-outputs
104+
RUN fvm flutter gen-l10n
93105

94106
# Create .env (empty values)
95107
RUN cp .env.template .env
@@ -103,5 +115,9 @@ RUN echo "storePassword=android" > /app/android/key.properties && \
103115
echo "keyAlias=upload" >> /app/android/key.properties && \
104116
echo "storeFile=/app/upload-keystore.jks" >> /app/android/key.properties
105117

106-
# Build APK with specific target platform
107-
RUN flutter build apk --debug --target-platform android-arm64
118+
# Build the app
119+
RUN if [ "$FORMAT" = "aab" ]; then \
120+
fvm flutter build appbundle --${MODE}; \
121+
else \
122+
fvm flutter build apk --${MODE}; \
123+
fi

cargokit_options.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ verbose_logging: false
55
# and deployed precompiled binaries, these will be by default used whenever Rustup
66
# is not installed. With `use_precompiled_binaries` set to false, the build will
77
# instead be aborted prompting user to install Rustup.
8-
use_precompiled_binaries: true
8+
use_precompiled_binaries: false

makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: all setup clean deps build-runner translations hooks ios-pod-update drift-migrations docker-build docker-run test unit-test integration-test fvm-check
1+
.PHONY: all setup clean deps build-runner translations hooks ios-pod-update drift-migrations docker-build docker-run test unit-test integration-test fvm-check build
22

33
fvm-check:
44
@echo "🔍 Checking FVM"
@@ -61,6 +61,13 @@ docker-build:
6161
@echo "🏗️ Building Docker image"
6262
@ docker build -t bull-mobile .
6363

64+
MODE ?= debug
65+
FORMAT ?= apk
66+
67+
build:
68+
@echo "🔨 Building $(FORMAT) ($(MODE))"
69+
@RUSTFLAGS="--remap-path-prefix=$$HOME/.cargo=/cargo --remap-path-prefix=$$(pwd)=/build" \
70+
fvm flutter build $(if $(filter aab,$(FORMAT)),appbundle,apk) --$(MODE)
6471

6572
test: unit-test integration-test
6673

0 commit comments

Comments
 (0)