Skip to content

Commit 063cca0

Browse files
authored
Add xrplf/ci/gcc containers (#54)
This change creates new containers named like `xrplf/ci/gcc:${GCC_VERSION}-${DEBIAN_VERSION}` supporting Debian Bullseye, to be reused by `xrplf/ci/debian` images.
1 parent 52d2ae6 commit 063cca0

File tree

9 files changed

+741
-34
lines changed

9 files changed

+741
-34
lines changed

.github/workflows/gcc.yml

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
name: GCC
2+
3+
on:
4+
push:
5+
paths:
6+
- .github/workflows/gcc.yml
7+
- docker/gcc/Dockerfile*
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
defaults:
15+
run:
16+
shell: bash
17+
18+
env:
19+
CONTAINER_REGISTRY: ghcr.io
20+
BUILDKIT_PROGRESS: plain
21+
22+
jobs:
23+
# Build the Docker image for Debian using different versions of GCC and Clang.
24+
# Note, the `os` part of matrix must be kept in sync with the `merge` job below
25+
build:
26+
strategy:
27+
matrix:
28+
architecture:
29+
- platform: linux/amd64
30+
runner: ubuntu-24.04
31+
- platform: linux/arm64
32+
runner: ubuntu-24.04-arm
33+
os:
34+
- release: bullseye
35+
compiler_version: 12
36+
- release: bullseye
37+
compiler_version: 13
38+
- release: bullseye
39+
compiler_version: 14
40+
- release: bullseye
41+
compiler_version: 15
42+
runs-on: ${{ matrix.architecture.runner }}
43+
permissions:
44+
packages: write
45+
steps:
46+
- name: Checkout repository
47+
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
48+
- name: Set up Docker Buildx
49+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
50+
- name: Login to GitHub Registry
51+
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
52+
with:
53+
registry: ${{ env.CONTAINER_REGISTRY }}
54+
username: ${{ github.repository_owner }}
55+
password: ${{ secrets.GITHUB_TOKEN }}
56+
- name: Prepare environment
57+
run: |
58+
GITHUB_REPO=${{ github.repository }}
59+
CONTAINER_REPO=${GITHUB_REPO@L}
60+
PLATFORM=${{ matrix.architecture.platform }}
61+
echo "PLATFORM_PAIR=${PLATFORM//\//-}" >> $GITHUB_ENV
62+
echo "CONTAINER_REPOSITORY=${CONTAINER_REPO}/gcc" >> $GITHUB_ENV
63+
echo "CONTAINER_IMAGE=${CONTAINER_REGISTRY}/${CONTAINER_REPO}/gcc" >> $GITHUB_ENV
64+
- name: Prepare image metadata
65+
id: meta
66+
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
67+
env:
68+
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,manifest-descriptor
69+
with:
70+
images: ${{ env.CONTAINER_IMAGE }}
71+
tags: |
72+
type=raw,value=${{ matrix.os.compiler_version }}-${{matrix.os.release}}
73+
type=sha,prefix=${{ matrix.os.compiler_version }}-${{matrix.os.release}}-sha-
74+
labels: |
75+
org.opencontainers.image.authors=For inquiries, please use https://${{ github.repository }}/issues
76+
org.opencontainers.image.documentation=https://${{ github.repository }}
77+
org.opencontainers.image.vendor=XRPLF
78+
org.opencontainers.image.title=${{ env.CONTAINER_REPOSITORY }}
79+
- name: Build image
80+
if: ${{ env.CONTAINER_IMAGE }}
81+
id: build
82+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
83+
with:
84+
build-args: |
85+
BUILDKIT_DOCKERFILE_CHECK=skip=InvalidDefaultArgInFrom
86+
BUILDKIT_INLINE_CACHE=1
87+
context: .
88+
file: docker/gcc/Dockerfile.${{ matrix.os.compiler_version }}-${{ matrix.os.release }}
89+
labels: ${{ steps.meta.outputs.labels }}
90+
outputs: type=image,name=${{ env.CONTAINER_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
91+
platforms: ${{ matrix.architecture.platform }}
92+
provenance: mode=max
93+
push: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
94+
sbom: true
95+
- name: Export digest
96+
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
97+
run: |
98+
mkdir -p /tmp/digests
99+
DIGEST="${{ steps.build.outputs.digest }}"
100+
touch "/tmp/digests/${DIGEST#sha256:}"
101+
- name: Upload digest
102+
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
103+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
104+
with:
105+
name: digests-${{ matrix.os.compiler_version }}-${{ matrix.os.release }}-${{ env.PLATFORM_PAIR }}
106+
path: /tmp/digests/*
107+
if-no-files-found: error
108+
retention-days: 1
109+
110+
merge:
111+
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
112+
strategy:
113+
matrix:
114+
os:
115+
- release: bullseye
116+
compiler_version: 12
117+
- release: bullseye
118+
compiler_version: 13
119+
- release: bullseye
120+
compiler_version: 14
121+
- release: bullseye
122+
compiler_version: 15
123+
runs-on: ubuntu-24.04
124+
needs:
125+
- build
126+
permissions:
127+
packages: write
128+
steps:
129+
- name: Checkout repository
130+
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
131+
- name: Download digests
132+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
133+
with:
134+
path: /tmp/digests
135+
pattern: digests-${{ matrix.os.compiler_version }}-${{ matrix.os.release }}-*
136+
merge-multiple: true
137+
- name: Set up Docker Buildx
138+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
139+
- name: Login to GitHub Registry
140+
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
141+
with:
142+
registry: ${{ env.CONTAINER_REGISTRY }}
143+
username: ${{ github.repository_owner }}
144+
password: ${{ secrets.GITHUB_TOKEN }}
145+
- name: Prepare environment
146+
run: |
147+
GITHUB_REPO=${{ github.repository }}
148+
CONTAINER_REPO=${GITHUB_REPO@L}
149+
echo "CONTAINER_IMAGE=${CONTAINER_REGISTRY}/${CONTAINER_REPO}/gcc" >> $GITHUB_ENV
150+
- name: Prepare container metadata
151+
id: meta
152+
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
153+
env:
154+
DOCKER_METADATA_ANNOTATIONS_LEVELS: index
155+
with:
156+
images: ${{ env.CONTAINER_IMAGE }}
157+
tags: |
158+
type=raw,value=${{ matrix.os.compiler_version }}-${{matrix.os.release}}
159+
type=sha,prefix=${{ matrix.os.compiler_version }}-${{matrix.os.release}}-sha-
160+
- name: Create manifest list and push
161+
working-directory: /tmp/digests
162+
run: |
163+
eval "docker buildx imagetools create \
164+
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
165+
$(jq -cr '.annotations | map("--annotation \"" + . + "\"") | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
166+
$(printf '${{ env.CONTAINER_IMAGE }}@sha256:%s ' *)"
167+
- name: Inspect image
168+
run: |
169+
docker buildx imagetools inspect ${{ env.CONTAINER_IMAGE }}:${{ steps.meta.outputs.version }}

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,20 @@ of environments and using different C++ compilers.
1919

2020
Only some of the container images provided support packaging.
2121

22+
## Compiler images
23+
24+
Container images created by `gcc` workflow are a [backport](https://github.com/docker-library/gcc) of
25+
official Docker images for [GNU Compiler Collection](https://hub.docker.com/_/gcc). The official images
26+
are built on a most recent official Debian release, which results in coupling to a higher
27+
[GLIBC](https://sourceware.org/glibc/) version than the versions which we want to support.
28+
The purpose of `gcc` images created in this repository is to provide most recent releases of
29+
the GCC compiler for older Debian (and derived distros) versions. These are in turn used
30+
by some of the Debian [build images](#build-images).
31+
2232
## Tools images
2333

24-
Aside from build images, XRPLF projects also use container images with specialized tools, e.g.
25-
to enforce code formatting, run sanitizers, run code coverage tools etc.
34+
Aside from build and compiler images, XRPLF projects also use container images with specialized tools,
35+
e.g. to enforce code formatting, run sanitizers etc.
2636
The required images are created by workflows starting with `tools-` and ending
2737
with the project name e.g. `tools-rippled`, and are only meant to support specific projects.
2838
These images may also contain a complete C++ build environment, if needed.

docker/debian/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
# the `COPY --from XXX` command used in a stage below does not allow `XXX` to
33
# contain dynamic values supplied via an argument. We are using GCC image rather
44
# than the official Debian package to access the latest versions, built by the
5-
# GCC team specifically for this Debian release. For build images using official
6-
# distribution packages, see Ubuntu. We set the GCC version to "undefined" to
7-
# satisfy the syntax checker, as it checks if the `FROM` command has a valid
5+
# [Docker community](https://github.com/docker-library/gcc/), or by [us](docker/gcc),
6+
# specifically for this Debian release. For build images using the official
7+
# distribution packages, see Ubuntu. We set the GCC version to "undefined"
8+
# to satisfy the syntax checker, as it checks if the `FROM` command has a valid
89
# image, even though it is not used for Clang.
910
ARG DEBIAN_VERSION
1011
ARG GCC_VERSION=undefined

docker/debian/README.md

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,42 +24,29 @@ docker login ${CONTAINER_REGISTRY} -u "${GITHUB_USER}" --password-stdin
2424

2525
### Building and pushing the Docker image
2626

27-
The same Dockerfile can be used to build an image for Debian Bookworm or future
28-
versions by specifying the `DEBIAN_VERSION` build argument. There are additional
27+
The same Dockerfile can be used to build an image for different Debian releases
28+
by specifying the `DEBIAN_VERSION` build argument. There are additional
2929
arguments to specify as well, namely `GCC_VERSION` for the GCC flavor and
3030
`CLANG_VERSION` for the Clang flavor.
3131

3232
Build image for `gcc` supports packaging.
3333

34-
In order to build an image, run the commands below from the root directory of
35-
the repository.
36-
37-
#### Note on old Debian releases
38-
39-
This image supports variety of releases of Debian, GCC and Clang.
40-
41-
The GCC binaries are sourced from [Docker "Official Image" for gcc](https://github.com/docker-library/gcc)
42-
with an important caveat - in order to install a GCC release in older
43-
Debian versions, we keep a local copy of `Dockerfile` from the above repository,
44-
backported to an older Debian base image. Such dockerfiles are stored in this
45-
directory with special file extension, e.g. `gcc-12-bullseye`. They are not altered from
46-
the source, except for change of the base image to older Debian version. They also
47-
show in a comment the specific `Dockerfile` they have been sourced from.
34+
#### Note on old GCC binaries
4835

49-
If you want to build a Docker image for GCC and an older Debian version, you should
50-
first build GCC using an appropriate image, giving it the _exact_ name and tag as
51-
passed later to the main `Dockerfile` as `BASE_IMAGE`. This may require significant
52-
CPU resources and take some time (e.g. 30 minutes using 40 cores) and it's needed
53-
to ensure that we do not use an old GCC release with known, and fixed, bugs.
36+
This image supports variety of releases of Debian, GCC and Clang. In order to
37+
support current GCC versions on an older Debian releases, we rely on `gcc` images
38+
backported from the [official GCC repository](https://github.com/docker-library/gcc).
5439

55-
For example:
40+
Hence, depending on the Debian release used, the GCC binaries are sourced from either of:
5641

57-
```shell
58-
docker buildx build . --progress plain --file docker/debian/Dockerfile.gcc-12-bullseye --tag localhost.localdomain/gcc:12-bullseye
59-
```
42+
- for `DEBIAN_VERSION=bookworm` : `gcc:$GCC_VERSION-$DEBIAN_VERSION`, produced in the [official GCC repository](https://github.com/docker-library/gcc)
43+
- for `DEBIAN_VERSION=bullseye` : `xrplf/ci/gcc:$GCC_VERSION-$DEBIAN_VERSION`, produced in [this repository](https://github.com/XRPLF/ci/pkgs/container/gcc)
6044

6145
#### Building the Docker image for GCC
6246

47+
In order to build an image, run the commands below from the root directory of
48+
the repository.
49+
6350
Ensure you've run the login command above to authenticate with the Docker
6451
registry.
6552

@@ -86,8 +73,8 @@ docker buildx build . \
8673
--tag ${CONTAINER_REGISTRY}/${CONTAINER_IMAGE}
8774
```
8875

89-
If you have prepared a GCC image for an older Debian version, you also need
90-
to explicitly set `BASE_IMAGE` build argument, e.g.
76+
In order to build an image for Bullseye, you also need to explicitly set
77+
`BASE_IMAGE` build argument, e.g.
9178

9279
```shell
9380
DEBIAN_VERSION=bullseye
@@ -96,7 +83,7 @@ CONAN_VERSION=2.19.1
9683
GCOVR_VERSION=8.3
9784
CMAKE_VERSION=3.31.6
9885
MOLD_VERSION=2.40.4
99-
BASE_IMAGE=localhost.localdomain/gcc:12-bullseye
86+
BASE_IMAGE=xrplf/ci/gcc:12-bullseye
10087
CONTAINER_IMAGE=xrplf/ci/debian-${DEBIAN_VERSION}:gcc-${GCC_VERSION}
10188

10289
docker buildx build . \
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM buildpack-deps:bullseye
22

33
## NOTE: EVERYTHING BELOW THIS COMMENT IS FROM
4-
## https://github.com/docker-library/gcc/blob/7070981b23d22d3ca790f87bff26f13f3614dd4c/12/Dockerfile
4+
## https://github.com/docker-library/gcc/blob/58af1a21e095e94e24b02350d0dbbc3d7f0a62ba/12/Dockerfile
55

66

77
RUN set -eux; \

0 commit comments

Comments
 (0)