From e7cd8645a48f98f17fb3e70465e9101436fa743c Mon Sep 17 00:00:00 2001 From: muzuke <92723634+muzuke@users.noreply.github.com> Date: Sat, 19 Oct 2024 22:45:31 +0300 Subject: [PATCH] Add workflow to create the build layer images --- .github/workflows/docker-layers.yml | 108 ++++++++++++++++++++++++++++ .github/workflows/docker-v2.yml | 16 ++--- Dockerfile.v2 | 6 +- 3 files changed, 119 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/docker-layers.yml diff --git a/.github/workflows/docker-layers.yml b/.github/workflows/docker-layers.yml new file mode 100644 index 0000000000..7e7a1f3d86 --- /dev/null +++ b/.github/workflows/docker-layers.yml @@ -0,0 +1,108 @@ +name: Docker layers + +# +# The workflow is meant to be triggered manually when there is a need to update the build layers. +# + +on: + # TODO: To be removed after PR is merged. + pull_request: + + workflow_dispatch: + inputs: + version: + description: "The version tag to use" + required: true + default: latest + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + TMP_LOCAL_IMAGE: localhost:5000/radixdlt/babylon-node-build-layers + REGISTRY_IMAGE: docker.io/radixdlt/babylon-node-build-layers + REGISTRY_TAG: latest + +jobs: + build_java_layer: + strategy: + matrix: + os: ["ubuntu-latest-8-cores", "ubuntu-latest-arm-8-cores"] + arch: ["amd64", "arm64"] + exclude: + - os: ubuntu-latest-8-cores + arch: arm64 + - os: ubuntu-latest-arm-8-cores + arch: amd64 + name: Build Java docker layer + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: RDXWorks-actions/checkout@main + - name: Set up Docker Buildx + uses: RDXWorks-actions/setup-buildx-action@master + - name: Prepare docker build + run: | + mkdir -p /tmp/images + platform=${{ matrix.arch }} + echo "TARFILE=${platform}-java.tar" >> $GITHUB_ENV + echo "TAG=${{ env.TMP_LOCAL_IMAGE }}:${platform}-java" >> $GITHUB_ENV + - name: Build image + uses: RDXWorks-actions/build-push-action@v6 + with: + file: ./docker/dockerfiles/java.dockerfile + context: . + platforms: linux/${{ matrix.arch }} + tags: ${{ env.TAG }}-java + labels: ${{ steps.meta.outputs.labels }} + outputs: type=docker,dest=/tmp/images/${{ env.TARFILE }} + push: false + - name: Upload images + uses: RDXWorks-actions/upload-artifact-v4@main + with: + name: images-${{ matrix.arch }}-java + path: /tmp/images/${{ env.TARFILE }} + if-no-files-found: error + retention-days: 1 + + build_rust_layer: + strategy: + matrix: + os: ["ubuntu-latest-8-cores", "ubuntu-latest-arm-8-cores"] + arch: ["amd64", "arm64"] + exclude: + - os: ubuntu-latest-8-cores + arch: arm64 + - os: ubuntu-latest-arm-8-cores + arch: amd64 + name: Build Rust docker layer + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: RDXWorks-actions/checkout@main + - name: Set up Docker Buildx + uses: RDXWorks-actions/setup-buildx-action@master + - name: Prepare docker build + run: | + mkdir -p /tmp/images + platform=${{ matrix.arch }} + echo "TARFILE=${platform}-rust.tar" >> $GITHUB_ENV + echo "TAG=${{ env.TMP_LOCAL_IMAGE }}:${platform}-rust" >> $GITHUB_ENV + - name: Build image + uses: RDXWorks-actions/build-push-action@v6 + with: + file: ./docker/dockerfiles/rust.dockerfile + context: . + platforms: linux/${{ matrix.arch }} + tags: ${{ env.TAG }}-rust + labels: ${{ steps.meta.outputs.labels }} + outputs: type=docker,dest=/tmp/images/${{ env.TARFILE }} + push: false + - name: Upload images + uses: RDXWorks-actions/upload-artifact-v4@main + with: + name: images-${{ matrix.arch }}-rust + path: /tmp/images/${{ env.TARFILE }} + if-no-files-found: error + retention-days: 1 diff --git a/.github/workflows/docker-v2.yml b/.github/workflows/docker-v2.yml index a0886448fa..d365f777ce 100644 --- a/.github/workflows/docker-v2.yml +++ b/.github/workflows/docker-v2.yml @@ -1,14 +1,14 @@ name: Docker v2 on: - pull_request: - # release: - # types: [published] - # push: - # branches: - # - develop - # - main - # - release\/* + # pull_request: + release: + types: [published] + push: + branches: + - develop + - main + - release\/* concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/Dockerfile.v2 b/Dockerfile.v2 index 396f878f0f..088b65a614 100644 --- a/Dockerfile.v2 +++ b/Dockerfile.v2 @@ -1,4 +1,4 @@ -FROM radixdlt/build-layers:java AS java-container +FROM radixdlt/babylon-node-build-layers:v1.2.3-java AS java-container WORKDIR /radixdlt @@ -30,7 +30,7 @@ RUN cd core/build/distributions && \ cp *.jar /artifacts && \ cp core /artifacts -FROM radixdlt/build-layers:rust AS rust-container +FROM radixdlt/babylon-node-build-layers:v1.2.3-rust AS rust-container WORKDIR /app @@ -40,7 +40,7 @@ RUN mkdir -p /artifacts && \ /root/.cargo/bin/cargo build --profile=release && \ cp target/release/libcorerust.so /artifacts/libcorerust.so -FROM radixdlt/build-layers:app AS main +FROM radixdlt/babylon-node-build-layers:v1.2.3-app AS main # Copy in the application artifacts COPY --from=java-container /artifacts/*.jar /opt/radixdlt/lib/