-
Notifications
You must be signed in to change notification settings - Fork 226
199 lines (179 loc) · 8.95 KB
/
build-base-images.yml
File metadata and controls
199 lines (179 loc) · 8.95 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: Build Base Images
# Builds and publishes shared base images to GHCR.
#
# Base images are heavy-dependency layers (Nmap compiled from source,
# RustScan, PowerShell, pre-built Go binaries) that would otherwise be
# rebuilt redundantly inside every application container build.
#
# Triggers:
# - Push to main when base-images/** files change
# - Manual dispatch (for emergency rebuilds)
# - Weekly schedule to pick up upstream security patches
on:
push:
branches: [main]
paths:
- "base-images/**"
workflow_dispatch:
inputs:
image:
description: "Which base image to rebuild"
required: false
default: "all"
type: choice
options:
- all
- go-builder
- engine-tools
schedule:
# Every Sunday at 04:00 UTC
- cron: "0 4 * * 0"
env:
REGISTRY: ghcr.io
IMAGE_NAMESPACE: siriusscan
jobs:
# ─────────────────────────────────────────────────────────────────────────────
# Build go-builder base image (per architecture, native runners)
# ─────────────────────────────────────────────────────────────────────────────
build-go-builder:
name: "go-builder (${{ matrix.platform }})"
if: >
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch' && (github.event.inputs.image == 'all' || github.event.inputs.image == 'go-builder') ||
github.event_name == 'push'
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
platform: [amd64, arm64]
include:
- platform: amd64
runner: blacksmith-4vcpu-ubuntu-2404
- platform: arm64
runner: blacksmith-4vcpu-ubuntu-2404-arm
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Blacksmith Builder
uses: useblacksmith/setup-docker-builder@v1
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.GHCR_PUSH_USER }}
password: ${{ secrets.GHCR_PUSH_TOKEN }}
- name: Build and push go-builder (${{ matrix.platform }})
uses: useblacksmith/build-push-action@v2
with:
context: ./base-images/go-builder
platforms: linux/${{ matrix.platform }}
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/sirius-base-go-builder:latest-${{ matrix.platform }}
# ─────────────────────────────────────────────────────────────────────────────
# Merge go-builder arch-specific images into a single multi-arch manifest
# ─────────────────────────────────────────────────────────────────────────────
merge-go-builder:
name: "go-builder (merge manifest)"
needs: build-go-builder
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.GHCR_PUSH_USER }}
password: ${{ secrets.GHCR_PUSH_TOKEN }}
- name: Create and push multi-arch manifest for go-builder
run: |
# Blacksmith build-push-action outputs manifest lists (with provenance);
# docker manifest create cannot nest those. Use buildx imagetools create instead.
docker buildx imagetools create -t \
${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/sirius-base-go-builder:latest \
${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/sirius-base-go-builder:latest-amd64 \
${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/sirius-base-go-builder:latest-arm64
echo "Published ghcr.io/${{ env.IMAGE_NAMESPACE }}/sirius-base-go-builder:latest (amd64 + arm64)"
- name: Verify go-builder tags resolve
run: |
set -e
BASE="${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/sirius-base-go-builder"
for TAG in latest latest-amd64 latest-arm64; do
echo "Verifying ${BASE}:${TAG}"
docker manifest inspect "${BASE}:${TAG}" > /dev/null
done
# ─────────────────────────────────────────────────────────────────────────────
# Build engine-tools base image (per architecture, native runners)
#
# NOTE: This job intentionally uses docker/setup-buildx-action (standard
# BuildKit) instead of useblacksmith/setup-docker-builder. The Nmap
# compilation from source generates large amounts of intermediate object
# files that fill the Blacksmith sticky disk, causing the overlay
# filesystem to go read-only mid-build. Standard BuildKit uses the
# runner's main disk which has ample free space for large compilations.
# ─────────────────────────────────────────────────────────────────────────────
build-engine-tools:
name: "engine-tools (${{ matrix.platform }})"
if: >
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch' && (github.event.inputs.image == 'all' || github.event.inputs.image == 'engine-tools') ||
github.event_name == 'push'
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
platform: [amd64, arm64]
include:
- platform: amd64
runner: blacksmith-4vcpu-ubuntu-2404
- platform: arm64
runner: blacksmith-4vcpu-ubuntu-2404-arm
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx (standard, not Blacksmith sticky disk)
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.GHCR_PUSH_USER }}
password: ${{ secrets.GHCR_PUSH_TOKEN }}
- name: Build and push engine-tools (${{ matrix.platform }})
uses: docker/build-push-action@v6
with:
context: ./base-images/engine-tools
platforms: linux/${{ matrix.platform }}
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/sirius-base-engine-tools:latest-${{ matrix.platform }}
# ─────────────────────────────────────────────────────────────────────────────
# Merge engine-tools arch-specific images into a single multi-arch manifest
# ─────────────────────────────────────────────────────────────────────────────
merge-engine-tools:
name: "engine-tools (merge manifest)"
needs: build-engine-tools
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.GHCR_PUSH_USER }}
password: ${{ secrets.GHCR_PUSH_TOKEN }}
- name: Create and push multi-arch manifest for engine-tools
run: |
# docker/build-push-action outputs manifest lists (with provenance);
# docker manifest create cannot nest those. Use buildx imagetools create instead.
docker buildx imagetools create -t \
${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/sirius-base-engine-tools:latest \
${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/sirius-base-engine-tools:latest-amd64 \
${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/sirius-base-engine-tools:latest-arm64
echo "Published ghcr.io/${{ env.IMAGE_NAMESPACE }}/sirius-base-engine-tools:latest (amd64 + arm64)"
- name: Verify engine-tools tags resolve
run: |
set -e
BASE="${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/sirius-base-engine-tools"
for TAG in latest latest-amd64 latest-arm64; do
echo "Verifying ${BASE}:${TAG}"
docker manifest inspect "${BASE}:${TAG}" > /dev/null
done