Skip to content

Commit 103a0af

Browse files
committed
feat: simplify Docker build workflow by removing unused variables and updating multi-arch image handling
1 parent 551e671 commit 103a0af

3 files changed

Lines changed: 6 additions & 60 deletions

File tree

.github/workflows/ci-cd.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ jobs:
3737
DOCKER_PATH_CONTEXT: .
3838
DOCKER_BUILD_DOCKERFILE: ./Dockerfile
3939
DOCKER_TAGS: ${{ vars.DOCKER_USERNAME }}/${{ vars.DOCKER_REPOSITORY }}:${{ github.sha }}
40-
DOCKER_LOAD_BOOL: false
41-
DOCKER_PUSH_BOOL: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
4240
DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }}
4341
secrets: inherit
4442
release:

.github/workflows/docker-build-and-scan.yaml

Lines changed: 6 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,13 @@ on:
1212
DOCKER_TAGS:
1313
required: true
1414
type: string
15-
DOCKER_LOAD_BOOL:
16-
required: false
17-
type: boolean
18-
default: false
19-
DOCKER_PUSH_BOOL:
20-
required: false
21-
type: boolean
22-
default: false
2315
DOCKER_USERNAME:
2416
required: true
2517
type: string
26-
DOCKER_PLATFORMS:
27-
required: false
28-
type: string
29-
default: 'linux/amd64,linux/arm64'
3018

3119
jobs:
32-
build:
20+
build-and-scan:
3321
runs-on: ubuntu-latest
34-
strategy:
35-
matrix:
36-
include:
37-
- platform: linux/amd64
38-
suffix: linux-amd64
39-
- platform: linux/arm64
40-
suffix: linux-arm64
4122
env:
4223
DOCKER_PATH_CONTEXT: ${{ inputs.DOCKER_PATH_CONTEXT }}
4324
DOCKER_BUILD_DOCKERFILE: ${{ inputs.DOCKER_BUILD_DOCKERFILE }}
@@ -51,50 +32,20 @@ jobs:
5132
with:
5233
username: ${{ env.DOCKER_USERNAME }}
5334
password: ${{ secrets.DOCKERHUB_TOKEN }}
54-
- name: Build & push per-arch image
35+
- name: Build & push multi-arch image
5536
uses: docker/build-push-action@v7
5637
with:
5738
context: ${{ env.DOCKER_PATH_CONTEXT }}
5839
file: ${{ env.DOCKER_BUILD_DOCKERFILE }}
59-
platforms: ${{ matrix.platform }}
40+
platforms: linux/amd64,linux/arm64
6041
push: true
61-
tags: docker.io/${{ env.DOCKER_TAGS }}-${{ matrix.suffix }}
62-
- name: Wait for image to be available in Docker Hub
63-
run: |
64-
for i in {1..20}; do
65-
if docker buildx imagetools inspect docker.io/${{ env.DOCKER_TAGS }}-${{ matrix.suffix }} > /dev/null 2>&1; then
66-
echo "Image found!"
67-
exit 0
68-
fi
69-
echo "Waiting for image to be available... ($i)"
70-
sleep 6
71-
done
72-
echo "Image not found after waiting. Exiting."
73-
exit 1
74-
- name: Run Trivy vulnerability scanner (per-arch)
42+
tags: docker.io/${{ env.DOCKER_TAGS }}
43+
- name: Run Trivy vulnerability scanner (multi-arch manifest)
7544
uses: aquasecurity/trivy-action@0.35.0
7645
with:
77-
image-ref: docker.io/${{ env.DOCKER_TAGS }}-${{ matrix.suffix }}
46+
image-ref: docker.io/${{ env.DOCKER_TAGS }}
7847
format: 'table'
7948
exit-code: '1'
8049
ignore-unfixed: true
8150
vuln-type: 'os,library'
8251
severity: 'CRITICAL,HIGH'
83-
84-
manifest:
85-
runs-on: ubuntu-latest
86-
needs: build
87-
env:
88-
DOCKER_TAGS: ${{ inputs.DOCKER_TAGS }}
89-
DOCKER_USERNAME: ${{ inputs.DOCKER_USERNAME }}
90-
steps:
91-
- uses: docker/login-action@v4
92-
with:
93-
username: ${{ env.DOCKER_USERNAME }}
94-
password: ${{ secrets.DOCKERHUB_TOKEN }}
95-
- name: Create and push multi-arch manifest
96-
run: |
97-
docker buildx imagetools create \
98-
-t docker.io/${{ env.DOCKER_TAGS }} \
99-
docker.io/${{ env.DOCKER_TAGS }}-linux-amd64 \
100-
docker.io/${{ env.DOCKER_TAGS }}-linux-arm64

.github/workflows/release.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,5 @@ jobs:
9393
with:
9494
DOCKER_PATH_CONTEXT: ${{ inputs.DOCKER_PATH_CONTEXT }}
9595
DOCKER_BUILD_DOCKERFILE: ${{ inputs.DOCKER_BUILD_DOCKERFILE }}
96-
DOCKER_LOAD_BOOL: false
9796
DOCKER_TAGS: ${{ inputs.DOCKER_USERNAME }}/${{ inputs.DOCKER_REPOSITORY }}:${{ needs.Semantic-Release.outputs.tag }}
98-
DOCKER_PUSH_BOOL: true
9997
DOCKER_USERNAME: ${{ inputs.DOCKER_USERNAME }}
100-
DOCKER_PLATFORMS: '["linux/amd64","linux/arm64"]'

0 commit comments

Comments
 (0)