Skip to content

Commit

Permalink
Add push jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
muzuke committed Oct 19, 2024
1 parent e6c20e3 commit 7793ef2
Showing 1 changed file with 218 additions and 41 deletions.
259 changes: 218 additions & 41 deletions .github/workflows/docker-layers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ concurrency:
env:
TMP_LOCAL_IMAGE: localhost:5000/radixdlt/babylon-node-build-layers
REGISTRY_IMAGE: docker.io/radixdlt/babylon-node-build-layers
REGISTRY_TAG: latest
REGISTRY_TAG: v1.2.4

jobs:
build_java_layer:
Expand Down Expand Up @@ -66,46 +66,46 @@ jobs:
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_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:
Expand Down Expand Up @@ -147,3 +147,180 @@ jobs:
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 }}
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 }}
# 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 }}

0 comments on commit 7793ef2

Please sign in to comment.