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

Docker build image and devcontainer config #147

Merged
merged 35 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
40b1eb2
0.8.0 Release: Merge pull request #78 from KomodoPlatform/dev
CharlVS Oct 20, 2023
8281a1a
update rates url
smk762 Oct 30, 2023
b0eb54a
Merge pull request #91 from KomodoPlatform/dev
ca333 Dec 19, 2023
68138a3
Merge pull request #93 from KomodoPlatform/dev
ca333 Jan 16, 2024
b853544
Merge pull request #100 from KomodoPlatform/dev
ca333 Jan 24, 2024
523e7c1
Add docker image and devcontainer
takenagain Mar 10, 2024
6df3044
Merge pull request #123 from KomodoPlatform/dev
ca333 May 4, 2024
69d98b2
SSL migration (#143)
ca333 May 13, 2024
ee3d6f7
Merge branch 'master' of https://github.com/KomodoPlatform/komodo-wal…
CharlVS May 21, 2024
0bde503
Replace python script with new dart version
takenagain May 21, 2024
2e31b5a
Fix issues with new dart script as when used via CLI
takenagain May 21, 2024
4059941
Revert "Replace python script with new dart version"
takenagain May 21, 2024
a6f0fc3
Change from clone to COPY and fix permission issue
takenagain May 21, 2024
93dfbaa
Add documentation and fix build directory permission issues
takenagain May 21, 2024
1e351d0
Update devcontainer image and fix permission issues
takenagain May 21, 2024
566ba0b
Fix devcontainer ndk install error
takenagain May 21, 2024
2f258ca
Move changing ownership of android sdk folder to dockerfile
takenagain May 21, 2024
6160a98
Replace Flutter archive download with git clone of Flutter repo
takenagain May 22, 2024
505279d
Refactor to fetch Defi binaries only from GH releases (#148)
CharlVS May 22, 2024
6d2d379
Remove the hardcoded platform from the devcontainer image
takenagain May 22, 2024
d5943df
Copy over android sdk dockerfile from Cirrus CI
takenagain May 22, 2024
2622fd4
Fix bug in API fetch script
CharlVS May 22, 2024
7022813
Add script to abstract apk release build
takenagain May 22, 2024
95ce8bf
Change devcontainer to docker-compose format
takenagain May 23, 2024
08baacc
Revert "Change devcontainer to docker-compose format"
takenagain May 23, 2024
78a51a0
Add note regarding build limitations and the Python script
takenagain May 23, 2024
d86be74
Update fetch coins scripts
takenagain May 23, 2024
924bf63
Merge branch 'dev' into feature/docker-build
CharlVS May 23, 2024
77a9b69
Add komodo-defi-framework build step to apk build image
takenagain May 27, 2024
b4abb97
Fix kdf branch build argument
takenagain May 27, 2024
7cdbc98
Remove unnecessary copy
takenagain May 27, 2024
1753e65
Combine dockerfiles into `android-dev` for Github codespaces
takenagain May 31, 2024
2aa8459
Move API build to postAttach event of devcontainer
takenagain Jun 1, 2024
7212f53
Fix cargo install in devcontainer/Codespaces
takenagain Jun 3, 2024
99efab0
Set the minimum host requirements for Codespaces
takenagain Jun 4, 2024
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
17 changes: 17 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "flutter_docker",
"context": "..",
"dockerFile": "../.docker/android-dev.dockerfile",
"remoteUser": "komodo",
"postAttachCommand": "sh .docker/dev-setup.sh",
"runArgs": [
"--privileged"
],
"workspaceMount": "source=${localWorkspaceFolder},target=/home/komodo/workspace,type=bind,consistency=delegated",
"workspaceFolder": "/home/komodo/workspace",
"hostRequirements": {
"cpus": 4,
"memory": "16gb",
"storage": "32gb"
}
}
43 changes: 43 additions & 0 deletions .docker/android-apk-build.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM komodo/kdf-android:latest as build

RUN cd /app && \
rustup default nightly-2022-10-29 && \
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

FROM komodo/android-sdk:34 as final

ENV FLUTTER_VERSION="2.8.1"
ENV FLUTTER_HOME "/home/komodo/.flutter-sdk"
ENV USER="komodo"
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

WORKDIR /app
COPY . .

RUN 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 && \
git clone https://github.com/flutter/flutter.git ${FLUTTER_HOME} && \
cd ${FLUTTER_HOME} && \
git fetch && \
git checkout tags/2.8.1

COPY --from=build --chown=$USER:$USER ${ANDROID_AARCH64_LIB_SRC} ${ANDROID_AARCH64_LIB}
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
170 changes: 170 additions & 0 deletions .docker/android-dev.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
FROM docker.io/ubuntu:22.04

ARG KDF_BRANCH=main
ENV KDF_DIR=/kdf

# Libz is distributed in the android ndk, but for some unknown reason it is not
# found in the build process of some crates, so we explicit set the DEP_Z_ROOT
ENV CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=x86_64-linux-android-clang \
CARGO_TARGET_X86_64_LINUX_ANDROID_RUNNER="qemu-x86_64 -cpu qemu64,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt" \
CC_x86_64_linux_android=x86_64-linux-android-clang \
CXX_x86_64_linux_android=x86_64-linux-android-clang++ \
CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=armv7a-linux-androideabi21-clang \
CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_RUNNER=qemu-arm \
CC_armv7_linux_androideabi=armv7a-linux-androideabi21-clang \
CXX_armv7_linux_androideabi=armv7a-linux-androideabi21-clang++ \
CC_aarch64_linux_android=aarch64-linux-android21-clang \
CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android21-clang \
CC_armv7_linux_androideabi=armv7a-linux-androideabi21-clang \
CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=armv7a-linux-androideabi21-clang \
DEP_Z_INCLUDE=/android-ndk/sysroot/usr/include/ \
OPENSSL_STATIC=1 \
OPENSSL_DIR=/openssl \
OPENSSL_INCLUDE_DIR=/openssl/include \
OPENSSL_LIB_DIR=/openssl/lib \
RUST_TEST_THREADS=1 \
HOME=/home/komodo/ \
TMPDIR=/tmp/ \
ANDROID_DATA=/ \
ANDROID_DNS_MODE=local \
ANDROID_ROOT=/system

ENV FLUTTER_VERSION="2.8.1"
ENV FLUTTER_HOME "/home/komodo/.flutter-sdk"
ENV USER="komodo"
ENV USER_ID=1000
ENV PATH $PATH:$FLUTTER_HOME/bin
ENV AR=/usr/bin/llvm-ar-16
ENV CC=/usr/bin/clang-16
ENV PATH="$HOME/.cargo/bin:$PATH"
ENV PATH=$PATH:/android-ndk/bin
ENV ANDROID_HOME=/opt/android-sdk-linux \
LANG=en_US.UTF-8 \
LC_ALL=en_US.UTF-8 \
LANGUAGE=en_US:en

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

# https://developer.android.com/studio/releases/build-tools
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

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

RUN sudo apt-get update -y && \
sudo apt-get install -y --no-install-recommends \
ca-certificates \
build-essential \
libssl-dev \
cmake \
llvm-dev \
libclang-dev \
lld \
gcc \
libc6-dev \
jq \
make \
pkg-config \
git \
automake \
libtool \
m4 \
autoconf \
make \
file \
curl \
wget \
gnupg \
software-properties-common \
lsb-release \
libudev-dev \
zip unzip \
binutils && \
sudo apt-get clean

RUN sudo ln -s /usr/bin/python3 /bin/python &&\
sudo curl --output llvm.sh https://apt.llvm.org/llvm.sh && \
sudo chmod +x llvm.sh && \
sudo ./llvm.sh 16 && \
sudo rm ./llvm.sh && \
sudo ln -s /usr/bin/clang-16 /usr/bin/clang && \
PROTOC_ZIP=protoc-25.3-linux-x86_64.zip && \
sudo curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v25.3/$PROTOC_ZIP && \
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc && \
sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*' && \
sudo rm -f $PROTOC_ZIP && \
sudo mkdir $KDF_DIR && \
sudo chown -R $USER:$USER $KDF_DIR

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 target add aarch64-linux-android && \
rustup target add armv7-linux-androideabi && \
sudo apt install -y python3 python3-pip git curl nodejs python3-venv sudo && \
git clone https://github.com/KomodoPlatform/komodo-defi-framework.git $KDF_DIR && \
cd $KDF_DIR && \
git fetch --all && \
git checkout origin/$KDF_BRANCH && \
if [ "$(uname -m)" = "x86_64" ]; then \
bash ./scripts/ci/android-ndk.sh x86 23; \
elif [ "$(uname -m)" = "aarch64" ]; then \
bash ./scripts/ci/android-ndk.sh arm64 23; \
else \
echo "Unsupported architecture"; \
exit 1; \
fi

RUN set -e -o xtrace \
&& cd /opt \
&& sudo chown -R $USER:$USER /opt \
&& 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 \
&& sudo rm -rf /var/lib/apt/lists/* \
&& sudo sh -c 'echo "en_US.UTF-8 UTF-8" > /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 \
&& sudo chown -R $USER:$USER $ANDROID_HOME \
&& rm android-sdk-tools.zip \
&& yes | sdkmanager --licenses \
&& sdkmanager platform-tools \
&& 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"

RUN git clone https://github.com/flutter/flutter.git ${FLUTTER_HOME} \
&& cd ${FLUTTER_HOME} \
&& git fetch \
&& git checkout tags/2.8.1 \
&& flutter config --no-analytics \
&& flutter precache \
&& yes "y" | flutter doctor --android-licenses \
&& flutter doctor \
&& flutter update-packages
56 changes: 56 additions & 0 deletions .docker/android-sdk.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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 ANDROID_HOME=/opt/android-sdk-linux \
LANG=en_US.UTF-8 \
LC_ALL=en_US.UTF-8 \
LANGUAGE=en_US:en

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

# https://developer.android.com/studio/releases/build-tools
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

RUN set -o xtrace \
&& 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 \
# 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 \
&& 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 \
&& 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"
6 changes: 6 additions & 0 deletions .docker/build_apk_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set -e

docker build -f .docker/kdf-android-build.dockerfile . -t komodo/kdf-android --build-arg KDF_BRANCH=main
docker build -f .docker/android-sdk.dockerfile . -t komodo/android-sdk:34
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
28 changes: 28 additions & 0 deletions .docker/build_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"api": {
"release_tag": "v2.0.0-beta",
"use_latest_release": false,
"github_repository": "https://github.com/KomodoPlatform/komodo-defi-framework",
"platforms": {
"ios": {
"keywords": [
"ios",
"aarch64"
],
"path": "ios"
},
"android-armv7": {
"keywords": [
"android-armv7"
],
"path": "android/app/src/main/cpp/libs/armeabi-v7a"
},
"android-aarch64": {
"keywords": [
"android-aarch64"
],
"path": "android/app/src/main/cpp/libs/arm64-v8a"
}
}
}
}
24 changes: 24 additions & 0 deletions .docker/dev-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

set -e

sudo git config core.fileMode false
sudo chmod -R u+rwx /home/komodo/workspace
sudo chown -R komodo:komodo /home/komodo/workspace
flutter pub get

curl -o assets/coins.json https://raw.githubusercontent.com/KomodoPlatform/coins/master/coins
curl -o assets/coins_config_tcp.json https://raw.githubusercontent.com/KomodoPlatform/coins/master/utils/coins_config_tcp.json
mkdir -p android/app/src/main/cpp/libs/armeabi-v7a
mkdir -p android/app/src/main/cpp/libs/arm64-v8a

cd /kdf
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 /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
Loading