Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(Devcontainers&Codespaces): rename mm2 to kdf #156

Merged
merged 14 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ ENV ANDROID_SDK_ROOT=$ANDROID_HOME \
PATH=${PATH}:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/emulator

# comes from https://developer.android.com/studio/#command-tools
ENV ANDROID_SDK_TOOLS_VERSION 11076708
ENV ANDROID_SDK_TOOLS_VERSION=11076708

# https://developer.android.com/studio/releases/build-tools
ENV ANDROID_PLATFORM_VERSION 34
ENV ANDROID_BUILD_TOOLS_VERSION 34.0.0
ENV ANDROID_PLATFORM_VERSION=34
ENV ANDROID_BUILD_TOOLS_VERSION=34.0.0

# https://developer.android.com/ndk/downloads
ENV ANDROID_NDK_VERSION 26.3.11579264
ENV ANDROID_NDK_VERSION=26.3.11579264

RUN apt update && apt install -y sudo && \
useradd -u $USER_ID -m $USER && \
Expand Down Expand Up @@ -112,8 +112,8 @@ RUN PATH="$HOME/.cargo/bin:$PATH" && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
export PATH="$HOME/.cargo/bin:$PATH" && \
sudo chown -R $USER:$USER $HOME/.cargo && \
rustup toolchain install nightly-2022-10-29 --no-self-update --profile=minimal &&\
rustup default nightly-2022-10-29 && \
rustup toolchain install nightly-2023-06-01 --no-self-update --profile=minimal && \
rustup default nightly-2023-06-01 && \
rustup target add aarch64-linux-android && \
rustup target add armv7-linux-androideabi && \
sudo apt install -y python3 python3-pip git curl nodejs python3-venv sudo && \
Expand Down
4 changes: 2 additions & 2 deletions .docker/dev-setup.sh → .devcontainer/dev-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export PATH="$HOME/.cargo/bin:$PATH"
export PATH=$PATH:/android-ndk/bin
CC_aarch64_linux_android=aarch64-linux-android21-clang CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android21-clang cargo rustc --target=aarch64-linux-android --lib --release --crate-type=staticlib --package mm2_bin_lib
CC_armv7_linux_androideabi=armv7a-linux-androideabi21-clang CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=armv7a-linux-androideabi21-clang cargo rustc --target=armv7-linux-androideabi --lib --release --crate-type=staticlib --package mm2_bin_lib
mv target/aarch64-linux-android/release/libmm2lib.a target/aarch64-linux-android/release/libmm2.a
mv target/armv7-linux-androideabi/release/libmm2lib.a target/armv7-linux-androideabi/release/libmm2.a
mv target/aarch64-linux-android/release/libkdflib.a target/aarch64-linux-android/release/libmm2.a
mv target/armv7-linux-androideabi/release/libkdflib.a target/armv7-linux-androideabi/release/libmm2.a

mv /kdf/target/aarch64-linux-android/release/libmm2.a /home/komodo/workspace/android/app/src/main/cpp/libs/arm64-v8a/libmm2.a
mv /kdf/target/armv7-linux-androideabi/release/libmm2.a /home/komodo/workspace/android/app/src/main/cpp/libs/armeabi-v7a/libmm2.a
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "flutter_docker",
"context": "..",
"dockerFile": "../.docker/android-dev.dockerfile",
"dockerFile": "android-dev.dockerfile",
"remoteUser": "komodo",
"postAttachCommand": "sh .docker/dev-setup.sh",
"postAttachCommand": "sh .devcontainer/dev-setup.sh",
"runArgs": [
"--privileged"
],
Expand Down
27 changes: 15 additions & 12 deletions .docker/android-apk-build.dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
FROM komodo/kdf-android:latest as build
FROM komodo/kdf-android:latest AS build

RUN cd /app && \
rustup default nightly-2022-10-29 && \
rustup default nightly-2023-06-01 && \
rustup target add aarch64-linux-android && \
rustup target add armv7-linux-androideabi && \
export PATH=$PATH:/android-ndk/bin && \
CC_aarch64_linux_android=aarch64-linux-android21-clang CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android21-clang cargo rustc --target=aarch64-linux-android --lib --release --crate-type=staticlib --package mm2_bin_lib && \
CC_armv7_linux_androideabi=armv7a-linux-androideabi21-clang CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=armv7a-linux-androideabi21-clang cargo rustc --target=armv7-linux-androideabi --lib --release --crate-type=staticlib --package mm2_bin_lib && \
mv target/aarch64-linux-android/release/libmm2lib.a target/aarch64-linux-android/release/libmm2.a &&\
mv target/armv7-linux-androideabi/release/libmm2lib.a target/armv7-linux-androideabi/release/libmm2.a
mv target/aarch64-linux-android/release/libkdflib.a target/aarch64-linux-android/release/libmm2.a && \
mv target/armv7-linux-androideabi/release/libkdflib.a target/armv7-linux-androideabi/release/libmm2.a

