Update Docker Builder

This commit is contained in:
Hanh 2022-05-20 23:40:43 +08:00
parent 46fa3462f5
commit 5b2cedb885
5 changed files with 80 additions and 52 deletions

View File

@ -1,34 +1,30 @@
# This is a basic workflow to help you get started with Actions
name: Builder
name: CI Build Image to Docker Hub
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ docker ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
@ -38,9 +34,16 @@ jobs:
uses: docker/build-push-action@v2
with:
context: ./
file: ./docker/Dockerfile-builder
file: docker/Dockerfile-builder
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/zwallet_builder:latest
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/builder_zwallet:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

View File

@ -1,5 +1,14 @@
FROM archlinux:base-devel-20220227.0.49015 AS builder
#syntax=docker/dockerfile:1.2
FROM archlinux:base-devel-20220227.0.49015 AS builder_rust
COPY install-rust.sh .
RUN ./install-rust.sh
FROM builder_rust as builder_flutter
COPY install-deps.sh .
RUN --mount=type=cache,target=/tmp ./install-deps.sh
RUN ./install-deps.sh
ENV ANDROID_SDK_ROOT /root/Android/sdk
ENV ANDROID_NDK_HOME $ANDROID_SDK_ROOT/android-ndk-r21e
ENV PATH $PATH:$ANDROID_SDK_ROOT/platform-tools:/root/flutter/bin

View File

@ -1,21 +1,30 @@
#syntax=docker/dockerfile:1.2
FROM archlinux:base-devel-20220227.0.49015 AS builder
##syntax=docker/dockerfile:1.2
#FROM archlinux:base-devel-20220227.0.49015 AS builder_rust
#
#COPY install-rust.sh .
#RUN ./install-rust.sh
#
#FROM builder_rust as builder_flutter
#
#COPY install-deps.sh .
#RUN --mount=type=cache,target=/tmp ./install-deps.sh
#
#ENV ANDROID_SDK_ROOT /root/Android/sdk
#ENV PATH $PATH:$ANDROID_SDK_ROOT/platform-tools:/root/flutter/bin
#ENV ANDROID_NDK_HOME $ANDROID_SDK_ROOT/ndk/21.4.7075529
COPY install-deps.sh .
# FROM builder_flutter as builder_zwallet
FROM hhanh00/builder_zwallet as builder
RUN ./install-deps.sh
FROM builder as builder2
ENV ANDROID_SDK_ROOT /Android/sdk
ENV PATH $PATH:$ANDROID_SDK_ROOT/platform-tools:/flutter/bin
ENV ANDROID_NDK_HOME $ANDROID_SDK_ROOT/ndk/21.4.7075529
ENV ANDROID_SDK_ROOT /root/Android/sdk
ENV ANDROID_NDK_HOME $ANDROID_SDK_ROOT/android-ndk-r21e
ENV PATH $PATH:$ANDROID_SDK_ROOT/platform-tools:/root/flutter/bin
COPY . /zwallet
RUN git config --global --add safe.directory /flutter
RUN git config --global --add safe.directory /root/flutter
RUN --mount=type=secret,id=pwd cd /zwallet && ./configure.sh zcash && ./build.sh
FROM alpine:latest
WORKDIR /root
COPY --from=builder2 /zwallet/build/app/outputs/bundle/release/* ./
COPY --from=builder /zwallet/build/app/outputs/bundle/release/* ./

View File

@ -1,31 +1,32 @@
#!/bin/sh
ROOT_DIR=$1
if [ "$ROOT_DIR" == "" ]; then
ROOT_DIR="/root"
fi
pacman -Sy --noconfirm unzip jdk8-openjdk wget
wget -P /tmp -N https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip
wget -P /tmp -N https://dl.google.com/android/repository/android-ndk-r21e-linux-x86_64.zip
wget -P /tmp -N https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.0.1-stable.tar.xz
wget -P /tmp -N https://download.z.cash/downloads/sapling-output.params
wget -P /tmp -N https://download.z.cash/downloads/sapling-spend.params
mkdir -p $ROOT_DIR/Android/sdk
export ANDROID_SDK_ROOT=$ROOT_DIR/Android/sdk
pacman -Sy --noconfirm unzip jdk8-openjdk git cmake
curl -o sdk-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip
unzip sdk-tools.zip
(cd cmdline-tools/bin &&
(cd $ROOT_DIR;unzip -o /tmp/commandlinetools-linux-7583922_latest.zip;
cd cmdline-tools/bin &&
yes | ./sdkmanager --sdk_root=$ANDROID_SDK_ROOT --licenses &&
yes | ./sdkmanager --sdk_root=$ANDROID_SDK_ROOT "platform-tools" "platforms;android-31" &&
yes | ./sdkmanager --sdk_root=$ANDROID_SDK_ROOT "ndk;21.4.7075529")
rm sdk-tools.zip
yes | ./sdkmanager --sdk_root=$ANDROID_SDK_ROOT "platform-tools" "platforms;android-31")
pacman -Sy --noconfirm rustup
rustup install stable
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
cargo install --force cargo-make
(cd $ANDROID_SDK_ROOT;unzip -o /tmp/android-ndk-r21e-linux-x86_64.zip)
(cd $ROOT_DIR;tar xvf /tmp/flutter_linux_3.0.1-stable.tar.xz)
curl -o flutter.tar.xz https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.0.0-stable.tar.xz
tar xvf flutter.tar.xz
rm -f flutter.tar.xz
mkdir -p $HOME/.zcash-params
cp /tmp/sapling-output.params /tmp/sapling-spend.params $HOME/.zcash-params
mkdir $HOME/.zcash-params
curl https://download.z.cash/downloads/sapling-output.params -o $HOME/.zcash-params/sapling-output.params
curl https://download.z.cash/downloads/sapling-spend.params -o $HOME/.zcash-params/sapling-spend.params
export ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/21.4.7075529
export PATH=$PATH:/flutter/bin
export ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/android-ndk-r21e
export PATH=$PATH:$ROOT_DIR/flutter/bin

6
install-rust.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
pacman -Sy --noconfirm git cmake rustup
rustup install stable
rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android
cargo install --force cargo-make cargo-ndk