diff --git a/repro/Dockerfile b/repro/Dockerfile index 1d7b17da..2d5ae34a 100644 --- a/repro/Dockerfile +++ b/repro/Dockerfile @@ -1,40 +1,101 @@ -FROM dart:stable -WORKDIR /usr/local/ - -RUN apt update -RUN apt install -y git openjdk-17-jdk unzip wget curl xz-utils -RUN dpkg --print-architecture -RUN dpkg --print-foreign-architectures -RUN dpkg --remove --force-depends libstdc++6-arm64-cross -RUN apt-get install --reinstall -y libstdc++6 -RUN apt-get -f install -RUN apt-get update -RUN apt-get upgrade -y -RUN apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc++6-arm64-cross libglu1-mesa fonts-droid-fallback libstdc++6-arm64-cross python3 sed -RUN apt-get clean -# RUN apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev - -ENV ANDROID_COMMAND_LINE_TOOLS_FILENAME commandlinetools-linux-10406996_latest.zip -ENV ANDROID_API_LEVELS android-34 -ENV ANDROID_BUILD_TOOLS_VERSION 34.0.0 -ENV ANDROID_HOME /usr/local/android-sdk-linux -ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/cmdline-tools/bin -ENV FLUTTER_VERSION flutter_linux_3.13.2-stable -ENV PATH ${PATH}:/usr/local/flutter/bin - -RUN wget -q "https://dl.google.com/android/repository/${ANDROID_COMMAND_LINE_TOOLS_FILENAME}" -RUN unzip ${ANDROID_COMMAND_LINE_TOOLS_FILENAME} -d /usr/local/android-sdk-linux -RUN rm ${ANDROID_COMMAND_LINE_TOOLS_FILENAME} - -RUN yes | sdkmanager --update --sdk_root="${ANDROID_HOME}" -RUN yes | sdkmanager --sdk_root="${ANDROID_HOME}" "platforms;${ANDROID_API_LEVELS}" "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" "extras;google;m2repository" "extras;android;m2repository" "extras;google;google_play_services" -RUN yes | sdkmanager --licenses --sdk_root="${ANDROID_HOME}" - -RUN rm -rf ${ANDROID_HOME}/tools - -RUN wget -q https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/${FLUTTER_VERSION}.tar.xz -RUN tar -xvf /usr/local/${FLUTTER_VERSION}.tar.xz -RUN git config --global --add safe.directory /usr/local/flutter -# RUN flutter --disable-telemetry -RUN flutter doctor -CMD ["tail", "-f", "/dev/null"] +# Use a base Ubuntu image +FROM ubuntu:20.04 + +# Avoid prompts from apt +ENV DEBIAN_FRONTEND=noninteractive +ENV USER="docker" + +# Install necessary dependencies +RUN apt update && apt install -y \ + curl \ + git \ + unzip \ + xz-utils \ + zip \ + libglu1-mesa \ + wget \ + clang \ + cmake \ + ninja-build \ + pkg-config \ + libgtk-3-dev \ + software-properties-common \ + && rm -rf /var/lib/apt/lists/* + +RUN apt update && apt install -y sudo +RUN adduser --disabled-password --gecos '' $USER +RUN adduser $USER sudo +RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + +USER $USER +RUN sudo apt update + +# Install OpenJDK 17 +RUN sudo apt-get update && sudo apt-get install -y openjdk-17-jdk && sudo rm -rf /var/lib/apt/lists/* + +# Install Rust +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +ENV PATH="/home/$USER/.cargo/bin:${PATH}" + +# Verify Rust installation +RUN rustc --version && cargo --version + +# Set environment variables +ENV FLUTTER_HOME=/opt/flutter +ENV ANDROID_HOME=/opt/android-sdk +ENV PATH=$FLUTTER_HOME/bin:$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools + +# Install Flutter +RUN sudo git clone https://github.com/flutter/flutter.git $FLUTTER_HOME +RUN sudo sh -c "cd $FLUTTER_HOME && git checkout stable && ./bin/flutter --version" + + +# Set up Android SDK +RUN sudo mkdir -p ${ANDROID_HOME}/cmdline-tools && \ + sudo wget -q https://dl.google.com/android/repository/commandlinetools-linux-8092744_latest.zip -O android-cmdline-tools.zip && \ + sudo unzip -q android-cmdline-tools.zip -d ${ANDROID_HOME}/cmdline-tools && \ + sudo mv ${ANDROID_HOME}/cmdline-tools/cmdline-tools ${ANDROID_HOME}/cmdline-tools/latest && \ + sudo rm android-cmdline-tools.zip + +RUN sudo chown -R $USER /opt/flutter +RUN sudo chown -R $USER /opt/android-sdk + +RUN flutter config --android-sdk=/opt/android-sdk + +# Accept licenses and install necessary Android SDK components +RUN yes | sdkmanager --licenses +RUN sdkmanager "platform-tools" "platforms;android-34" "build-tools;34.0.0" + +# Clean up existing app directory +RUN sudo rm -rf /app + +RUN sudo mkdir /app + +RUN sudo chown -R $USER /app + +# Clone the Bull Bitcoin mobile repository +RUN git clone --branch main https://github.com/SatoshiPortal/bullbitcoin-mobile /app + +# Copy device-spec.json into the container +COPY device-spec.json /app/device-spec.json + +WORKDIR /app + +RUN flutter pub get + +# Generate a fake keystore +RUN keytool -genkey -v -keystore upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload -storepass android -keypass android -dname "CN=Android Debug,O=Android,C=US" + +# Set up key.properties +RUN echo "storePassword=android" > /app/android/key.properties && \ + echo "keyPassword=android" >> /app/android/key.properties && \ + echo "keyAlias=upload" >> /app/android/key.properties && \ + echo "storeFile=/app/upload-keystore.jks" >> /app/android/key.properties + +# Pre-build the project to download all necessary dependencies +RUN flutter precache + +# Generates freezed files +RUN dart run build_runner build --delete-conflicting-outputs + +RUN flutter build apk --release diff --git a/repro/README.md b/repro/README.md index 9363392e..a92f1a2a 100644 --- a/repro/README.md +++ b/repro/README.md @@ -1,44 +1,9 @@ -# Reproducible Builds (Work in Progress) +# Reproducible Builds -## NOTE -DOES NOT WORK ON MAC M1. -Refer to the following issues: -https://github.com/dart-lang/sdk/issues/48420 - -## Reference -As we develop the repro build process, reference https://github.com/signalapp/Signal-Android/tree/main/reproducible-builds and update this document. - -## Dev - -To inspect the container, uncomment the `CMD` line in the Dockerfile and run the following: +## Usage ```bash -docker build -t bullwallet . -docker run -itd --name bbw bullwallet -docker exec -it bbw bash -# inspect the container +docker build -t bull-mobile . +docker run --name bull-container bull-mobile +docker cp bull-container:/app/build/app/outputs/apk/release/app-release.apk ./ ``` - -## TL;DR - -```bash -git clone https://github.com/SatoshiPortal/bullbitcoin-mobile && cd bullbitcoin-mobile - -# Check out the release tag for the version you'd like to compare -git checkout v[the version number] - -# Build the Docker image -cd reproducible_builds -docker build -t bullbitcoin-mobile . - -# Go back up to the root of the project -cd .. - -# Build using the Docker environment -docker run --rm -v $(pwd):/project -w /project bullbitcoin-mobile flutter build - -# Verify the APKs -python3 apkdiff/apkdiff.py app/build/outputs/apks/project-release-unsigned.apk path/to/BullWalletFromPlay.apk -``` - -*** diff --git a/repro/device-spec.json b/repro/device-spec.json new file mode 100644 index 00000000..db01f2bd --- /dev/null +++ b/repro/device-spec.json @@ -0,0 +1,7 @@ +{ + "supportedAbis": ["armeabi-v7a", "armeabi"], + "supportedLocales": ["en"], + "screenDensity": 280, + "sdkVersion": 31 + } + \ No newline at end of file