From 803504328bbe19eb95808f2a62bc0f329041b021 Mon Sep 17 00:00:00 2001 From: BAStos525 <66615487+BAStos525@users.noreply.github.com> Date: Thu, 12 Dec 2024 17:24:55 +0300 Subject: [PATCH] ci: update images building workflows (#5265) * ci: update images building workflows Signed-off-by: BAStos525 * rename Dockerfiles Signed-off-by: BAStos525 * rename Dockerfile.glibc to Dockerfile Signed-off-by: BAStos525 * Fix choice options for custom jobs Co-authored-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com> Signed-off-by: BAStos525 <66615487+BAStos525@users.noreply.github.com> --------- Signed-off-by: BAStos525 Signed-off-by: BAStos525 <66615487+BAStos525@users.noreply.github.com> Co-authored-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com> --- .github/workflows/iroha2-custom-image.yml | 42 +++------- .github/workflows/iroha2-dev-pr.yml | 2 - .github/workflows/iroha2-dev-sonar-dojo.yml | 2 +- .github/workflows/iroha2-dev.yml | 1 - .github/workflows/iroha2-release.yml | 61 +++++++++++++- Dockerfile | 89 ++++++++------------- Dockerfile.glibc | 69 ---------------- Dockerfile.musl | 88 ++++++++++++++++++++ 8 files changed, 194 insertions(+), 160 deletions(-) delete mode 100644 Dockerfile.glibc create mode 100644 Dockerfile.musl diff --git a/.github/workflows/iroha2-custom-image.yml b/.github/workflows/iroha2-custom-image.yml index 1256d52ff2f..0ade658fb07 100644 --- a/.github/workflows/iroha2-custom-image.yml +++ b/.github/workflows/iroha2-custom-image.yml @@ -1,38 +1,24 @@ name: I2::Custom::Publish on: - push: - tags: - - 'v2*' workflow_dispatch: inputs: - BUILD_GLIBC_IMAGE: - description: "Select \"true\" to build and push the standard \"glibc\" image" - type: choice + PROFILER_NAME: + description: "Profiler value (profiling/glibc/alpine) as the image tag part" required: true - default: 'false' - options: - - true - - false - BUILD_ALPINE_IMAGE: - description: "Select \"true\" to build and push the alpine image from specific commit SHA" type: choice - required: true - default: 'false' options: - - true - - false + - profiling + - glibc + - alpine + default: glibc CHECKOUT_REF: description: "The branch, tag or SHA to checkout" required: true + type: string default: main - PROFILER_NAME: - description: "Profiler value (glibc/alpine) as the image tag part" - required: true - default: glibc env: - IROHA2_DOCKERFILE: Dockerfile.glibc IROHA2_PROFILE: profiling IROHA2_RUSTFLAGS: -C force-frame-pointers=on IROHA2_FEATURES: profiling @@ -60,7 +46,7 @@ jobs: retention-days: 1 registry-profiling-image: - if: ${{ inputs.BUILD_GLIBC_IMAGE == 'false' }} and ${{ inputs.BUILD_ALPINE_IMAGE == 'false' }} + if: ${{ inputs.PROFILER_NAME == 'profiling' }} runs-on: [self-hosted, Linux, iroha2] needs: build_wasm_libs container: @@ -103,20 +89,17 @@ jobs: if: always() with: push: true - tags: | - hyperledger/iroha:${{ env.TAG }}-${{ env.IROHA2_PROFILE }} - docker.soramitsu.co.jp/iroha2/iroha:${{ env.TAG }}-${{ env.IROHA2_PROFILE }} + tags: docker.soramitsu.co.jp/iroha2/iroha:${{ env.TAG }}-${{ inputs.PROFILER_NAME }}-${{ github.sha }} labels: commit=${{ github.sha }} build-args: | "PROFILE=${{ env.IROHA2_PROFILE }}" "RUSTFLAGS=${{ env.IROHA2_RUSTFLAGS }}" "FEATURES=${{ env.IROHA2_FEATURES }}" "CARGOFLAGS=${{ env.IROHA2_CARGOFLAGS }}" - file: ${{env.IROHA2_DOCKERFILE }} context: . registry-glibc-image: - if: ${{ inputs.BUILD_GLIBC_IMAGE == 'true' }} and ${{ inputs.BUILD_ALPINE_IMAGE == 'false' }} + if: ${{ inputs.PROFILER_NAME == 'glibc' }} runs-on: [self-hosted, Linux, iroha2] needs: build_wasm_libs container: @@ -151,11 +134,10 @@ jobs: push: true tags: docker.soramitsu.co.jp/iroha2/iroha:${{ inputs.PROFILER_NAME }}-${{ github.sha }} labels: commit=${{ github.sha }} - file: ${{env.IROHA2_DOCKERFILE }} context: . registry-alpine-image: - if: ${{ inputs.BUILD_GLIBC_IMAGE == 'false' }} and ${{ inputs.BUILD_ALPINE_IMAGE == 'true' }} + if: ${{ inputs.PROFILER_NAME == 'alpine' }} runs-on: [self-hosted, Linux, iroha2] needs: build_wasm_libs container: @@ -190,5 +172,5 @@ jobs: push: true tags: docker.soramitsu.co.jp/iroha2/iroha:${{ inputs.PROFILER_NAME }}-${{ github.sha }} labels: commit=${{ github.sha }} - file: Dockerfile + file: Dockerfile.musl context: . diff --git a/.github/workflows/iroha2-dev-pr.yml b/.github/workflows/iroha2-dev-pr.yml index b451f9a0d06..61aae2aff95 100644 --- a/.github/workflows/iroha2-dev-pr.yml +++ b/.github/workflows/iroha2-dev-pr.yml @@ -168,7 +168,6 @@ jobs: tags: docker.soramitsu.co.jp/iroha2/iroha2:dev-${{ github.event.pull_request.head.sha }} labels: commit=${{ github.sha }} build-args: TAG=dev - file: Dockerfile.glibc # This context specification is required context: . @@ -211,7 +210,6 @@ jobs: with: context: . load: true - file: Dockerfile.glibc tags: | hyperledger/iroha:local hyperledger/iroha:dev diff --git a/.github/workflows/iroha2-dev-sonar-dojo.yml b/.github/workflows/iroha2-dev-sonar-dojo.yml index d369581946e..18973c19f52 100644 --- a/.github/workflows/iroha2-dev-sonar-dojo.yml +++ b/.github/workflows/iroha2-dev-sonar-dojo.yml @@ -35,7 +35,7 @@ jobs: -Dcommunity.rust.lcov.reportPaths=lints/lcov.info - name: DefectDojo id: defectdojo - uses: C4tWithShell/defectdojo-action@1.0.5 + uses: C4tWithShell/defectdojo-action@1.0.6 with: token: ${{ secrets.DEFECTOJO_TOKEN }} defectdojo_url: ${{ secrets.DEFECTOJO_URL }} diff --git a/.github/workflows/iroha2-dev.yml b/.github/workflows/iroha2-dev.yml index e59be25c7f8..3227b7794d5 100644 --- a/.github/workflows/iroha2-dev.yml +++ b/.github/workflows/iroha2-dev.yml @@ -62,7 +62,6 @@ jobs: uses: docker/build-push-action@v6 with: context: . - file: Dockerfile.glibc push: true tags: | hyperledger/iroha:dev diff --git a/.github/workflows/iroha2-release.yml b/.github/workflows/iroha2-release.yml index 9f6ac3658b1..5d674d1ff53 100644 --- a/.github/workflows/iroha2-release.yml +++ b/.github/workflows/iroha2-release.yml @@ -9,6 +9,10 @@ env: CARGO_TERM_COLOR: always DEFAULTS_DIR: defaults WASM_TARGET_DIR: wasm/target/prebuilt + IROHA2_PROFILE: profiling + IROHA2_RUSTFLAGS: -C force-frame-pointers=on + IROHA2_FEATURES: profiling + IROHA2_CARGOFLAGS: -Z build-std jobs: build_wasm_libs: @@ -27,8 +31,8 @@ jobs: path: ${{ env.WASM_TARGET_DIR }}/libs retention-days: 1 - registry: - runs-on: ubuntu-latest + registry-no-profiling: + runs-on: [self-hosted, Linux, iroha2] needs: build_wasm_libs steps: - uses: actions/checkout@v4 @@ -56,7 +60,6 @@ jobs: with: context: . load: true - file: Dockerfile.glibc tags: | hyperledger/iroha:${{ env.TAG }} docker.soramitsu.co.jp/iroha2/iroha:${{ env.TAG }} @@ -94,3 +97,55 @@ jobs: hyperledger/iroha:${{ env.TAG }} docker.soramitsu.co.jp/iroha2/iroha:${{ env.TAG }} labels: commit=${{ github.sha }} + + registry-with-profiling: + runs-on: [self-hosted, Linux, iroha2] + needs: build_wasm_libs + container: + image: hyperledger/iroha2-ci:nightly-2024-09-09 + steps: + - uses: actions/checkout@v4 + - name: Download wasm libs + uses: actions/download-artifact@v4 + with: + name: wasm-libs + path: ${{ env.DEFAULTS_DIR }}/libs + - name: Move the default executor + run: mv ${{ env.DEFAULTS_DIR }}/libs/default_executor.wasm ${{ env.DEFAULTS_DIR }}/executor.wasm + - name: Get the release tag + run: | + RELEASE_VERSION=${{ github.ref_name }} + PREFIX='v' + TAG=${RELEASE_VERSION#$PREFIX} + echo "TAG=$TAG" >>$GITHUB_ENV + - uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Login to Soramitsu Harbor + uses: docker/login-action@v3 + with: + registry: docker.soramitsu.co.jp + username: ${{ secrets.HARBOR_USERNAME }} + password: ${{ secrets.HARBOR_TOKEN }} + - name: Set up Docker Buildx + id: buildx + if: always() + uses: docker/setup-buildx-action@v3 + with: + install: true + - name: Build and push iroha2-profiling image + uses: docker/build-push-action@v6 + if: always() + with: + push: true + tags: | + hyperledger/iroha:${{ env.TAG }}-${{ env.IROHA2_PROFILE }} + docker.soramitsu.co.jp/iroha2/iroha:${{ env.TAG }}-${{ env.IROHA2_PROFILE }} + labels: commit=${{ github.sha }} + build-args: | + "PROFILE=${{ env.IROHA2_PROFILE }}" + "RUSTFLAGS=${{ env.IROHA2_RUSTFLAGS }}" + "FEATURES=${{ env.IROHA2_FEATURES }}" + "CARGOFLAGS=${{ env.IROHA2_CARGOFLAGS }}" + context: . diff --git a/Dockerfile b/Dockerfile index b8f064b3bb7..d1e8079a382 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,66 +1,47 @@ -FROM --platform=linux/amd64 archlinux:base-devel AS builder +# base stage +FROM debian:bookworm-slim AS builder -ARG NIGHTLY_VERSION=2024-09-09 +# install required packages +RUN apt-get update -y && \ + apt-get install -y curl build-essential mold pkg-config libssl-dev -RUN <