Repository navigation
151 lines (137 loc) · 5.45 KB
/
Copy pathdocker-build-ubi8.yml
File metadata and controls
151 lines (137 loc) · 5.45 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
name: Semoss UBI 8 Builder
on:
push:
branches: [ "dev", "main" ]
paths:
- 'docker/Dockerfile.ubi8'
- '.github/workflows/docker-build-ubi8.yml'
workflow_dispatch:
schedule:
- cron: '18 1 * * *' # Runs every day at 1:18 AM UTC, which is 9:18 PM EDT (8:18 PM EST)
jobs:
# Resolve release/non-release naming once (repo, SEMOSS_VERSION build-arg, tags).
prepare:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.vars.outputs.image }}
semoss_version: ${{ steps.vars.outputs.semoss_version }}
tag_args: ${{ steps.vars.outputs.tag_args }}
primary_tag: ${{ steps.vars.outputs.primary_tag }}
tag_args_fips: ${{ steps.vars.outputs.tag_args_fips }}
primary_tag_fips: ${{ steps.vars.outputs.primary_tag_fips }}
steps:
- name: Determine image, version and tags
id: vars
shell: bash
run: |
if [ "${{ vars.RELEASE }}" = "TRUE" ]; then
IMAGE="quay.io/semoss/semoss"
SV="${{ vars.VERSION }}"
PRIMARY="${IMAGE}:${{ vars.VERSION }}-ubi8"
TAGS="-t ${PRIMARY}"
PRIMARY_FIPS="${IMAGE}:${{ vars.VERSION }}-ubi8-fips"
TAGS_FIPS="-t ${PRIMARY_FIPS}"
else
DATE=$(date +'%Y-%m-%d')
IMAGE="quay.io/semoss/semoss-dev"
SV="${{ vars.VERSION }}-SNAPSHOT"
PRIMARY="${IMAGE}:${{ vars.VERSION }}-SNAPSHOT-ubi8-${DATE}"
TAGS="-t ${PRIMARY} -t ${IMAGE}:${{ vars.VERSION }}-SNAPSHOT-ubi8-latest"
PRIMARY_FIPS="${IMAGE}:${{ vars.VERSION }}-SNAPSHOT-ubi8-fips-${DATE}"
TAGS_FIPS="-t ${PRIMARY_FIPS} -t ${IMAGE}:${{ vars.VERSION }}-SNAPSHOT-ubi8-fips-latest"
fi
echo "image=${IMAGE}" >> "$GITHUB_OUTPUT"
echo "semoss_version=${SV}" >> "$GITHUB_OUTPUT"
echo "tag_args=${TAGS}" >> "$GITHUB_OUTPUT"
echo "primary_tag=${PRIMARY}" >> "$GITHUB_OUTPUT"
echo "tag_args_fips=${TAGS_FIPS}" >> "$GITHUB_OUTPUT"
echo "primary_tag_fips=${PRIMARY_FIPS}" >> "$GITHUB_OUTPUT"
# Build each arch natively (amd64 + arm64 CodeBuild fleets) and push BY DIGEST.
build:
needs: prepare
strategy:
fail-fast: false
matrix:
# Cross-product: (amd64|arm64) x (standard|fips). include entries
# match on arch, so they fill in both fips legs.
fips: [false, true]
arch: [amd64, arm64]
include:
- arch: amd64
platform: linux/amd64
runner_prefix: codebuild-semoss-github-runner
container: quay.io/semoss/test-quay:ubuntu-dind
- arch: arm64
platform: linux/arm64
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 }}
container:
image: ${{ matrix.container }}
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.ubi8
platforms: ${{ matrix.platform }}
pull: true
no-cache: true
build-args: |
SEMOSS_VERSION=${{ needs.prepare.outputs.semoss_version }}
TOMCAT_TAG_SUFFIX=${{ matrix.fips && '-fips' || '' }}
SEMOSS_FIPS=${{ matrix.fips }}
outputs: type=image,name=${{ needs.prepare.outputs.image }},push-by-digest=true,name-canonical=true,push=true
- 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
# Stitch the per-arch digests into one multi-arch tag (no rebuild).
merge:
needs: [ prepare, build ]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
fips: [false, true]
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
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: Create and push manifest list
working-directory: /tmp/digests
run: |
docker buildx imagetools create ${{ matrix.fips && needs.prepare.outputs.tag_args_fips || needs.prepare.outputs.tag_args }} \
$(printf "${{ needs.prepare.outputs.image }}@sha256:%s " *)
- name: Inspect manifest list
run: docker buildx imagetools inspect "${{ matrix.fips && needs.prepare.outputs.primary_tag_fips || needs.prepare.outputs.primary_tag }}"