Skip to content

Commit 5922dcd

Browse files
committed
Add Ubuntu Docker images
1 parent 6ecd920 commit 5922dcd

File tree

5 files changed

+206
-1
lines changed

5 files changed

+206
-1
lines changed

.github/workflows/ubuntu.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Ubuntu
2+
3+
on:
4+
push:
5+
6+
env:
7+
DOCKER_REGISTRY: ghcr.io
8+
9+
jobs:
10+
# Build the Docker image for Ubuntu using different versions of GCC.
11+
gcc:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
version:
16+
- os: jammy
17+
gcc: 12
18+
- os: noble
19+
gcc: 14
20+
steps:
21+
- name: Login to GitHub Container Registry
22+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ${DOCKER_REGISTRY} -u ${{ github.actor }} --password-stdin
23+
- name: Build the Docker image
24+
run: |
25+
DOCKER_BUILDKIT=1 docker build . \
26+
--target gcc \
27+
--build-arg UBUNTU_VERSION=${{ matrix.version.os }} \
28+
--build-arg GCC_VERSION=${{ matrix.version.gcc }} \
29+
--tag ${{ github.event.repository.name }}/${{ matrix.version.os }}:gcc${{ matrix.version.gcc }}
30+
31+
# Build the Docker image for Ubuntu using different versions of Clang.
32+
clang:
33+
runs-on: ubuntu-latest
34+
strategy:
35+
matrix:
36+
version:
37+
- os: noble
38+
clang: 18
39+
- os: noble
40+
clang: 19
41+
steps:
42+
- name: Login to GitHub Container Registry
43+
run: |
44+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ${DOCKER_REGISTRY} -u ${{ github.actor }} --password-stdin
45+
- name: Build the Docker image
46+
run: |
47+
DOCKER_BUILDKIT=1 docker build . \
48+
--target clang \
49+
--build-arg UBUNTU_VERSION=${{ matrix.version.os }} \
50+
--build-arg CLANG_VERSION=${{ matrix.version.clang }} \
51+
--tag ${{ github.event.repository.name }}/${{ matrix.version.os }}:clang{{ matrix.version.clang }}

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# IDEs.
2+
.idea
3+
.vscode
4+
settings.json
5+
6+
# OS.
7+
.DS_Store

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# ci
1+
# CI
2+
23
Images and workflows for use by CI pipelines.

