-
Notifications
You must be signed in to change notification settings - Fork 4
144 lines (131 loc) · 5.09 KB
/
Copy pathcpp-libs.yaml
File metadata and controls
144 lines (131 loc) · 5.09 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
# SPDX-FileCopyrightText: 2026 European Centre for Medium-Range Weather Forecasts (ECMWF)
#
# SPDX-License-Identifier: Apache-2.0
# Builds and publishes the C++ library base images under docker/cpp-libs/ to
# ECCR. App images pull these by pinned tag instead of compiling C++.
#
# To bump a library stack:
# 1. Update the version ARGs in docker/cpp-libs/<name>/Dockerfile
# 2. Set a new tag in docker/cpp-libs/<name>/TAG (tags are immutable)
# 3. Run this workflow (workflow_dispatch) to publish the image
# 4. Update the *_LIBS_IMAGE ARG default in the consuming Dockerfile
name: C++ library images
# PRs touching docker/cpp-libs/ run the lint job only (Dockerfile validation,
# no build — the C++ stacks take too long for PR CI). Publishing is always
# manual:
# gh workflow run cpp-libs.yaml -f image=all
on:
pull_request:
paths:
- "docker/cpp-libs/**"
- ".github/workflows/cpp-libs.yaml"
workflow_dispatch:
inputs:
image:
description: Library image to build and push
type: choice
default: all
options:
- all
- metkit
- fdb
- fdb-gribjump
- mars
permissions:
contents: read
jobs:
# Static Dockerfile validation only — building the images is deliberately not
# part of PR CI (hours of C++ compilation).
lint:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
name: [metkit, fdb, fdb-gribjump, mars]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Validate Dockerfile
run: docker buildx build --check "docker/cpp-libs/${{ matrix.name }}"
publish:
# Builds and pushes via skaffold (docker/cpp-libs/skaffold.yaml), matching
# how the application images are built.
if: github.event_name == 'workflow_dispatch'
name: Publish ${{ matrix.name }}
runs-on: ubuntu-latest
timeout-minutes: 180
strategy:
fail-fast: false
max-parallel: 2
matrix:
include:
- name: metkit
image: eccr.ecmwf.int/polytope/cpp-metkit-libs
- name: fdb
image: eccr.ecmwf.int/polytope/cpp-fdb-libs
- name: fdb-gribjump
image: eccr.ecmwf.int/polytope/cpp-fdb-gribjump-libs
- name: mars
image: eccr.ecmwf.int/polytope/cpp-mars-libs
needs_token: "true"
env:
RPM_REPO: https://nexus.ecmwf.int/repository
SKAFFOLD_SHA256: 8f62095ba8c282c03ad7b4987fbaf4f29b289fd6cbafb0351effd49f73f0240d
SKAFFOLD_VERSION: v2.18.0
SELECTED: ${{ inputs.image == 'all' || inputs.image == matrix.name }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: env.SELECTED == 'true'
with:
persist-credentials: false
- name: Read image tag
if: env.SELECTED == 'true'
id: tag
run: echo "tag=$(cat "docker/cpp-libs/${{ matrix.name }}/TAG")" >> "$GITHUB_OUTPUT"
- name: Prepare repository token
if: env.SELECTED == 'true' && matrix.needs_token == 'true'
env:
RAW_GH_TOKEN: ${{ secrets.GH_REPO_READ_TOKEN }}
run: |
token="$(printf '%s' "$RAW_GH_TOKEN" | tr -d '[:space:]')"
echo "::add-mask::$token"
echo "GH_TOKEN=$token" >> "$GITHUB_ENV"
- name: Install Skaffold
if: env.SELECTED == 'true'
run: |
curl -fsSL "https://storage.googleapis.com/skaffold/releases/${SKAFFOLD_VERSION}/skaffold-linux-amd64" -o skaffold
echo "${SKAFFOLD_SHA256} skaffold" | sha256sum --check -
sudo install skaffold /usr/local/bin/skaffold
- name: Log in to ECCR
if: env.SELECTED == 'true'
env:
ECCR_PASSWORD: ${{ secrets.ECCR_PASSWORD }}
ECCR_USERNAME: ${{ secrets.ECCR_USERNAME }}
run: printf '%s' "$ECCR_PASSWORD" | docker login eccr.ecmwf.int --username "$ECCR_USERNAME" --password-stdin
- name: Refuse to overwrite an existing image
if: env.SELECTED == 'true'
env:
IMAGE: ${{ matrix.image }}
TAG: ${{ steps.tag.outputs.tag }}
run: |
for img in "${IMAGE}" "${IMAGE}-debug"; do
if docker manifest inspect "${img}:${TAG}" >/dev/null 2>&1; then
echo "${img}:${TAG} already exists; library image tags are immutable" >&2
exit 1
fi
done
# Skaffold resolves each artifact's context (e.g. `metkit`) relative to the
# current working directory, not to skaffold.yaml, so run from docker/cpp-libs.
# Builds both the stripped default image and its `-debug` (full-symbol) companion.
- name: Build and publish ${{ matrix.name }}
if: env.SELECTED == 'true'
env:
FIXED_TAG: ${{ steps.tag.outputs.tag }}
working-directory: docker/cpp-libs
run: |
skaffold build --push=true \
--filename skaffold.yaml \
--build-image "${{ matrix.image }}" \
--build-image "${{ matrix.image }}-debug"