Skip to content

Commit

Permalink
Merge pull request #17 from zingolabs/upgrade_docker_build_pipeline2
Browse files Browse the repository at this point in the history
reorganized docker build pipeline for hackability
  • Loading branch information
dannasessha authored May 16, 2022
2 parents 3806acf + 361e58d commit 9b5c3f4
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 68 deletions.
57 changes: 48 additions & 9 deletions rust/android/docker/Dockerfile → rust/android/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,52 @@
FROM stunnar/rustndk:latest
FROM rust:1.60-slim-bullseye as apt_upgrade_rustndk_image

RUN apt-get update
RUN apt-get install -y curl wget gcc make automake build-essential
ARG android_ndk_ver=r23b

# Install Android NDK
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends --no-install-suggests \
ca-certificates \
make \
curl \
wget \
gcc \
make \
automake \
build-essential \
unzip \
git \
g++-aarch64-linux-gnu \
libc6-dev-arm64-cross \
&& update-ca-certificates \
# Install NDK itself
&& curl -fL -o /tmp/android-ndk.zip \
https://dl.google.com/android/repository/android-ndk-${android_ndk_ver}-linux.zip \
&& unzip /tmp/android-ndk.zip -d /usr/local/


# get latest stable toolchain
RUN rustup toolchain install stable

# Install Rust targets for Android platforms
RUN rustup target add aarch64-linux-android \
armv7-linux-androideabi \
i686-linux-android \
x86_64-linux-android


# Path to the Android NDK for cargo-ndk Cargo plugin
ENV ANDROID_NDK_HOME=/usr/local/android-ndk-${android_ndk_ver} \
NDK_HOME=/usr/local/android-ndk-${android_ndk_ver} \
ANDROID_NDK_ROOT=/usr/local/android-ndk-${android_ndk_ver}

ENV PATH=/root/.cargo/bin:/usr/local/android-ndk-${android_ndk_ver}/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH


# Install cargo-ndk Cargo plugin
RUN cargo install cargo-ndk

FROM apt_upgrade_rustndk_image as rustndk_openssl_installed_image

# RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain none -y
# ENV PATH=/root/.cargo/bin:/opt/android-ndk-linux/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
Expand Down Expand Up @@ -33,14 +78,8 @@ RUN cd /opt/openssl-3.0.1 && \

RUN rustup component add rustfmt

RUN apt-get install -y git

RUN cd /opt && git clone --depth=1 https://github.com/zecwalletco/zecwallet-mobile zecwalletmobile && cd zecwalletmobile/rust/android && cargo fetch && cargo build --release && rm -rf /opt/zecwalletmobile

RUN apt-get install --assume-yes --no-install-recommends \
g++-aarch64-linux-gnu \
libc6-dev-arm64-cross

RUN rustup target install aarch64-linux-android
RUN echo "[target.aarch64-linux-android]" >> /usr/local/cargo/config
RUN echo "ar = \"llvm-ar\"" >> /usr/local/cargo/config
Expand Down
4 changes: 2 additions & 2 deletions rust/android/buildphases/constructdockerimages.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#! /usr/bin/env bash

# build docker images
docker build --tag localrndk/rustndk:latest rustNDKDocker
docker build --tag zecwalletmobile/android:latest docker
docker build --target apt_upgrade_rustndk_image . \
&& docker build --target rustndk_openssl_installed_image --tag devlocal/rustndk_openssl_installed_image .
2 changes: 1 addition & 1 deletion rust/android/buildphases/runcargobuilds.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env bash

# build rust library for android, used nightly build to rebuild core-librarys not there at compile time
docker run --rm -v $(pwd)/..:/opt/zecwalletmobile -v $(pwd)/target/registry:/root/.cargo/registry zecwalletmobile/android:latest bash -c "
docker run --rm -v $(pwd)/..:/opt/zecwalletmobile -v $(pwd)/target/registry:/root/.cargo/registry devlocal/rustndk_openssl_installed_image:latest bash -c "
cd /opt/zecwalletmobile/android && \
AR=llvm-ar LD=ld RANLIB=llvm-ranlib CC=i686-linux-android29-clang OPENSSL_DIR=/opt/openssl-3.0.1/x86 cargo +nightly build -Z build-std --target i686-linux-android --release && llvm-strip ../target/i686-linux-android/release/librust.so && \
AR=llvm-ar LD=ld RANLIB=llvm-ranlib CC=armv7a-linux-androideabi29-clang OPENSSL_DIR=/opt/openssl-3.0.1/armv7 cargo +nightly build -Z build-std --target armv7-linux-androideabi --release && llvm-strip ../target/armv7-linux-androideabi/release/librust.so && \
Expand Down
56 changes: 0 additions & 56 deletions rust/android/rustNDKDocker/dockerfile

This file was deleted.

0 comments on commit 9b5c3f4

Please sign in to comment.