docker/ubuntu/Dockerfile

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# ====================== BASE IMAGE ======================
2+
ARG UBUNTU_VERSION=jammy
3+
FROM ubuntu:${UBUNTU_VERSION} AS base
4+
5+
# Associate the image with the repository.
6+
ARG GITHUB_REPO=XRPLF/ci
7+
LABEL org.opencontainers.image.source=https://github.com/${GITHUB_REPO}
8+
9+
# Ensure any packages installed directly or indirectly via dpkg do not require
10+
# manual interaction.
11+
ARG DEBIAN_FRONTEND=noninteractive
12+
RUN apt update && apt upgrade -y && \
13+
ln -fs /usr/share/zoneinfo/America/Los_Angeles /etc/localtime && \
14+
apt install tzdata && \
15+
dpkg-reconfigure --frontend noninteractive tzdata
16+
17+
# Install tools that are shared by all stages.
18+
RUN apt install -y build-essential \
19+
ca-certificates \
20+
cmake \
21+
curl \
22+
git \
23+
gpg \
24+
libssl-dev \
25+
libprotobuf-dev \
26+
ninja-build \
27+
protobuf-compiler
28+
29+
# Install Conan.
30+
RUN apt install -y pipx
31+
RUN PIPX_HOME=/opt/pipx \
32+
PIPX_BIN_DIR=/usr/bin \
33+
PIPX_MAN_DIR=/usr/share/man \
34+
pipx install conan
35+
36+
# Create the user to switch to, once all packages have been installed.
37+
ARG NONROOT_USER=ci
38+
RUN useradd -ms /bin/bash ${NONROOT_USER}
39+
40+
# ====================== GCC IMAGE ======================
41+
FROM base AS gcc
42+
43+
# Install GCC.
44+
ARG GCC_VERSION=12
45+
RUN apt install -y gcc-${GCC_VERSION} g++-${GCC_VERSION}
46+
ENV CC=/usr/bin/gcc-${GCC_VERSION}
47+
ENV CXX=/usr/bin/gcc-${GCC_VERSION}
48+
RUN rm -rf /var/lib/apt/lists/*
49+
50+
# Switch to the non-root user.
51+
USER ${NONROOT_USER}
52+
WORKDIR /home/${NONROOT_USER}
53+
54+
# ===================== CLANG IMAGE =====================
55+
FROM base AS clang
56+
57+
# Install Clang.
58+
ARG CLANG_VERSION=16
59+
RUN apt install -y clang-${CLANG_VERSION} llvm-${CLANG_VERSION}
60+
ENV CC=clang-${CLANG_VERSION}
61+
ENV CXX=clang++-${CLANG_VERSION}
62+
RUN rm -rf /var/lib/apt/lists/*
63+
64+
# Switch to the non-root user.
65+
USER ${NONROOT_USER}
66+
WORKDIR /home/${NONROOT_USER}

docker/ubuntu/README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
## Ubuntu: A Docker image used to build and test rippled
2+
3+
The code in this repository creates a locked-down Ubuntu image for building and
4+
testing rippled in the GitHub CI pipelines.
5+
6+
### Logging into the Docker registry
7+
8+
To be able to push to GitHub a personal access token is needed, see instructions
9+
[here](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#authenticating-with-a-personal-access-token-classic).
10+
In summary, if you do not have a suitable personal access token, generate one
11+
[here](https://github.com/settings/tokens/new?scopes=write:packages).
12+
13+
```shell
14+
DOCKER_REGISTRY=ghcr.io
15+
GITHUB_USER=<your-github-username>
16+
GITHUB_TOKEN=<your-github-personal-access-token>
17+
echo ${GITHUB_TOKEN} | \
18+
docker login ${DOCKER_REGISTRY} -u "${GITHUB_USER}" --password-stdin
19+
```
20+
21+
### Building and pushing the Docker image
22+
23+
The same Dockerfile can be used to build an image for Ubuntu 22.04 and 24.04 by
24+
specifying the `UBUNTU_VERSION` build argument. There are additional arguments
25+
to specify as well, namely `CMAKE_VERSION` and `GCC_VERSION` for the GCC flavor
26+
and `CMAKE_VERSION` and `CLANG_VERSION` for the Clang flavor.
27+
28+
Run the commands below from the current directory containing the Dockerfile.
29+
30+
#### Building the Docker image for GCC.
31+
32+
Ensure you've run the login command above to authenticate with the Docker
33+
registry.
34+
35+
```shell
36+
UBUNTU_VERSION=noble
37+
GCC_VERSION=14
38+
DOCKER_IMAGE=xrplf/ci/${UBUNTU_VERSION}:gcc${GCC_VERSION}
39+
40+
DOCKER_BUILDKIT=1 docker build . \
41+
--target gcc \
42+
--build-arg BUILDKIT_INLINE_CACHE=1 \
43+
--build-arg UBUNTU_VERSION=${UBUNTU_VERSION} \
44+
--build-arg GCC_VERSION=${GCC_VERSION} \
45+
--tag ${DOCKER_REGISTRY}/${DOCKER_IMAGE} \
46+
--platform linux/amd64
47+
48+
docker push ${DOCKER_REGISTRY}/${DOCKER_IMAGE}
49+
```
50+
51+
#### Building the Docker image for Clang.
52+
53+
Ensure you've run the login command above to authenticate with the Docker
54+
registry.
55+
56+
```shell
57+
UBUNTU_VERSION=noble
58+
CLANG_VERSION=18
59+
DOCKER_IMAGE=xrplf/ci/${UBUNTU_VERSION}:clang${CLANG_VERSION}
60+
61+
DOCKER_BUILDKIT=1 docker build . \
62+
--target clang \
63+
--build-arg BUILDKIT_INLINE_CACHE=1 \
64+
--build-arg UBUNTU_VERSION=${UBUNTU_VERSION} \
65+
--build-arg CLANG_VERSION=${CLANG_VERSION} \
66+
--tag ${DOCKER_REGISTRY}/${DOCKER_IMAGE} \
67+
--platform linux/amd64
68+
69+
docker push ${DOCKER_REGISTRY}/${DOCKER_IMAGE}
70+
```
71+
72+
### List of Docker images built for CI
73+
74+
As our code requires a minimum of GCC 12 and Clang 16, and Ubuntu only supports
75+
certain versions depending on the release, we have built the following images
76+
and pushed them to the GitHub Container Registry:
77+
* `ghcr.io/xrplf/ci/jammy:gcc12`
78+
* `ghcr.io/xrplf/ci/noble:gcc14`
79+
* `ghcr.io/xrplf/ci/noble:clang18`
80+
* `ghcr.io/xrplf/ci/noble:clang19`

0 commit comments

Comments
 (0)