Repository navigation
214 lines (200 loc) · 9.27 KB
/
Copy pathtomcat-builder.yml
File metadata and controls
214 lines (200 loc) · 9.27 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
name: Tomcat Builder
on:
workflow_dispatch:
inputs:
version:
description: 'Tomcat Version to deploy'
required: true
default: '11.0.29'
push:
branches: [ "dev", "main" ]
paths:
- 'docker/Dockerfile.tomcat'
- '.github/workflows/tomcat-builder.yml'
env:
IMAGE: quay.io/semoss/tomcat-builder
jobs:
# ---------------------------------------------------------------------------
# Build each architecture on its OWN native runner and push the result to the
# registry BY DIGEST (no tag yet). amd64 and arm64 build on their own
# CodeBuild fleets - no QEMU emulation, so each builds at full speed in
# parallel.
#
# PREREQUISITE: the arm64 leg only succeeds once Dockerfile.tomcat is
# architecture-aware. Today the Zulu JDK is installed by install_java.sh (in
# the semoss-artifacts repo); it must select the aarch64 tarball when
# TARGETARCH=arm64 or this leg fails.
# ---------------------------------------------------------------------------
build:
strategy:
fail-fast: false
matrix:
# Cross-product: 4 jobs (amd64|arm64) x (standard|fips). The include
# entries match on `arch`, so they fill in platform/runner/uname_arch for
# both fips values rather than adding extra jobs.
# CodeBuild fleets like the image builders: anonymous base-image pulls from
# public.ecr.aws hit "429 Data limit exceeded" on GitHub-hosted runners.
fips: [false, true]
arch: [amd64, arm64]
include:
- arch: amd64
platform: linux/amd64
uname_arch: x86_64
runner_prefix: codebuild-semoss-github-runner
container: quay.io/semoss/test-quay:ubuntu-dind
- arch: arm64
platform: linux/arm64
uname_arch: aarch64
runner_prefix: codebuild-semoss-github-runner-arm64
container: quay.io/semoss/test-quay:ubuntu-dind-arm64
runs-on: ${{ matrix.runner_prefix }}-${{ github.run_id }}-${{ github.run_attempt }}
# A healthy leg takes ~4 min; fail fast instead of hanging on a stalled download.
timeout-minutes: 20
container:
image: ${{ matrix.container }}
env:
TOMCAT_VERSION: ${{ github.event.inputs.version || '11.0.29' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Quay
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_ROBOT_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_PASSWORD }}
- name: Build and push by digest (${{ matrix.platform }})
id: build
uses: docker/build-push-action@v6
with:
context: ./docker
file: ./docker/Dockerfile.tomcat
platforms: ${{ matrix.platform }}
build-args: |
TOMCAT_VERSION=${{ env.TOMCAT_VERSION }}
BASE_REGISTRY=public.ecr.aws/docker/library
FIPS_ENABLED=${{ matrix.fips }}
# push-by-digest: publish the blobs + per-arch manifest, but DO NOT tag.
# The merge job stitches the digests into a single tagged manifest list.
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true
# The Java version comes from the ARG defaults in Dockerfile.tomcat, not from
# this workflow, so assert what actually landed in the image.
- name: Verify builder image
shell: bash
run: |
set -euo pipefail
image_ref="${IMAGE}@${{ steps.build.outputs.digest }}"
docker pull "$image_ref"
docker run --rm --entrypoint bash "$image_ref" -c '
set -euo pipefail
test "$JAVA_HOME" = "/usr/lib/jvm/zulu25"
test "$(uname -m)" = "${{ matrix.uname_arch }}"
java -version 2>&1 | grep -q "openjdk version \"25\."
mvn -version | grep -q "Java version: 25\."
# TOMCAT_HOME must survive into the final stage. If it is empty then
# $TOMCAT_HOME/bin drops out of PATH, catalina.sh and start.sh become
# unreachable, and WORKDIR points at /webapps.
test -n "$TOMCAT_HOME"
test -d "$TOMCAT_HOME/bin"
test -x "$TOMCAT_HOME/bin/catalina.sh"
command -v start.sh >/dev/null
if [ "${{ matrix.fips }}" = "true" ]; then
test -d "$JAVA_HOME/lib/fips"
test -f "$JAVA_HOME/lib/security/cacerts.bcfks"
grep -q "^security.provider.1=org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider" "$JAVA_HOME/conf/security/java.security.fips"
grep -q "^security.provider.2=org.bouncycastle.jsse.provider.BouncyCastleJsseProvider" "$JAVA_HOME/conf/security/java.security.fips"
# TLS defaults. SunX509 is a SunJSSE-only algorithm name and BCFKS
# is a BCFIPS-only store type, so leaving either default in place
# breaks TLS at first use rather than at startup. Exactly one line
# each - a stale JDK default left behind would still match a plain
# grep and win, since the last assignment is the one that applies.
sec_fips="$JAVA_HOME/conf/security/java.security.fips"
test "$(grep -c "^ssl.KeyManagerFactory.algorithm=" "$sec_fips")" = 1
test "$(grep -c "^ssl.TrustManagerFactory.algorithm=" "$sec_fips")" = 1
grep -q "^ssl.KeyManagerFactory.algorithm=PKIX$" "$sec_fips"
grep -q "^ssl.TrustManagerFactory.algorithm=PKIX$" "$sec_fips"
grep -q "javax.net.ssl.trustStoreProvider=BCFIPS" "$TOMCAT_HOME/bin/setenv.sh"
grep -q "approved_only=true" "$TOMCAT_HOME/bin/setenv.sh"
grep -q "java.security.properties==" "$TOMCAT_HOME/bin/setenv.sh"
# the JDK default must stay usable or Maven, keytool and the
# Playwright installer lose TLS inside the image build
grep -q "^security.provider.1=SUN" "$JAVA_HOME/conf/security/java.security"
mvn -B -q -version >/dev/null
echo "FIPS variant verified"
else
# The standard image must carry NO FIPS artifacts at all, otherwise
# FIPS_ENABLED is leaking and the two tags are not really distinct.
test ! -e "$JAVA_HOME/lib/fips"
test ! -e "$JAVA_HOME/lib/security/cacerts.bcfks"
test ! -e "$JAVA_HOME/conf/security/java.security.fips"
! grep -q "BouncyCastleFipsProvider" "$JAVA_HOME/conf/security/java.security"
! grep -q "approved_only" "$TOMCAT_HOME/bin/setenv.sh"
! grep -q "trustStoreProvider" "$TOMCAT_HOME/bin/setenv.sh"
echo "standard variant verified clean"
fi
'
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.fips }}-${{ matrix.arch }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
# ---------------------------------------------------------------------------
# Combine the per-arch digests into ONE manifest list and apply the tag(s).
# This does not rebuild anything; it just writes the index that makes the tag
# multi-arch, so `docker pull <tag>` auto-selects amd64 or arm64.
# ---------------------------------------------------------------------------
merge:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
fips: [false, true]
env:
TOMCAT_VERSION: ${{ github.event.inputs.version || '11.0.29' }}
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
# Only this variant's digests, or the two tags would point at a mixed
# manifest list containing both FIPS and standard images.
pattern: digests-${{ matrix.fips }}-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Quay
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_ROBOT_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_PASSWORD }}
- name: Compute tags
id: meta
shell: bash
run: |
SUFFIX=""
if [[ "${{ matrix.fips }}" == "true" ]]; then SUFFIX="-fips"; fi
TAGS=( "-t" "${IMAGE}:${TOMCAT_VERSION}${SUFFIX}" )
if [[ "${{ vars.RELEASE }}" == "TRUE" ]]; then
TAGS+=( "-t" "${IMAGE}:${TOMCAT_VERSION}-${{ vars.VERSION }}${SUFFIX}" )
fi
echo "args=${TAGS[*]}" >> "$GITHUB_OUTPUT"
echo "primary=${IMAGE}:${TOMCAT_VERSION}${SUFFIX}" >> "$GITHUB_OUTPUT"
- name: Create and push manifest list
working-directory: /tmp/digests
run: |
docker buildx imagetools create ${{ steps.meta.outputs.args }} \
$(printf "${IMAGE}@sha256:%s " *)
- name: Inspect manifest list
run: docker buildx imagetools inspect "${{ steps.meta.outputs.primary }}"