11# Use a base Ubuntu image
22FROM --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
511ENV DEBIAN_FRONTEND=noninteractive
612ENV USER="docker"
@@ -28,9 +34,9 @@ RUN adduser $USER sudo
2834RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
2935
3036USER $USER
31- RUN sudo apt update
37+ RUN sudo apt update
3238
33- # Install OpenJDK 17
39+ # Install OpenJDK 21
3440RUN 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
4147RUN 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
4559ENV 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
5363RUN 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
6069RUN 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
6572RUN yes | sdkmanager --licenses
6673RUN 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
6980RUN sudo rm -rf /app
7081
7182RUN sudo mkdir /app
7283
7384RUN 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
8695WORKDIR /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)
95107RUN 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
0 commit comments