lldap/.github/workflows/docker-build-static.yml

492 lines
18 KiB
YAML
Raw Permalink Normal View History

name: Docker Static
on:
push:
branches:
- 'main'
2022-11-21 11:10:47 +00:00
- 'v1'
release:
types:
- 'published'
pull_request:
branches:
- 'main'
workflow_dispatch:
inputs:
msg:
description: "Set message"
default: "Manual trigger"
2022-07-15 13:02:35 +00:00
env:
CARGO_TERM_COLOR: always
# 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
2022-07-15 13:02:35 +00:00
### 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
# 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
# cache
## cargo
## target
jobs:
build-ui:
runs-on: ubuntu-latest
2022-07-15 13:02:35 +00:00
container:
2022-07-18 03:52:02 +00:00
image: rust:1.62
env:
CARGO_TERM_COLOR: always
2022-07-18 03:52:02 +00:00
RUSTFLAGS: -Ctarget-feature=+crt-static
steps:
- name: install runtime
2022-07-31 03:20:26 +00:00
run: apt update && apt install -y gcc-x86-64-linux-gnu g++-x86-64-linux-gnu libc6-dev ca-certificates
- 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
with:
path: |
/usr/local/cargo/bin
/usr/local/cargo/registry/index
/usr/local/cargo/registry/cache
/usr/local/cargo/git/db
target
key: lldap-ui-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
lldap-ui-
- name: Checkout repository
uses: actions/checkout@v3.1.0
2022-08-01 13:43:29 +00:00
- name: install rollup nodejs
run: npm install -g rollup
- name: install wasm-pack with cargo
run: cargo install wasm-pack || true
2022-09-10 11:01:42 +00:00
env:
RUSTFLAGS: ""
- 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/
2022-07-15 13:02:35 +00:00
build-armhf:
runs-on: ubuntu-latest
2022-07-15 13:02:35 +00:00
container:
2022-07-18 03:52:02 +00:00
image: rust:1.62
env:
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc
2022-07-31 03:20:26 +00:00
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_LINKER: arm-linux-gnueabihf-ld
CARGO_TERM_COLOR: always
2022-07-18 03:52:02 +00:00
RUSTFLAGS: -Ctarget-feature=-crt-static
CARGO_HOME: ${GITHUB_WORKSPACE}/.cargo
steps:
- name: add armhf architecture
run: dpkg --add-architecture armhf
- name: install runtime
2022-07-31 03:14:15 +00:00
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
run: rustup target add armv7-unknown-linux-gnueabihf
- name: smoke test
run: rustc --version
- name: Checkout repository
uses: actions/checkout@v3.1.0
- uses: actions/cache@v3
with:
path: |
.cargo/bin
.cargo/registry/index
.cargo/registry/cache
.cargo/git/db
target
key: lldap-bin-armhf-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
lldap-bin-armhf-
- 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
- name: upload armhf lldap artifacts
uses: actions/upload-artifact@v3
with:
name: armhf-lldap-bin
path: target/armv7-unknown-linux-gnueabihf/release/lldap
- name: upload armhfmigration-tool artifacts
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
2022-07-15 13:02:35 +00:00
container:
2022-08-01 13:43:29 +00:00
##################################################################################
# Github actions currently timeout when downloading musl-gcc #
# Using lldap dev image based on rust:1.62-slim-bullseye and musl-gcc bundled #
# Only for Job build aarch64 and amd64 #
###################################################################################
2022-08-01 12:50:45 +00:00
#image: rust:1.62
2022-08-01 13:09:17 +00:00
image: nitnelave/rust-dev:latest
env:
2022-07-31 03:20:26 +00:00
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-musl-gcc
CARGO_TERM_COLOR: always
RUSTFLAGS: -Ctarget-feature=+crt-static
CARGO_HOME: ${GITHUB_WORKSPACE}/.cargo
steps:
- name: Checkout repository
uses: actions/checkout@v3.1.0
- name: smoke test
2022-08-01 13:43:29 +00:00
run: rustc --version
- name: Checkout repository
uses: actions/checkout@v3.1.0
- uses: actions/cache@v3
with:
path: |
.cargo/bin
.cargo/registry/index
.cargo/registry/cache
.cargo/git/db
target
key: lldap-bin-aarch64-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
2022-08-01 12:28:42 +00:00
lldap-bin-aarch64-
2022-08-01 12:50:45 +00:00
# - name: fetch musl-gcc
# run: |
2022-08-01 16:21:25 +00:00
# wget -c https://musl.cc/aarch64-linux-musl-cross.tgz
2022-08-01 12:50:45 +00:00
# tar zxf ./x86_64-linux-musl-cross.tgz -C /opt
2022-08-01 16:21:25 +00:00
# echo "/opt/aarch64-linux-musl-cross:/opt/aarch64-linux-musl-cross/bin" >> $GITHUB_PATH
2022-07-31 03:20:26 +00:00
- name: add musl aarch64 target
run: rustup target add aarch64-unknown-linux-musl
- name: build lldap aarch4
run: cargo build --target=aarch64-unknown-linux-musl --release -p lldap -p migration-tool
- name: check path
2022-07-18 03:52:02 +00:00
run: ls -al target/aarch64-unknown-linux-musl/release/
- name: upload aarch64 lldap artifacts
uses: actions/upload-artifact@v3
with:
name: aarch64-lldap-bin
2022-07-18 03:52:02 +00:00
path: target/aarch64-unknown-linux-musl/release/lldap
- name: upload aarch64 migration-tool artifacts
uses: actions/upload-artifact@v3
with:
name: aarch64-migration-tool-bin
2022-07-18 03:52:02 +00:00
path: target/aarch64-unknown-linux-musl/release/migration-tool
build-amd64:
runs-on: ubuntu-latest
2022-07-15 13:02:35 +00:00
container:
2022-08-01 12:50:45 +00:00
# image: rust:1.62
2022-08-01 13:09:17 +00:00
image: nitnelave/rust-dev:latest
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -Ctarget-feature=+crt-static
CARGO_HOME: ${GITHUB_WORKSPACE}/.cargo
2022-07-31 03:20:26 +00:00
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER: x86_64-linux-musl-gcc
steps:
- name: Checkout repository
uses: actions/checkout@v3.1.0
- uses: actions/cache@v3
with:
path: |
.cargo/bin
.cargo/registry/index
.cargo/registry/cache
.cargo/git/db
target
key: lldap-bin-amd64-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
lldap-bin-amd64-
2022-08-01 07:31:44 +00:00
- name: install musl
2022-08-01 07:38:51 +00:00
run: apt update && apt install -y musl-tools tar wget
2022-08-01 12:50:45 +00:00
# - name: fetch musl-gcc
# run: |
2022-08-01 16:21:25 +00:00
# wget -c https://musl.cc/x86_64-linux-musl-cross.tgz
2022-08-01 12:50:45 +00:00
# tar zxf ./x86_64-linux-musl-cross.tgz -C /opt
# echo "/opt/x86_64-linux-musl-cross:/opt/x86_64-linux-musl-cross/bin" >> $GITHUB_PATH
2022-08-01 07:38:51 +00:00
- name: add x86_64 target
run: rustup target add x86_64-unknown-linux-musl
- name: build x86_64 lldap
run: cargo build --target=x86_64-unknown-linux-musl --release -p lldap -p migration-tool
- name: check path
2022-07-18 03:52:02 +00:00
run: ls -al target/x86_64-unknown-linux-musl/release/
- name: upload amd64 lldap artifacts
uses: actions/upload-artifact@v3
with:
name: amd64-lldap-bin
2022-07-18 03:52:02 +00:00
path: target/x86_64-unknown-linux-musl/release/lldap
- name: upload amd64 migration-tool artifacts
uses: actions/upload-artifact@v3
with:
name: amd64-migration-tool-bin
2022-07-18 03:52:02 +00:00
path: target/x86_64-unknown-linux-musl/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: install rsync
run: sudo apt update && sudo apt install -y rsync
- name: fetch repo
uses: actions/checkout@v3.1.0
2022-07-15 13:02:35 +00:00
- 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
2022-07-15 13:02:35 +00:00
- 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
2022-07-15 13:02:35 +00:00
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
2022-07-15 13:02:35 +00:00
- name: check bin path
run: ls -al bin/
2022-07-15 13:02:35 +00:00
- name: Download llap ui artifacts
uses: actions/download-artifact@v3
with:
name: ui
path: web
2022-07-15 13:02:35 +00:00
- name: setup qemu
uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
2022-07-15 13:02:35 +00:00
- 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
- 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-07-15 13:02:35 +00:00
- name: parse tag
uses: gacts/github-slug@v1
id: slug
2022-07-15 13:02:35 +00:00
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
2022-08-01 16:21:25 +00:00
2022-07-18 03:52:02 +00:00
######################
#### latest build ####
######################
2022-11-21 11:10:47 +00:00
- name: Sets env vars for docker images
run: |
echo "DOCKER_IMAGE_SUFFIX=-v1" >> $GITHUB_ENV
if: github.ref == 'refs/heads/v1'
2022-07-18 03:52:02 +00:00
- name: Build and push latest alpine
if: github.event_name != 'release'
uses: docker/build-push-action@v3
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
2022-07-18 03:52:02 +00:00
platforms: linux/amd64,linux/arm64
file: ./.github/workflows/Dockerfile.ci.alpine
2022-11-21 11:10:47 +00:00
tags: nitnelave/lldap:latest${{env.DOCKER_IMAGE_SUFFIX}}, nitnelave/lldap:latest-alpine${{env.DOCKER_IMAGE_SUFFIX}}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
2022-08-01 16:21:25 +00:00
2022-07-18 03:52:02 +00:00
- name: Build and push latest debian
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.debian
2022-11-21 11:10:47 +00:00
tags: nitnelave/lldap:latest-debian${{env.DOCKER_IMAGE_SUFFIX}}
2022-07-18 03:52:02 +00:00
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
2022-08-01 16:21:25 +00:00
2022-07-18 03:52:02 +00:00
#######################
#### release build ####
2022-08-01 16:21:25 +00:00
#######################
2022-07-18 03:52:02 +00:00
- name: Build and push release alpine
2022-11-21 11:10:47 +00:00
if: github.event_name == 'release' && github.ref != 'refs/heads/v1'
2022-07-18 03:52:02 +00:00
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
# Tag as latest, stable, semver, major, major.minor and major.minor.patch.
file: ./.github/workflows/Dockerfile.ci.alpine
2022-08-01 08:35:38 +00:00
tags: nitnelave/lldap:stable, nitnelave/lldap:stable-alpine, 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 }}, nitnelave/lldap:v${{ steps.slug.outputs.version-semantic }}-alpine, nitnelave/lldap:v${{ steps.slug.outputs.version-major }}-alpine, nitnelave/lldap:v${{ steps.slug.outputs.version-major }}-alpine.${{ steps.slug.outputs.version-minor }}-alpine, nitnelave/lldap:v${{ steps.slug.outputs.version-major }}.${{ steps.slug.outputs.version-minor }}.${{ steps.slug.outputs.version-patch }}-alpine
2022-07-18 03:52:02 +00:00
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
2022-07-15 13:02:35 +00:00
2022-07-18 03:52:02 +00:00
- name: Build and push release debian
if: github.event_name == 'release'
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
# Tag as latest, stable, semver, major, major.minor and major.minor.patch.
2022-07-18 03:52:02 +00:00
file: ./.github/workflows/Dockerfile.ci.debian
tags: nitnelave/lldap:stable-debian, nitnelave/lldap:v${{ steps.slug.outputs.version-semantic }}-debian, nitnelave/lldap:v${{ steps.slug.outputs.version-major }}-debian, nitnelave/lldap:v${{ steps.slug.outputs.version-major }}.${{ steps.slug.outputs.version-minor }}-debian, nitnelave/lldap:v${{ steps.slug.outputs.version-major }}.${{ steps.slug.outputs.version-minor }}.${{ steps.slug.outputs.version-patch }}-debian
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
2022-07-15 13:02:35 +00:00
- name: Move cache
run: rsync -r /tmp/.buildx-cache-new /tmp/.buildx-cache --delete
2022-07-15 13:02:35 +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
create-release-artifacts:
needs: [build-ui,build-armhf,build-aarch64,build-amd64]
name: Create release artifacts
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- 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: Fix binary name armhf
run: mv bin/armhf-bin/lldap bin/armhf-bin/lldap-armhf && mv bin/armhf-bin/migration-tool bin/armhf-bin/migration-tool-armhf
- 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: 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
uses: actions/download-artifact@v3
with:
name: ui
path: web
- name: Web Cleanup
run: mkdir app && mv web/index.html app/index.html && mv web/static app/static && mv web/pkg app/pkg
- name: compress web
run: sudo apt update && sudo apt install -y zip && zip -r web.zip app/
- name: Upload artifacts release
uses: ncipollo/release-action@v1
id: create_release
with:
allowUpdates: true
artifacts: "bin/armhf-bin/lldap-armhf,
bin/aarch64-bin/lldap-aarch64,
bin/amd64-bin/lldap-amd64,
bin/armhf-bin/migration-tool-armhf,
bin/aarch64-bin/migration-tool-aarch64,
bin/amd64-bin/migration-tool-amd64,
web.zip"
env:
2022-11-21 11:10:47 +00:00
GITHUB_TOKEN: ${{ github.token }}