FROM komodo/android-sdk:34 as final
FROM komodo/android-sdk:34 AS final

ENV FLUTTER_VERSION="2.8.1"
ENV FLUTTER_HOME "/home/komodo/.flutter-sdk"
ENV FLUTTER_HOME="/home/komodo/.flutter-sdk"
ENV USER="komodo"
ENV PATH $PATH:$FLUTTER_HOME/bin
ENV PATH=$PATH:$FLUTTER_HOME/bin
ENV ANDROID_AARCH64_LIB=android/app/src/main/cpp/libs/arm64-v8a
ENV ANDROID_AARCH64_LIB_SRC=/app/target/aarch64-linux-android/release/libmm2.a
ENV ANDROID_ARMV7_LIB=android/app/src/main/cpp/libs/armeabi-v7a
ENV ANDROID_ARMV7_LIB_SRC=/app/target/armv7-linux-androideabi/release/libmm2.a

USER $USER

WORKDIR /app
COPY . .
COPY --chown=$USER:$USER . .

RUN curl -o assets/coins.json https://raw.githubusercontent.com/KomodoPlatform/coins/master/coins && \
RUN rm -f assets/coins.json && rm -f assets/coins_config.json && \
sudo rm -rf build/* && \
mkdir -p build && \
curl -o assets/coins.json https://raw.githubusercontent.com/KomodoPlatform/coins/master/coins && \
curl -o assets/coins_config.json https://raw.githubusercontent.com/KomodoPlatform/coins/master/utils/coins_config.json && \
mkdir -p android/app/src/main/cpp/libs/armeabi-v7a && \
mkdir -p android/app/src/main/cpp/libs/arm64-v8a && \
Expand All @@ -37,7 +42,5 @@ COPY --from=build --chown=$USER:$USER ${ANDROID_AARCH64_LIB_SRC} ${ANDROID_AARCH
COPY --from=build --chown=$USER:$USER ${ANDROID_ARMV7_LIB_SRC} ${ANDROID_ARMV7_LIB}

RUN flutter config --no-analytics \
&& flutter precache \
&& yes "y" | flutter doctor --android-licenses \
&& flutter doctor \
&& flutter update-packages
&& flutter doctor
45 changes: 26 additions & 19 deletions .docker/android-sdk.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ FROM docker.io/ubuntu:22.04
# Credit to Cirrus Labs for the original Dockerfile
# LABEL org.opencontainers.image.source=https://github.com/cirruslabs/docker-images-android

USER root
ENV USER="komodo"
ENV USER_ID=1000

RUN apt update && apt install -y sudo && \
useradd -u $USER_ID -m $USER && \
usermod -aG sudo $USER && \
echo "$USER ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

USER $USER

ENV ANDROID_HOME=/opt/android-sdk-linux \
LANG=en_US.UTF-8 \
Expand All @@ -14,43 +22,42 @@ ENV ANDROID_SDK_ROOT=$ANDROID_HOME \
PATH=${PATH}:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/emulator

# comes from https://developer.android.com/studio/#command-tools
ENV ANDROID_SDK_TOOLS_VERSION 11076708
ENV ANDROID_SDK_TOOLS_VERSION=11076708

# https://developer.android.com/studio/releases/build-tools
ENV ANDROID_PLATFORM_VERSION 34
ENV ANDROID_BUILD_TOOLS_VERSION 34.0.0
ENV ANDROID_PLATFORM_VERSION=34
ENV ANDROID_BUILD_TOOLS_VERSION=34.0.0

# https://developer.android.com/ndk/downloads
ENV ANDROID_NDK_VERSION 26.3.11579264
ENV ANDROID_NDK_VERSION=26.3.11579264

RUN set -o xtrace \
&& sudo chown -R $USER:$USER /opt \
&& cd /opt \
&& apt-get update \
&& apt-get install -y jq \
openjdk-17-jdk \
sudo wget zip unzip git openssh-client curl bc software-properties-common build-essential ruby-full ruby-bundler libstdc++6 libpulse0 libglu1-mesa locales lcov libsqlite3-dev --no-install-recommends \
&& sudo apt-get update \
&& sudo apt-get install -y jq openjdk-17-jdk \
wget zip unzip git openssh-client curl bc software-properties-common build-essential \
ruby-full ruby-bundler libstdc++6 libpulse0 libglu1-mesa locales lcov libsqlite3-dev --no-install-recommends \
# for x86 emulators
libxtst6 libnss3-dev libnspr4 libxss1 libatk-bridge2.0-0 libgtk-3-0 libgdk-pixbuf2.0-0 \
&& rm -rf /var/lib/apt/lists/* \
&& sh -c 'echo "en_US.UTF-8 UTF-8" > /etc/locale.gen' \
&& locale-gen \
&& update-locale LANG=en_US.UTF-8 \
&& sudo rm -rf /var/lib/apt/lists/* \
&& sh -c 'echo "en_US.UTF-8 UTF-8" | sudo tee -a /etc/locale.gen' \
&& sudo locale-gen \
&& sudo update-locale LANG=en_US.UTF-8 \
&& wget -q https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS_VERSION}_latest.zip -O android-sdk-tools.zip \
&& mkdir -p ${ANDROID_HOME}/cmdline-tools/ \
&& unzip -q android-sdk-tools.zip -d ${ANDROID_HOME}/cmdline-tools/ \
&& mv ${ANDROID_HOME}/cmdline-tools/cmdline-tools ${ANDROID_HOME}/cmdline-tools/latest \
&& chown -R root:root $ANDROID_HOME \
&& rm android-sdk-tools.zip \
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
&& yes | sdkmanager --licenses \
&& wget -O /usr/bin/android-wait-for-emulator https://raw.githubusercontent.com/travis-ci/travis-cookbooks/master/community-cookbooks/android-sdk/files/default/android-wait-for-emulator \
&& chmod +x /usr/bin/android-wait-for-emulator \
&& sdkmanager platform-tools \
&& mkdir -p /root/.android \
&& sudo mkdir -p /root/.android \
&& sudo chown -R $USER:$USER /root \
&& touch /root/.android/repositories.cfg \
&& git config --global user.email "[email protected]" \
&& git config --global user.name "Komodo Platform" \
&& yes | sdkmanager \
"platforms;android-$ANDROID_PLATFORM_VERSION" \
"build-tools;$ANDROID_BUILD_TOOLS_VERSION" \
&& yes | sdkmanager "ndk;$ANDROID_NDK_VERSION"
&& yes | sdkmanager "ndk;$ANDROID_NDK_VERSION" \
&& sudo chown -R $USER:$USER $ANDROID_HOME
24 changes: 21 additions & 3 deletions .docker/build_apk_release.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
set -e
#!/bin/bash

docker build -f .docker/kdf-android-build.dockerfile . -t komodo/kdf-android --build-arg KDF_BRANCH=main
set -eu

# Git branch of Komodo DeFi Framework to build
BRANCH=${1:-main}
# Enable screenshots (disabled by default for security, but can be useful during testing)
ALLOW_SCREENSHOTS=${2:-false}

# Build KDF libraries
docker build -f .docker/kdf-android-build.dockerfile . -t komodo/kdf-android --build-arg KDF_BRANCH=${BRANCH}
# Setup Android SDK
docker build -f .docker/android-sdk.dockerfile . -t komodo/android-sdk:34
# Prepare coins and other dependencies
docker build -f .docker/android-apk-build.dockerfile . -t komodo/komodo-wallet-mobile
docker run --rm -v ./build:/app/build komodo/komodo-wallet-mobile:latest flutter build apk --release
# Clean projects won't have a build directory, so create it if it doesn't exist
mkdir -p ./build

FLUTTER_BUILD_COMMAND="flutter pub get && flutter build apk --release"
if [ "$ALLOW_SCREENSHOTS" == "true" ]; then
FLUTTER_BUILD_COMMAND+=" --dart-define=screenshot=true"
fi

docker run --rm -v ./build:/app/build komodo/komodo-wallet-mobile:latest bash -c "$FLUTTER_BUILD_COMMAND"
14 changes: 7 additions & 7 deletions .docker/kdf-android-build.dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM docker.io/ubuntu:22.04

LABEL Author "Onur Özkan <[email protected]>"
LABEL Author="Onur Özkan <[email protected]>"
ARG KDF_BRANCH=main

RUN apt-get update -y && \
apt-get install -y --no-install-recommends \
ca-certificates \
build-essential \
build-essential \
libssl-dev \
cmake \
llvm-dev \
Expand All @@ -27,15 +27,15 @@ RUN apt-get update -y && \
curl \
wget \
gnupg \
software-properties-common \
python-is-python3 \
software-properties-common \
lsb-release \
libudev-dev \
zip unzip \
binutils && \
apt-get clean

RUN ln -s /usr/bin/python3 /bin/python &&\
curl --output llvm.sh https://apt.llvm.org/llvm.sh && \
RUN curl --output llvm.sh https://apt.llvm.org/llvm.sh && \
chmod +x llvm.sh && \
./llvm.sh 16 && \
rm ./llvm.sh && \
Expand All @@ -53,8 +53,8 @@ RUN mkdir -m 0755 -p /etc/apt/keyrings

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
export PATH="/root/.cargo/bin:$PATH" && \
rustup toolchain install nightly-2022-10-29 --no-self-update --profile=minimal &&\
rustup default nightly-2022-10-29 && \
rustup toolchain install nightly-2023-06-01 --no-self-update --profile=minimal && \
rustup default nightly-2023-06-01 && \
rustup target add aarch64-linux-android && \
rustup target add armv7-linux-androideabi && \
apt install -y python3 python3-pip git curl nodejs python3-venv sudo && \
Expand Down