2022-06-30 09:21:14 +00:00
|
|
|
name: Docker
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- 'main'
|
|
|
|
release:
|
|
|
|
types:
|
|
|
|
- 'published'
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- 'main'
|
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
msg:
|
|
|
|
description: "Set message"
|
|
|
|
default: "Manual trigger"
|
|
|
|
|
|
|
|
env:
|
|
|
|
CARGO_TERM_COLOR: always
|
2022-07-01 19:53:50 +00:00
|
|
|
RUSTC_WRAPPER: sccache
|
|
|
|
SCCACHE_DIR: $GITHUB_WORKSPACE/.sccache
|
|
|
|
SCCACHE_VERSION: v0.3.0
|
|
|
|
LINK: https://github.com/mozilla/sccache/releases/download
|
2022-06-30 09:21:14 +00:00
|
|
|
|
|
|
|
# In total 5 jobs, all of the jobs are containerized
|
|
|
|
# ---
|
|
|
|
|
|
|
|
# build-ui , create/compile the web
|
|
|
|
## Use rustlang/rust:nighlty image
|
|
|
|
### Install nodejs from nodesource repo
|
|
|
|
### install wasm
|
|
|
|
### install rollup
|
|
|
|
### run app/build.sh
|
|
|
|
### upload artifacts
|
|
|
|
|
|
|
|
# builds-armhf, build-aarch64, build-amd64 create binary for respective arch
|
|
|
|
## Use rustlang/rust:nightly image
|
|
|
|
### Add non native architecture dpkg --add-architecture XXX
|
|
|
|
### Install dev tool gcc g++, etc per respective arch
|
|
|
|
### Cargo build
|
|
|
|
### Upload artifacts
|
|
|
|
|
|
|
|
## the CARGO_ env
|
|
|
|
#CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc
|
|
|
|
#OPENSSL_INCLUDE_DIR: "/usr/include/openssl/"
|
|
|
|
#OPENSSL_LIB_DIR: "/usr/lib/arm-linux-gnueabihf/"
|
|
|
|
# This will determine which architecture lib will be used.
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
# On current https://hub.docker.com/_/rust
|
|
|
|
# 1-bullseye, 1.61-bullseye, 1.61.0-bullseye, bullseye, 1, 1.61, 1.61.0, latest
|
|
|
|
|
2022-07-01 19:53:50 +00:00
|
|
|
# cache
|
|
|
|
## .sccache
|
|
|
|
## cargo
|
|
|
|
## target
|
|
|
|
|
2022-06-30 09:21:14 +00:00
|
|
|
jobs:
|
|
|
|
build-ui:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
container:
|
|
|
|
image: rust:1.61
|
|
|
|
env:
|
|
|
|
CARGO_TERM_COLOR: always
|
|
|
|
RUSTFLAGS: -Ctarget-feature=-crt-static
|
|
|
|
steps:
|
|
|
|
- name: install runtime
|
|
|
|
run: apt update && apt install -y gcc-x86-64-linux-gnu g++-x86-64-linux-gnu libc6-dev libssl-dev
|
|
|
|
- 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
|
2022-07-01 19:53:50 +00:00
|
|
|
- name: Install sccache (ubuntu-latest)
|
|
|
|
run: |
|
|
|
|
SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl
|
|
|
|
mkdir -p $HOME/.local/bin
|
|
|
|
curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz
|
|
|
|
mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache
|
|
|
|
chmod +x $HOME/.local/bin/sccache
|
|
|
|
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
|
|
|
- uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
.sccache
|
|
|
|
/usr/local/cargo
|
|
|
|
target
|
|
|
|
key: lldap-ui-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
lldap-ui-
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v2
|
2022-06-30 09:21:14 +00:00
|
|
|
- name: install cargo wasm
|
|
|
|
run: cargo install wasm-pack
|
|
|
|
- name: install rollup nodejs
|
|
|
|
run: npm install -g rollup
|
|
|
|
- name: build frontend
|
|
|
|
run: ./app/build.sh
|
|
|
|
- name: check path
|
|
|
|
run: ls -al app/
|
|
|
|
- name: upload ui artifacts
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: ui
|
|
|
|
path: app/
|
|
|
|
|
|
|
|
build-armhf:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
container:
|
|
|
|
image: rust:1.61
|
|
|
|
env:
|
|
|
|
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc
|
|
|
|
OPENSSL_INCLUDE_DIR: "/usr/include/openssl/"
|
|
|
|
OPENSSL_LIB_DIR: "/usr/lib/arm-linux-gnueabihf/"
|
|
|
|
CARGO_TERM_COLOR: always
|
|
|
|
RUSTFLAGS: -Ctarget-feature=-crt-static
|
|
|
|
steps:
|
|
|
|
- name: add armhf architecture
|
|
|
|
run: dpkg --add-architecture armhf
|
|
|
|
- name: install runtime
|
2022-07-01 19:53:50 +00:00
|
|
|
run: apt update && apt install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libc6-armhf-cross libc6-dev-armhf-cross libssl-dev:armhf tar
|
2022-06-30 09:21:14 +00:00
|
|
|
- name: smoke test
|
|
|
|
run: rustc --version
|
|
|
|
- name: add armhf target
|
|
|
|
run: rustup target add armv7-unknown-linux-gnueabihf
|
|
|
|
- name: smoke test
|
|
|
|
run: rustc --version
|
2022-07-01 19:53:50 +00:00
|
|
|
- name: Install sccache (ubuntu-latest)
|
|
|
|
run: |
|
|
|
|
SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl
|
|
|
|
mkdir -p $HOME/.local/bin
|
|
|
|
curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz
|
|
|
|
mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache
|
|
|
|
chmod +x $HOME/.local/bin/sccache
|
|
|
|
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
2022-06-30 09:21:14 +00:00
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v2
|
2022-07-01 19:53:50 +00:00
|
|
|
- uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
.sccache
|
|
|
|
/usr/local/cargo
|
|
|
|
target
|
|
|
|
key: lldap-bin-armhf-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
lldap-bin-armhf-
|
2022-06-30 09:21:14 +00:00
|
|
|
- name: compile armhf
|
|
|
|
run: cargo build --target=armv7-unknown-linux-gnueabihf --release -p lldap -p migration-tool
|
|
|
|
- name: check path
|
|
|
|
run: ls -al target/release
|
2022-07-01 19:53:50 +00:00
|
|
|
- name: upload armhf lldap artifacts
|
2022-06-30 09:21:14 +00:00
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: armhf-lldap-bin
|
|
|
|
path: target/armv7-unknown-linux-gnueabihf/release/lldap
|
2022-07-01 19:53:50 +00:00
|
|
|
- name: upload armhfmigration-tool artifacts
|
2022-06-30 09:21:14 +00:00
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: armhf-migration-tool-bin
|
|
|
|
path: target/armv7-unknown-linux-gnueabihf/release/migration-tool
|
|
|
|
|
|
|
|
|
|
|
|
build-aarch64:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
container:
|
|
|
|
image: rust:1.61
|
|
|
|
env:
|
|
|
|
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
|
|
|
|
OPENSSL_INCLUDE_DIR: "/usr/include/openssl/"
|
|
|
|
OPENSSL_LIB_DIR: "/usr/lib/aarch64-linux-gnu/"
|
|
|
|
CARGO_TERM_COLOR: always
|
|
|
|
RUSTFLAGS: -Ctarget-feature=-crt-static
|
|
|
|
steps:
|
|
|
|
- name: add arm64 architecture
|
|
|
|
run: dpkg --add-architecture arm64
|
|
|
|
- name: install runtime
|
2022-07-01 19:53:50 +00:00
|
|
|
run: apt update && apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-arm64-cross libc6-dev-arm64-cross libssl-dev:arm64 tar
|
2022-06-30 09:21:14 +00:00
|
|
|
- name: smoke test
|
|
|
|
run: rustc --version
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
- name: add arm64 target
|
|
|
|
run: rustup target add aarch64-unknown-linux-gnu
|
|
|
|
- name: smoke test
|
|
|
|
run: rustc --version
|
2022-07-01 19:53:50 +00:00
|
|
|
- name: Install sccache (ubuntu-latest)
|
|
|
|
run: |
|
|
|
|
SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl
|
|
|
|
mkdir -p $HOME/.local/bin
|
|
|
|
curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz
|
|
|
|
mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache
|
|
|
|
chmod +x $HOME/.local/bin/sccache
|
|
|
|
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
2022-06-30 09:21:14 +00:00
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v2
|
2022-07-01 19:53:50 +00:00
|
|
|
- uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
.sccache
|
|
|
|
/usr/local/cargo
|
|
|
|
target
|
|
|
|
key: lldap-bin-aarch64-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
lldap-bin-aarch64-
|
2022-06-30 09:21:14 +00:00
|
|
|
- name: compile aarch64
|
|
|
|
run: cargo build --target=aarch64-unknown-linux-gnu --release -p lldap -p migration-tool
|
|
|
|
- name: check path
|
|
|
|
run: ls -al target/aarch64-unknown-linux-gnu/release/
|
2022-07-01 19:53:50 +00:00
|
|
|
- name: upload aarch64 lldap artifacts
|
2022-06-30 09:21:14 +00:00
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: aarch64-lldap-bin
|
|
|
|
path: target/aarch64-unknown-linux-gnu/release/lldap
|
2022-07-01 19:53:50 +00:00
|
|
|
- name: upload aarch64 migration-tool artifacts
|
2022-06-30 09:21:14 +00:00
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: aarch64-migration-tool-bin
|
|
|
|
path: target/aarch64-unknown-linux-gnu/release/migration-tool
|
|
|
|
|
|
|
|
build-amd64:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
container:
|
|
|
|
image: rust:1.61
|
|
|
|
env:
|
|
|
|
CARGO_TERM_COLOR: always
|
|
|
|
RUSTFLAGS: -Ctarget-feature=-crt-static
|
|
|
|
steps:
|
|
|
|
- name: install runtime
|
2022-07-01 19:53:50 +00:00
|
|
|
run: apt update && apt install -y gcc-x86-64-linux-gnu g++-x86-64-linux-gnu libc6-dev libssl-dev tar
|
2022-06-30 09:21:14 +00:00
|
|
|
- name: smoke test
|
|
|
|
run: rustc --version
|
2022-07-01 19:53:50 +00:00
|
|
|
- name: Install sccache (ubuntu-latest)
|
|
|
|
run: |
|
|
|
|
SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl
|
|
|
|
mkdir -p $HOME/.local/bin
|
|
|
|
curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz
|
|
|
|
mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache
|
|
|
|
chmod +x $HOME/.local/bin/sccache
|
|
|
|
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
2022-06-30 09:21:14 +00:00
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v2
|
2022-07-01 19:53:50 +00:00
|
|
|
- name: cargo & sscache cache
|
|
|
|
uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
.sccache
|
|
|
|
/usr/local/cargo
|
|
|
|
target
|
|
|
|
key: lldap-bin-amd64-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
lldap-bin-amd64-
|
|
|
|
#- name: add cargo chef
|
|
|
|
# run: cargo install cargo-chef
|
|
|
|
#- name: chef prepare
|
|
|
|
# run: cargo chef prepare --recipe-path recipe.json
|
|
|
|
#- name: cook?
|
|
|
|
# run: cargo chef cook --release --recipe-path recipe.json
|
2022-06-30 09:21:14 +00:00
|
|
|
- name: compile amd64
|
|
|
|
run: cargo build --target=x86_64-unknown-linux-gnu --release -p lldap -p migration-tool
|
|
|
|
- name: check path
|
|
|
|
run: ls -al target/x86_64-unknown-linux-gnu/release/
|
|
|
|
- name: upload amd64 lldap artifacts
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: amd64-lldap-bin
|
|
|
|
path: target/x86_64-unknown-linux-gnu/release/lldap
|
|
|
|
- name: upload amd64 migration-tool artifacts
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: amd64-migration-tool-bin
|
|
|
|
path: target/x86_64-unknown-linux-gnu/release/migration-tool
|
|
|
|
|
|
|
|
|
|
|
|
build-docker-image:
|
|
|
|
needs: [build-ui,build-armhf,build-aarch64,build-amd64]
|
|
|
|
name: Build Docker image
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
packages: write
|
|
|
|
steps:
|
|
|
|
- name: fetch repo
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Download armhf lldap artifacts
|
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: armhf-lldap-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
|
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: ui
|
|
|
|
path: web
|
|
|
|
|
|
|
|
- name: setup qemu
|
2022-07-01 06:03:53 +00:00
|
|
|
uses: docker/setup-qemu-action@v2
|
2022-06-30 09:21:14 +00:00
|
|
|
- uses: docker/setup-buildx-action@v2
|
|
|
|
|
|
|
|
- name: Docker meta
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v4
|
|
|
|
with:
|
|
|
|
# list of Docker images to use as base name for tags
|
|
|
|
images: |
|
|
|
|
nitnelave/lldap
|
|
|
|
# generate Docker tags based on the following events/attributes
|
|
|
|
tags: |
|
|
|
|
type=ref,event=branch
|
|
|
|
type=ref,event=pr
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
|
|
type=semver,pattern={{major}}
|
|
|
|
type=sha
|
2022-07-01 19:53:50 +00:00
|
|
|
- name: Cache Docker layers
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache
|
|
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-buildx-
|
|
|
|
|
2022-06-30 09:21:14 +00:00
|
|
|
- name: parse tag
|
|
|
|
uses: gacts/github-slug@v1
|
|
|
|
id: slug
|
|
|
|
|
|
|
|
- name: Login to Docker Hub
|
|
|
|
if: github.event_name != 'pull_request'
|
2022-06-30 20:26:07 +00:00
|
|
|
uses: docker/login-action@v2
|
2022-06-30 09:21:14 +00:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
|
2022-06-30 17:31:31 +00:00
|
|
|
- name: Build and push latest
|
|
|
|
if: github.event_name != 'release'
|
|
|
|
uses: docker/build-push-action@v3
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
|
|
|
file: ./.github/workflows/Dockerfile.ci
|
|
|
|
tags: nitnelave/lldap:latest
|
2022-07-01 19:53:50 +00:00
|
|
|
#cache-from: type=gha
|
|
|
|
#cache-to: type=gha,mode=max
|
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache-new
|
2022-06-30 17:31:31 +00:00
|
|
|
|
|
|
|
- name: Build and push release
|
2022-06-30 09:21:14 +00:00
|
|
|
if: github.event_name == 'release'
|
|
|
|
uses: docker/build-push-action@v3
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
2022-06-30 17:31:31 +00:00
|
|
|
push: true
|
2022-06-30 09:21:14 +00:00
|
|
|
# Tag as latest, stable, semver, major, major.minor and major.minor.patch.
|
2022-06-30 17:31:31 +00:00
|
|
|
file: ./.github/workflows/Dockerfile.ci
|
|
|
|
tags: nitnelave/lldap:stable, nitnelave/lldap:v${{ steps.slug.outputs.version-semantic }}, nitnelave/lldap:v${{ steps.slug.outputs.version-major }}, nitnelave/lldap:v${{ steps.slug.outputs.version-major }}.${{ steps.slug.outputs.version-minor }}, nitnelave/lldap:v${{ steps.slug.outputs.version-major }}.${{ steps.slug.outputs.version-minor }}.${{ steps.slug.outputs.version-patch }}
|
2022-07-01 19:53:50 +00:00
|
|
|
#cache-from: type=gha
|
|
|
|
#cache-to: type=gha,mode=max
|
|
|
|
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
|
2022-06-30 09:21:14 +00:00
|
|
|
|
|
|
|
- name: Update repo description
|
|
|
|
if: github.event_name != 'pull_request'
|
|
|
|
uses: peter-evans/dockerhub-description@v3
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
|
|
repository: nitnelave/lldap
|
|
|
|
|