docker: simplify ci and better package release artifacts

This commit is contained in:
Dedy Martadinata S 2023-01-06 22:34:22 +07:00 committed by GitHub
parent c87adfeecc
commit 3a43b7a4c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 78 additions and 139 deletions

View File

@ -10,8 +10,8 @@ RUN mkdir -p target/
RUN mkdir -p /lldap/app RUN mkdir -p /lldap/app
RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \
mv bin/amd64-bin/lldap target/lldap && \ mv bin/amd64-lldap-bin/lldap target/lldap && \
mv bin/amd64-bin/migration-tool target/migration-tool && \ mv bin/amd64-migration-tool-bin/migration-tool target/migration-tool && \
chmod +x target/lldap && \ chmod +x target/lldap && \
chmod +x target/migration-tool && \ chmod +x target/migration-tool && \
ls -la target/ . && \ ls -la target/ . && \
@ -19,8 +19,8 @@ RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \
; fi ; fi
RUN if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ RUN if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
mv bin/aarch64-bin/lldap target/lldap && \ mv bin/aarch64-lldap-bin/lldap target/lldap && \
mv bin/aarch64-bin/migration-tool target/migration-tool && \ mv bin/aarch64-migration-tool-bin/migration-tool target/migration-tool && \
chmod +x target/lldap && \ chmod +x target/lldap && \
chmod +x target/migration-tool && \ chmod +x target/migration-tool && \
ls -la target/ . && \ ls -la target/ . && \
@ -28,8 +28,8 @@ RUN if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
; fi ; fi
RUN if [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then \ RUN if [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then \
mv bin/armhf-bin/lldap target/lldap && \ mv bin/armhf-lldap-bin/lldap target/lldap && \
mv bin/armhf-bin/migration-tool target/migration-tool && \ mv bin/armhf-migration-tool-bin/migration-tool target/migration-tool && \
chmod +x target/lldap && \ chmod +x target/lldap && \
chmod +x target/migration-tool && \ chmod +x target/migration-tool && \
ls -la target/ . && \ ls -la target/ . && \

View File

@ -10,8 +10,8 @@ RUN mkdir -p target/
RUN mkdir -p /lldap/app RUN mkdir -p /lldap/app
RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \
mv bin/amd64-bin/lldap target/lldap && \ mv bin/amd64-lldap-bin/lldap target/lldap && \
mv bin/amd64-bin/migration-tool target/migration-tool && \ mv bin/amd64-migration-tool-bin/migration-tool target/migration-tool && \
chmod +x target/lldap && \ chmod +x target/lldap && \
chmod +x target/migration-tool && \ chmod +x target/migration-tool && \
ls -la target/ . && \ ls -la target/ . && \
@ -19,8 +19,8 @@ RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \
; fi ; fi
RUN if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ RUN if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
mv bin/aarch64-bin/lldap target/lldap && \ mv bin/aarch64-lldap-bin/lldap target/lldap && \
mv bin/aarch64-bin/migration-tool target/migration-tool && \ mv bin/aarch64-migration-tool-bin/migration-tool target/migration-tool && \
chmod +x target/lldap && \ chmod +x target/lldap && \
chmod +x target/migration-tool && \ chmod +x target/migration-tool && \
ls -la target/ . && \ ls -la target/ . && \
@ -28,8 +28,8 @@ RUN if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
; fi ; fi
RUN if [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then \ RUN if [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then \
mv bin/armhf-bin/lldap target/lldap && \ mv bin/armhf-lldap-bin/lldap target/lldap && \
mv bin/armhf-bin/migration-tool target/migration-tool && \ mv bin/armhf-migration-tool-bin/migration-tool target/migration-tool && \
chmod +x target/lldap && \ chmod +x target/lldap && \
chmod +x target/migration-tool && \ chmod +x target/migration-tool && \
ls -la target/ . && \ ls -la target/ . && \

View File

@ -22,16 +22,19 @@ env:
# In total 5 jobs, all the jobs are containerized # In total 5 jobs, all the jobs are containerized
# --- # ---
#######################################################################################
# GitHub actions randomly timeout when downloading musl-gcc #
# Using lldap dev image based on https://hub.docker.com/_/rust and musl-gcc bundled #
# Look into .github/workflows/Dockerfile.dev for development image details #
#######################################################################################
# build-ui , create/compile the web # build-ui , create/compile the web
## Use rustlang/rust:nighlty image
### Install nodejs from nodesource repo
### install wasm ### install wasm
### install rollup ### install rollup
### run app/build.sh ### run app/build.sh
### upload artifacts ### upload artifacts
# builds-armhf, build-aarch64, build-amd64 create binary for respective arch # builds-armhf, build-aarch64, build-amd64 create binary for respective arch
## Use rustlang/rust:nightly image
### Add non-native architecture dpkg --add-architecture XXX ### Add non-native architecture dpkg --add-architecture XXX
### Install dev tool gcc g++, etc. per respective arch ### Install dev tool gcc g++, etc. per respective arch
### Cargo build ### Cargo build
@ -44,30 +47,16 @@ env:
# build-ui,builds-armhf, build-aarch64, build-amd64 will upload artifacts will be used next job # build-ui,builds-armhf, build-aarch64, build-amd64 will upload artifacts will be used next job
# build-docker-image job will fetch artifacts and run Dockerfile.ci then push the image. # build-docker-image job will fetch artifacts and run Dockerfile.ci then push the image.
# On current https://hub.docker.com/_/rust # cache based on Cargo.lock
# 1-bullseye, 1.61-bullseye, 1.61.0-bullseye, bullseye, 1, 1.61, 1.61.0, latest
# cache
## cargo
## target
jobs: jobs:
build-ui: build-ui:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: rust:1.65 image: nitnelave/rust-dev:latest
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -Ctarget-feature=+crt-static
steps: steps:
- name: install runtime - name: Checkout repository
run: apt update && apt install -y gcc-x86-64-linux-gnu g++-x86-64-linux-gnu libc6-dev ca-certificates uses: actions/checkout@v3.3.0
- name: setup node repo LTS
run: curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
- name: install nodejs
run: apt install -y nodejs && npm -g install npm
- name: smoke test
run: rustc --version
- uses: actions/cache@v3 - uses: actions/cache@v3
with: with:
path: | path: |
@ -79,10 +68,10 @@ jobs:
key: lldap-ui-${{ hashFiles('**/Cargo.lock') }} key: lldap-ui-${{ hashFiles('**/Cargo.lock') }}
restore-keys: | restore-keys: |
lldap-ui- lldap-ui-
- name: Checkout repository
uses: actions/checkout@v3.3.0
- name: install rollup nodejs - name: install rollup nodejs
run: npm install -g rollup run: npm install -g rollup
- name: add wasm target
run: rustup target add wasm32-unknown-unknown
- name: install wasm-pack with cargo - name: install wasm-pack with cargo
run: cargo install wasm-pack || true run: cargo install wasm-pack || true
env: env:
@ -100,7 +89,7 @@ jobs:
build-armhf: build-armhf:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: rust:1.65 image: nitnelave/rust-dev:latest
env: env:
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_LINKER: arm-linux-gnueabihf-ld CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_LINKER: arm-linux-gnueabihf-ld
@ -112,12 +101,8 @@ jobs:
run: dpkg --add-architecture armhf run: dpkg --add-architecture armhf
- name: install runtime - name: install runtime
run: apt update && apt install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libc6-armhf-cross libc6-dev-armhf-cross tar ca-certificates run: apt update && apt install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libc6-armhf-cross libc6-dev-armhf-cross tar ca-certificates
- name: smoke test
run: rustc --version
- name: add armhf target - name: add armhf target
run: rustup target add armv7-unknown-linux-gnueabihf run: rustup target add armv7-unknown-linux-gnueabihf
- name: smoke test
run: rustc --version
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3.3.0 uses: actions/checkout@v3.3.0
- uses: actions/cache@v3 - uses: actions/cache@v3
@ -150,12 +135,6 @@ jobs:
build-aarch64: build-aarch64:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
##################################################################################
# GitHub actions currently timeout when downloading musl-gcc #
# Using lldap dev image based on rust:1.65-slim-bullseye and musl-gcc bundled #
# Only for Job build aarch64 and amd64 #
###################################################################################
#image: rust:1.65
image: nitnelave/rust-dev:latest image: nitnelave/rust-dev:latest
env: env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-musl-gcc CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-musl-gcc
@ -163,10 +142,6 @@ jobs:
RUSTFLAGS: -Ctarget-feature=+crt-static RUSTFLAGS: -Ctarget-feature=+crt-static
CARGO_HOME: ${GITHUB_WORKSPACE}/.cargo CARGO_HOME: ${GITHUB_WORKSPACE}/.cargo
steps: steps:
- name: Checkout repository
uses: actions/checkout@v3.3.0
- name: smoke test
run: rustc --version
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3.3.0 uses: actions/checkout@v3.3.0
- uses: actions/cache@v3 - uses: actions/cache@v3
@ -205,7 +180,6 @@ jobs:
build-amd64: build-amd64:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
# image: rust:1.65
image: nitnelave/rust-dev:latest image: nitnelave/rust-dev:latest
env: env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
@ -263,42 +237,10 @@ jobs:
run: sudo apt update && sudo apt install -y rsync run: sudo apt update && sudo apt install -y rsync
- name: fetch repo - name: fetch repo
uses: actions/checkout@v3.3.0 uses: actions/checkout@v3.3.0
- name: Download All Artifacts
- name: Download armhf lldap artifacts
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: armhf-lldap-bin path: bin
path: bin/armhf-bin
- name: Download armhf migration-tool artifacts
uses: actions/download-artifact@v3
with:
name: armhf-migration-tool-bin
path: bin/armhf-bin
- name: Download aarch64 lldap artifacts
uses: actions/download-artifact@v3
with:
name: aarch64-lldap-bin
path: bin/aarch64-bin
- name: Download aarch64 migration-tool artifacts
uses: actions/download-artifact@v3
with:
name: aarch64-migration-tool-bin
path: bin/aarch64-bin
- name: Download amd64 lldap artifacts
uses: actions/download-artifact@v3
with:
name: amd64-lldap-bin
path: bin/amd64-bin
- name: Download amd64 migration-tool artifacts
uses: actions/download-artifact@v3
with:
name: amd64-migration-tool-bin
path: bin/amd64-bin
- name: check bin path
run: ls -al bin/
- name: Download llap ui artifacts - name: Download llap ui artifacts
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
@ -326,7 +268,7 @@ jobs:
type=semver,pattern={{major}} type=semver,pattern={{major}}
type=sha type=sha
- name: Cache Docker layers - name: Cache Docker layers
uses: actions/cache@v2 uses: actions/cache@v3
with: with:
path: /tmp/.buildx-cache path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }} key: ${{ runner.os }}-buildx-${{ github.sha }}
@ -344,9 +286,9 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
###################### ########################################
#### latest build #### #### docker image :latest tag build ####
###################### ########################################
- name: Build and push latest alpine - name: Build and push latest alpine
if: github.event_name != 'release' if: github.event_name != 'release'
uses: docker/build-push-action@v3 uses: docker/build-push-action@v3
@ -371,9 +313,9 @@ jobs:
cache-from: type=local,src=/tmp/.buildx-cache cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new cache-to: type=local,dest=/tmp/.buildx-cache-new
####################### ########################################
#### release build #### #### docker image :semver tag build ####
####################### ########################################
- name: Build and push release alpine - name: Build and push release alpine
if: github.event_name == 'release' if: github.event_name == 'release'
uses: docker/build-push-action@v3 uses: docker/build-push-action@v3
@ -411,52 +353,31 @@ jobs:
password: ${{ secrets.DOCKERHUB_PASSWORD }} password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: nitnelave/lldap repository: nitnelave/lldap
###############################################################
### Download artifacts, clean up ui, upload to release page ###
###############################################################
create-release-artifacts: create-release-artifacts:
needs: [build-ui,build-armhf,build-aarch64,build-amd64] needs: [build-ui,build-armhf,build-aarch64,build-amd64]
name: Create release artifacts name: Create release artifacts
if: github.event_name == 'release' if: github.event_name == 'release'
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Download All Artifacts
- name: Download armhf lldap artifacts
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: armhf-lldap-bin path: bin/
path: bin/armhf-bin - name: Check file
- name: Download armhf migration-tool artifacts run: ls -alR bin/
uses: actions/download-artifact@v3 - name: Fixing Filename
with: run: |
name: armhf-migration-tool-bin mv bin/aarch64-lldap-bin/lldap bin/aarch64-lldap
path: bin/armhf-bin mv bin/amd64-lldap-bin/lldap bin/amd64-lldap
- name: Fix binary name armhf mv bin/armhf-lldap-bin/lldap bin/armhf-lldap
run: mv bin/armhf-bin/lldap bin/armhf-bin/lldap-armhf && mv bin/armhf-bin/migration-tool bin/armhf-bin/migration-tool-armhf mv bin/aarch64-migration-tool-bin/migration-tool bin/aarch64-migration-tool
mv bin/amd64-migration-tool-bin/migration-tool bin/amd64-migration-tool
- name: Download aarch64 lldap artifacts mv bin/armhf-migration-tool-bin/migration-tool bin/armhf-migration-tool
uses: actions/download-artifact@v3 chmod +x bin/*-lldap
with: chmod +x bin/*-migration-tool
name: aarch64-lldap-bin
path: bin/aarch64-bin
- name: Download aarch64 migration-tool artifacts
uses: actions/download-artifact@v3
with:
name: aarch64-migration-tool-bin
path: bin/aarch64-bin
- name: Fix binary name aarch64
run: mv bin/aarch64-bin/lldap bin/aarch64-bin/lldap-aarch64 && mv bin/aarch64-bin/migration-tool bin/aarch64-bin/migration-tool-aarch64
- name: Download amd64 lldap artifacts
uses: actions/download-artifact@v3
with:
name: amd64-lldap-bin
path: bin/amd64-bin
- name: Download amd64 migration-tool artifacts
uses: actions/download-artifact@v3
with:
name: amd64-migration-tool-bin
path: bin/amd64-bin
- name: Fix binary name amd64
run: mv bin/amd64-bin/lldap bin/amd64-bin/lldap-amd64 && mv bin/amd64-bin/migration-tool bin/amd64-bin/migration-tool-amd64
- name: Download llap ui artifacts - name: Download llap ui artifacts
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
@ -472,8 +393,30 @@ jobs:
for file in $(cat app/static/libraries.txt); do wget -P app/static "$file"; done for file in $(cat app/static/libraries.txt); do wget -P app/static "$file"; done
for file in $(cat app/static/fonts/fonts.txt); do wget -P app/static/fonts "$file"; done for file in $(cat app/static/fonts/fonts.txt); do wget -P app/static/fonts "$file"; done
chmod a+r -R . chmod a+r -R .
- name: compress web
run: sudo apt update && sudo apt install -y zip && zip -r web.zip app/ - name: Setup LLDAP dir for packing
run: |
mkdir aarch64-lldap
mkdir amd64-lldap
mkdir armhf-lldap
mv bin/aarch64-lldap aarch64-lldap/lldap
mv bin/amd64-lldap amd64-lldap/lldap
mv bin/armhf-lldap armhf-lldap/lldap
mv bin/aarch64-migration-tool aarch64-lldap/migration-tool
mv bin/amd64-migration-tool amd64-lldap/migration-tool
mv bin/armhf-migration-tool armhf-lldap/migration-tool
cp -r app aarch64-lldap/
cp -r app amd64-lldap/
cp -r app armhf-lldap/
ls -alR aarch64-lldap/
ls -alR amd64-lldap/
ls -alR armhf-lldap/
- name: Compress
run: |
tar -czvf aarch64-lldap.tar.gz aarch64-lldap/
tar -czvf amd64-lldap.tar.gz amd64-lldap/
tar -czvf armhf-lldap.tar.gz armhf-lldap/
- name: Upload artifacts release - name: Upload artifacts release
@ -481,12 +424,8 @@ jobs:
id: create_release id: create_release
with: with:
allowUpdates: true allowUpdates: true
artifacts: bin/armhf-bin/lldap-armhf, artifacts: aarch64-lldap.tar.gz,
bin/aarch64-bin/lldap-aarch64, amd64-lldap.tar.gz,
bin/amd64-bin/lldap-amd64, armhf-lldap.tar.gz
bin/armhf-bin/migration-tool-armhf,
bin/aarch64-bin/migration-tool-aarch64,
bin/amd64-bin/migration-tool-amd64,
web.zip
env: env:
GITHUB_TOKEN: ${{ github.token }} GITHUB_TOKEN: ${{ github.token }}