-
-
Notifications
You must be signed in to change notification settings - Fork 17
110 lines (100 loc) · 3.64 KB
/
docker-image.yml
File metadata and controls
110 lines (100 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: Build and Push Multi-Arch Docker Images
on:
push:
branches: [ main ]
paths-ignore:
- '**.md'
- 'docs/**'
release:
types: [ published ]
env:
DOCKER_TAG: ${{ github.ref_type == 'tag' && github.ref_name || 'latest' }}
SERVICES: plc router workstation simulation scadalts attacker caldera
jobs:
# ================================================================
# Build AMD64 images
# ================================================================
build-amd64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
lfs: true
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push amd64 images
run: |
set -euo pipefail
for SERVICE in $SERVICES; do
IMAGE="${{ secrets.DOCKERHUB_USERNAME }}/grfics-${SERVICE}"
echo "🚀 Building ${IMAGE}:${DOCKER_TAG} (amd64)"
docker buildx build \
--platform linux/amd64 \
--tag "${IMAGE}:amd64" \
--push \
--cache-from type=gha \
--cache-to type=gha,mode=max \
"./${SERVICE}"
echo "🧹 Cleaning local build cache to free space..."
docker builder prune -af || true
docker system prune -af || true
done
# ================================================================
# Build ARM64 images
# ================================================================
build-arm64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
lfs: true
- uses: docker/setup-qemu-action@v3 # enables ARM emulation
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push arm64 images
run: |
set -euo pipefail
for SERVICE in $SERVICES; do
IMAGE="${{ secrets.DOCKERHUB_USERNAME }}/grfics-${SERVICE}"
echo "🚀 Building ${IMAGE}:${DOCKER_TAG} (arm64)"
docker buildx build \
--platform linux/arm64 \
--tag "${IMAGE}:arm64" \
--push \
--cache-from type=gha \
--cache-to type=gha,mode=max \
"./${SERVICE}"
echo "🧹 Cleaning local build cache to free space..."
docker builder prune -af || true
docker system prune -af || true
done
# ================================================================
# Combine manifests once both architectures exist
# ================================================================
create-manifests:
runs-on: ubuntu-latest
needs: [ build-amd64, build-arm64 ]
steps:
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create and push multi-arch manifests
run: |
set -euo pipefail
for SERVICE in $SERVICES; do
IMAGE="${{ secrets.DOCKERHUB_USERNAME }}/grfics-${SERVICE}:${DOCKER_TAG}"
echo "🔗 Creating multi-arch manifest for ${IMAGE}"
docker buildx imagetools create \
-t "${IMAGE}" \
"${IMAGE%:*}:amd64" \
"${IMAGE%:*}:arm64"
echo "✅ Multi-arch manifest published for ${IMAGE}"
done