Skip to content

Commit

Permalink
Use separate runner for Docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
f0reachARR committed Jan 23, 2025
1 parent d72bc26 commit b2d9c7f
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 119 deletions.
120 changes: 74 additions & 46 deletions .github/workflows/Docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,37 @@ on:
description: version of the scenario_simulator_v2
required: true

env:
REGISTRY_IMAGE: ghcr.io/tier4/scenario_simulator_v2

jobs:
push_docker:
name: Push Docker Image
runs-on: ubuntu-22.04
timeout-minutes: 720
build:
strategy:
fail-fast: false
matrix:
rosdistro: [humble]
# arch: [amd64, arm64]
arch: [amd64]

include:
- platform: linux/amd64
runner: ubuntu-22.04
- platform: linux/arm64
runner: ubuntu-22.04-arm
runs-on: ${{ matrix.runner }}
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Install docker for ubuntu runner
uses: docker/setup-buildx-action@v3
- name: Checkout
uses: actions/checkout@v4

- name: Install QEMU
uses: docker/setup-qemu-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}

- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
Expand All @@ -49,37 +56,58 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker Qemu Setup
- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ github.event_name == 'workflow_dispatch' }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Export digest
if: github.event_name == 'workflow_dispatch'
run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --use
docker buildx inspect --bootstrap
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Build (${{ matrix.arch }})
if: github.event_name == 'pull_request'
uses: docker/bake-action@v3
- name: Upload digest
uses: actions/upload-artifact@v4
if: github.event_name == 'workflow_dispatch'
with:
files: |
./docker-bake.hcl
workdir: .
set: |
*.cache-to=type=gha,mode=max
*.cache-from=type=gha
push: false
targets: |
${{ matrix.rosdistro }}_base_${{ matrix.arch }}
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

- name: Build and push (${{ matrix.arch }})
if: github.event_name == 'workflow_dispatch'
uses: docker/bake-action@v3
merge:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
files: |
./docker-bake.hcl
workdir: .
set: |
*.cache-to=type=gha,mode=max
*.cache-from=type=gha
*.tags=ghcr.io/tier4/scenario_simulator_v2:humble-${{ github.event.inputs.version }}
push: true
targets: |
${{ matrix.rosdistro }}_base_${{ matrix.arch }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create -t ghcr.io/tier4/scenario_simulator_v2:humble-${{ github.event.inputs.version }} \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
47 changes: 0 additions & 47 deletions Dockerfile.arm64

This file was deleted.

26 changes: 0 additions & 26 deletions docker-bake.hcl

This file was deleted.

0 comments on commit b2d9c7f

Please sign in to comment.