Use a rust layer with a full app build #5
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: v1.2.4 | |
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 | |
build_app_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 App 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}-app.tar" >> $GITHUB_ENV | |
echo "TAG=${{ env.TMP_LOCAL_IMAGE }}:${platform}-app" >> $GITHUB_ENV | |
- name: Build image | |
uses: RDXWorks-actions/build-push-action@v6 | |
with: | |
file: ./docker/dockerfiles/app.dockerfile | |
context: . | |
platforms: linux/${{ matrix.arch }} | |
tags: ${{ env.TAG }}-app | |
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 }}-app | |
path: /tmp/images/${{ env.TARFILE }} | |
if-no-files-found: error | |
retention-days: 1 | |
push_java_layer: | |
name: Push Java docker image | |
runs-on: ubuntu-latest | |
services: | |
registry: | |
image: registry:2 | |
ports: | |
- 5000:5000 | |
needs: | |
- build_java_layer | |
permissions: | |
id-token: write | |
contents: read | |
pull-requests: read | |
steps: | |
- name: Configure AWS credentials | |
uses: RDXWorks-actions/configure-aws-credentials@main | |
with: | |
role-to-assume: ${{ secrets.COMMON_SECRETS_ROLE_ARN }} | |
aws-region: eu-west-2 | |
- name: Setup dockerhub credentials | |
uses: RDXWorks-actions/aws-secretsmanager-get-secrets@main | |
with: | |
secret-ids: | | |
DOCKERHUB_PRIVATE, github-actions/common/dockerhub-credentials | |
parse-json-secrets: true | |
- name: Login to Docker Hub | |
uses: RDXWorks-actions/login-action@master | |
with: | |
username: ${{env.DOCKERHUB_PRIVATE_USERNAME}} | |
password: ${{env.DOCKERHUB_PRIVATE_TOKEN}} | |
- name: Set up Docker Buildx | |
uses: RDXWorks-actions/setup-buildx-action@master | |
- name: Download images | |
uses: RDXWorks-actions/download-artifact-v4@main | |
with: | |
pattern: images-*-java | |
path: /tmp/images | |
merge-multiple: true | |
- name: Load images | |
run: | | |
for image in /tmp/images/*.tar; do | |
docker load -i $image | |
done | |
- name: Push images to local registry | |
run: docker push -a ${{ env.TMP_LOCAL_IMAGE }} | |
- name: Create manifest list and push | |
run: | | |
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:${{ env.REGISTRY_TAG }}-java \ | |
$(docker image ls --format '{{.Repository}}:{{.Tag}}' '${{ env.TMP_LOCAL_IMAGE }}' | tr '\n' ' ') | |
- name: Inspect image | |
run: | | |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ env.REGISTRY_TAG }}-java | |
push_app_layer: | |
name: Push App docker image | |
runs-on: ubuntu-latest | |
services: | |
registry: | |
image: registry:2 | |
ports: | |
- 5000:5000 | |
needs: | |
- build_app_layer | |
permissions: | |
id-token: write | |
contents: read | |
pull-requests: read | |
steps: | |
- name: Configure AWS credentials | |
uses: RDXWorks-actions/configure-aws-credentials@main | |
with: | |
role-to-assume: ${{ secrets.COMMON_SECRETS_ROLE_ARN }} | |
aws-region: eu-west-2 | |
- name: Setup dockerhub credentials | |
uses: RDXWorks-actions/aws-secretsmanager-get-secrets@main | |
with: | |
secret-ids: | | |
DOCKERHUB_PRIVATE, github-actions/common/dockerhub-credentials | |
parse-json-secrets: true | |
- name: Login to Docker Hub | |
uses: RDXWorks-actions/login-action@master | |
with: | |
username: ${{env.DOCKERHUB_PRIVATE_USERNAME}} | |
password: ${{env.DOCKERHUB_PRIVATE_TOKEN}} | |
- name: Set up Docker Buildx | |
uses: RDXWorks-actions/setup-buildx-action@master | |
- name: Download images | |
uses: RDXWorks-actions/download-artifact-v4@main | |
with: | |
pattern: images-*-app | |
path: /tmp/images | |
merge-multiple: true | |
- name: Load images | |
run: | | |
for image in /tmp/images/*.tar; do | |
docker load -i $image | |
done | |
- name: Push images to local registry | |
run: docker push -a ${{ env.TMP_LOCAL_IMAGE }} | |
- name: Create manifest list and push | |
run: | | |
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:${{ env.REGISTRY_TAG }}-app \ | |
$(docker image ls --format '{{.Repository}}:{{.Tag}}' '${{ env.TMP_LOCAL_IMAGE }}' | tr '\n' ' ') | |
- name: Inspect image | |
run: | | |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ env.REGISTRY_TAG }}-app | |
push_rust_layer: | |
name: Push Rust docker image | |
runs-on: ubuntu-latest | |
services: | |
registry: | |
image: registry:2 | |
ports: | |
- 5000:5000 | |
needs: | |
- build_rust_layer | |
permissions: | |
id-token: write | |
contents: read | |
pull-requests: read | |
steps: | |
- name: Configure AWS credentials | |
uses: RDXWorks-actions/configure-aws-credentials@main | |
with: | |
role-to-assume: ${{ secrets.COMMON_SECRETS_ROLE_ARN }} | |
aws-region: eu-west-2 | |
- name: Setup dockerhub credentials | |
uses: RDXWorks-actions/aws-secretsmanager-get-secrets@main | |
with: | |
secret-ids: | | |
DOCKERHUB_PRIVATE, github-actions/common/dockerhub-credentials | |
parse-json-secrets: true | |
- name: Login to Docker Hub | |
uses: RDXWorks-actions/login-action@master | |
with: | |
username: ${{env.DOCKERHUB_PRIVATE_USERNAME}} | |
password: ${{env.DOCKERHUB_PRIVATE_TOKEN}} | |
- name: Set up Docker Buildx | |
uses: RDXWorks-actions/setup-buildx-action@master | |
- name: Download images | |
uses: RDXWorks-actions/download-artifact-v4@main | |
with: | |
pattern: images-*-rust | |
path: /tmp/images | |
merge-multiple: true | |
- name: Load images | |
run: | | |
for image in /tmp/images/*.tar; do | |
docker load -i $image | |
done | |
- name: Push images to local registry | |
run: docker push -a ${{ env.TMP_LOCAL_IMAGE }} | |
- name: Create manifest list and push | |
run: | | |
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:${{ env.REGISTRY_TAG }}-rust \ | |
$(docker image ls --format '{{.Repository}}:{{.Tag}}' '${{ env.TMP_LOCAL_IMAGE }}' | tr '\n' ' ') | |
- name: Inspect image | |
run: | | |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ env.REGISTRY_TAG }}-rust |