Skip to content

Commit

Permalink
build images also for arm64 (#168)
Browse files Browse the repository at this point in the history
* build images also for arm64

* add extended build steps to prepare env for multi build

* use Vox Pupulis container action

* update container gha to latest version

* update to v1 instead of commit id

* ci only build x86_64 to showcase that container build is working at all

* disable container scanning
  • Loading branch information
rwaffen authored Sep 20, 2023
1 parent c575982 commit d1a33d4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 55 deletions.
49 changes: 5 additions & 44 deletions .github/workflows/build_docker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: publish 🐳 Docker image
name: Build and publish a 🛢️ container

on:
push:
Expand All @@ -10,52 +10,13 @@ on:
- '*'

jobs:
build-and-push-image:
build-and-push-container:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get tags
shell: python
run: |
import re
import os
from packaging.version import parse
image = "ghcr.io/${{ github.repository }}"
tags = set()
version = "${{ github.ref_name }}"
if version.startswith('v'):
version = "${{ github.ref_name }}".replace("v", "")
tags.add(f"{image}:latest")
if version == 'main':
version = "development"
tags.add(f"{image}:{version}")
tags = ",".join(sorted(list(tags)))
with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
print(f'tags={tags}', file=fh)
id: tags

- name: Build and push
uses: docker/build-push-action@v5
- uses: voxpupuli/gha-build-and-publish-a-container@v1
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.tags.outputs.tags }}
github_token: ${{ secrets.GITHUB_TOKEN }}
build_arch: linux/amd64,linux/arm64
27 changes: 16 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,26 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
tags: 'ci/hdm:${{ github.sha }}'
# tags: 'ci/hdm:${{ github.sha }}'
platforms: linux/amd64
push: false

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: 'ci/hdm:${{ github.sha }}'
format: 'sarif'
output: 'trivy-results.sarif'
# - name: Run Trivy vulnerability scanner
# uses: aquasecurity/trivy-action@master
# with:
# image-ref: 'ci/hdm:${{ github.sha }}'
# format: 'sarif'
# output: 'trivy-results.sarif'

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'
# - name: Upload Trivy scan results to GitHub Security tab
# uses: github/codeql-action/upload-sarif@v2
# with:
# sarif_file: 'trivy-results.sarif'

0 comments on commit d1a33d4

Please sign in to comment.