Skip to content

Commit c00f7ca

Browse files
authored
Update READMEs (#69)
This PR updates the READMEs as follows: * Logging into GHCR is only needed when pushing, so those instructions are moved to the last section. * GCC base image ARG was missing ghcr.io, which has been fixed. * To simplify copy-pasting of commands, the `CONTAINER_REGISTRY` var has been removed and ghcr.io has been added explicitly. Otherwise it's needed to copy-paste-run commands scattered across the readme. * Extra note for macOS is included to add `--platform linux/amd64` in order to create a Docker image that can be run by CI on Linux. * Updated push instruction to include `sha-${USER}` to the image tag, so it can be referenced in the strategy matrix. * General other cleanups.
1 parent 6948666 commit c00f7ca

File tree

5 files changed

+261
-180
lines changed

5 files changed

+261
-180
lines changed

docker/debian/README.md

Lines changed: 63 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,33 @@ Although the images will be built by a CI pipeline in this repository, if
77
necessary a maintainer can build them manually by following the instructions
88
below.
99

10-
### Logging into the GitHub registry
11-
12-
To be able to push a Docker image to the GitHub registry, a personal access
13-
token is needed, see instructions [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).
14-
In summary, if you do not have a suitable personal access token, generate one
15-
[here](https://github.com/settings/tokens/new?scopes=write:packages).
16-
17-
```shell
18-
CONTAINER_REGISTRY=ghcr.io
19-
GITHUB_USER=<your-github-username>
20-
GITHUB_TOKEN=<your-github-personal-access-token>
21-
echo ${GITHUB_TOKEN} | \
22-
docker login ${CONTAINER_REGISTRY} -u "${GITHUB_USER}" --password-stdin
23-
```
24-
25-
### Building and pushing the Docker image
10+
### Building the Docker image
2611

2712
The same Dockerfile can be used to build an image for different Debian releases
2813
by specifying the `DEBIAN_VERSION` build argument. There are additional
2914
arguments to specify as well, namely `GCC_VERSION` for the GCC flavor and
3015
`CLANG_VERSION` for the Clang flavor.
3116

32-
Build image for `gcc` supports packaging.
17+
Only the build image for `gcc` supports packaging.
3318

3419
#### Note on old GCC binaries
3520

3621
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).
22+
support current GCC versions on an older Debian releases, we rely on `gcc`
23+
images backported from the [official GCC repository](https://github.com/docker-library/gcc).
3924

40-
Hence, depending on the Debian release used, the GCC binaries are sourced from either of:
25+
Hence, depending on the Debian release used, the GCC binaries are sourced from
26+
either of:
4127

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)
28+
- for `DEBIAN_VERSION=bookworm`: `gcc:${GCC_VERSION}-${DEBIAN_VERSION}`, produced in
29+
the [official GCC repository](https://github.com/docker-library/gcc)
30+
- for `DEBIAN_VERSION=bullseye`: `ghcr.io/xrplf/ci/gcc:${GCC_VERSION}-${DEBIAN_VERSION}`,
31+
produced in [this repository](https://github.com/XRPLF/ci/pkgs/container/gcc)
4432

4533
#### Building the Docker image for GCC
4634

47-
In order to build an image, run the commands below from the root directory of
48-
the repository.
49-
50-
Ensure you've run the login command above to authenticate with the Docker
51-
registry.
35+
In order to build the image for GCC, run the commands below from the root
36+
directory of the repository.
5237

5338
```shell
5439
DEBIAN_VERSION=bookworm
@@ -57,7 +42,7 @@ CONAN_VERSION=2.19.1
5742
GCOVR_VERSION=8.3
5843
CMAKE_VERSION=4.1.0
5944
MOLD_VERSION=2.40.4
60-
CONTAINER_IMAGE=xrplf/ci/debian-${DEBIAN_VERSION}:gcc-${GCC_VERSION}
45+
CONTAINER_IMAGE=ghcr.io/xrplf/ci/debian-${DEBIAN_VERSION}:gcc-${GCC_VERSION}
6146

6247
docker buildx build . \
6348
--file docker/debian/Dockerfile \
@@ -70,10 +55,10 @@ docker buildx build . \
7055
--build-arg GCOVR_VERSION=${GCOVR_VERSION} \
7156
--build-arg CMAKE_VERSION=${CMAKE_VERSION} \
7257
--build-arg MOLD_VERSION=${MOLD_VERSION} \
73-
--tag ${CONTAINER_REGISTRY}/${CONTAINER_IMAGE}
58+
--tag ${CONTAINER_IMAGE}
7459
```
7560

76-
In order to build an image for Bullseye, you also need to explicitly set
61+
In order to build a GCC image for Bullseye, you also need to explicitly set
7762
`BASE_IMAGE` build argument, e.g.
7863

7964
```shell
@@ -83,8 +68,8 @@ CONAN_VERSION=2.19.1
8368
GCOVR_VERSION=8.3
8469
CMAKE_VERSION=4.1.0
8570
MOLD_VERSION=2.40.4
86-
BASE_IMAGE=xrplf/ci/gcc:12-bullseye
87-
CONTAINER_IMAGE=xrplf/ci/debian-${DEBIAN_VERSION}:gcc-${GCC_VERSION}
71+
BASE_IMAGE=ghcr.io/xrplf/ci/gcc:12-bullseye
72+
CONTAINER_IMAGE=ghcr.io/xrplf/ci/debian-${DEBIAN_VERSION}:gcc-${GCC_VERSION}
8873

8974
docker buildx build . \
9075
--file docker/debian/Dockerfile \
@@ -98,13 +83,13 @@ docker buildx build . \
9883
--build-arg CMAKE_VERSION=${CMAKE_VERSION} \
9984
--build-arg MOLD_VERSION=${MOLD_VERSION} \
10085
--build-arg BASE_IMAGE=${BASE_IMAGE} \
101-
--tag ${CONTAINER_REGISTRY}/${CONTAINER_IMAGE}
86+
--tag ${CONTAINER_IMAGE}
10287
```
10388

10489
#### Building the Docker image for Clang
10590

106-
Ensure you've run the login command above to authenticate with the Docker
107-
registry.
91+
In order to build an image for Clang, run the commands below from the root
92+
directory of the repository.
10893

10994
```shell
11095
DEBIAN_VERSION=bookworm
@@ -113,7 +98,7 @@ CONAN_VERSION=2.19.1
11398
GCOVR_VERSION=8.3
11499
CMAKE_VERSION=4.1.0
115100
MOLD_VERSION=2.40.4
116-
CONTAINER_IMAGE=xrplf/ci/debian-${DEBIAN_VERSION}:clang-${CLANG_VERSION}
101+
CONTAINER_IMAGE=ghcr.io/xrplf/ci/debian-${DEBIAN_VERSION}:clang-${CLANG_VERSION}
117102

118103
docker buildx build . \
119104
--file docker/debian/Dockerfile \
@@ -126,17 +111,17 @@ docker buildx build . \
126111
--build-arg GCOVR_VERSION=${GCOVR_VERSION} \
127112
--build-arg CMAKE_VERSION=${CMAKE_VERSION} \
128113
--build-arg MOLD_VERSION=${MOLD_VERSION} \
129-
--tag ${CONTAINER_REGISTRY}/${CONTAINER_IMAGE}
114+
--tag ${CONTAINER_IMAGE}
130115
```
131116

132-
#### Running the Docker image
117+
### Running the Docker image
133118

134119
If you want to run the image locally using a cloned `rippled` repository, you
135120
can do so with the following command:
136121

137122
```shell
138123
CODEBASE=<path to the rippled repository>
139-
docker run --user $(id -u):$(id -g) --rm -it -v ${CODEBASE}:/rippled ${CONTAINER_REGISTRY}/${CONTAINER_IMAGE}
124+
docker run --user $(id -u):$(id -g) --rm -it -v ${CODEBASE}:/rippled ${CONTAINER_IMAGE}
140125
```
141126

142127
Note, the above command will assume the identity of the current user in the
@@ -163,7 +148,7 @@ cd /rippled
163148
# Remove any existing data from previous builds on the host machine.
164149
rm -rf CMakeCache.txt CMakeFiles build || true
165150
# Install dependencies via Conan.
166-
conan remote add --index=0 xrplf https://conan.ripplex.io
151+
conan remote add --force --index 0 xrplf https://conan.ripplex.io
167152
conan install . --build missing --settings:all build_type=${BUILD_TYPE} \
168153
--options:host '&:tests=True' --options:host '&:xrpld=True'
169154
# Configure the build with CMake.
@@ -177,11 +162,45 @@ cmake --build . -j ${PARALLELISM}
177162
./rippled --unittest --unittest-jobs ${PARALLELISM}
178163
```
179164

180-
#### Pushing the Docker image to the GitHub registry
165+
### Pushing the Docker image
166+
167+
#### Logging into the GitHub registry
168+
169+
To be able to push a Docker image to the GitHub registry, a personal access
170+
token is needed, see instructions [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).
171+
In summary, if you do not have a suitable personal access token, generate one
172+
[here](https://github.com/settings/tokens/new?scopes=write:packages).
173+
174+
```shell
175+
GITHUB_USER=<your-github-username>
176+
GITHUB_TOKEN=<your-github-personal-access-token>
177+
echo ${GITHUB_TOKEN} | docker login ghcr.io -u "${GITHUB_USER}" --password-stdin
178+
```
179+
180+
#### Pushing to the GitHub registry
181181

182-
If you want to push the image to the GitHub registry, you can do so with the
183-
following command:
182+
To push the image to the GitHub registry, you can do so with the following
183+
command, whereby we append your username to not overwrite existing images:
184184

185185
```shell
186-
docker push ${CONTAINER_REGISTRY}/${CONTAINER_IMAGE}
186+
docker tag ${CONTAINER_IMAGE} ${CONTAINER_IMAGE}-sha-${GITHUB_USER}
187+
docker push ${CONTAINER_IMAGE}-sha-${GITHUB_USER}
187188
```
189+
190+
This way you can test the image in the `rippled` repository by modifying the
191+
`image_sha` entry in `.github/scripts/strategy-matrix/linux.json` for the
192+
relevant configuration, and then creating a pull request.
193+
194+
Note, if you or the CI pipeline are pushing an image for the first time, it will
195+
be private by default. You will need to go to the
196+
[packages page](https://github.com/orgs/XRPLF/packages), select the relevant
197+
package, then "Package settings", and after clicking the "Change visibility"
198+
button make it "Public". In addition, on that same page, under "Manage Actions
199+
access" click the "Add repository" button, select the `ci` repository, and grant
200+
it "Admin" access.
201+
202+
#### Note on macOS
203+
204+
If you are using macOS and wish to push an image to the GitHub registry for use
205+
in GitHub Actions, you will need to append `--platform linux/amd64` to the
206+
`docker buildx build` commands above.

docker/gcc/README.md

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,54 +19,68 @@ Although the images will be built by a CI pipeline in this repository, if
1919
necessary a maintainer can build them manually by following the instructions
2020
below.
2121

22-
### Logging into the GitHub registry
22+
### Building the Docker image
2323

24-
To be able to push a Docker image to the GitHub registry, a personal access
25-
token is needed, see instructions [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).
26-
In summary, if you do not have a suitable personal access token, generate one
27-
[here](https://github.com/settings/tokens/new?scopes=write:packages).
28-
29-
```shell
30-
CONTAINER_REGISTRY=ghcr.io
31-
GITHUB_USER=<your-github-username>
32-
GITHUB_TOKEN=<your-github-personal-access-token>
33-
echo ${GITHUB_TOKEN} | \
34-
docker login ${CONTAINER_REGISTRY} -u "${GITHUB_USER}" --password-stdin
35-
```
36-
37-
### Building and pushing the Docker image
38-
39-
Dockerfiles provided in this directory can be used to build an image for different GCC versions
40-
by specifying it as part of the the extension of a Dockerfile, e.g. `Dockerfile.12-bullseye`.
24+
Dockerfiles provided in this directory can be used to build an image for
25+
different GCC versions by specifying it as part of the extension of a
26+
Dockerfile, e.g. `Dockerfile.12-bullseye`.
4127

4228
Even though in principle this repository can support different Debian releases,
4329
currently only Dockerfiles for Debian Bullseye are provided.
4430

45-
#### Building the Docker image
46-
4731
In order to build an image, run the commands below from the root directory of
4832
the repository.
4933

50-
Ensure you've run the login command above to authenticate with the Docker
51-
registry.
52-
5334
```shell
5435
GCC_VERSION=12
5536
DEBIAN_VERSION=bullseye
56-
CONTAINER_IMAGE=xrplf/ci/gcc:${GCC_VERSION}-${DEBIAN_VERSION}
37+
CONTAINER_IMAGE=ghcr.io/xrplf/ci/gcc:${GCC_VERSION}-${DEBIAN_VERSION}
5738

5839
docker buildx build . \
5940
--file docker/gcc/Dockerfile.${GCC_VERSION}-${DEBIAN_VERSION} \
6041
--build-arg BUILDKIT_DOCKERFILE_CHECK=skip=InvalidDefaultArgInFrom \
6142
--build-arg BUILDKIT_INLINE_CACHE=1 \
62-
--tag ${CONTAINER_REGISTRY}/${CONTAINER_IMAGE}
43+
--tag ${CONTAINER_IMAGE}
6344
```
6445

65-
#### Pushing the Docker image to the GitHub registry
46+
### Pushing the Docker image
6647

67-
If you want to push the image to the GitHub registry, you can do so with the
68-
following command:
48+
#### Logging into the GitHub registry
49+
50+
To be able to push a Docker image to the GitHub registry, a personal access
51+
token is needed, see instructions [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).
52+
In summary, if you do not have a suitable personal access token, generate one
53+
[here](https://github.com/settings/tokens/new?scopes=write:packages).
54+
55+
```shell
56+
GITHUB_USER=<your-github-username>
57+
GITHUB_TOKEN=<your-github-personal-access-token>
58+
echo ${GITHUB_TOKEN} | docker login ghcr.io -u "${GITHUB_USER}" --password-stdin
59+
```
60+
61+
#### Pushing to the GitHub registry
62+
63+
To push the image to the GitHub registry, you can do so with the following
64+
command, whereby we append your username to not overwrite existing images:
6965

7066
```shell
71-
docker push ${CONTAINER_REGISTRY}/${CONTAINER_IMAGE}
67+
docker tag ${CONTAINER_IMAGE} ${CONTAINER_IMAGE}-${GITHUB_USER}
68+
docker push ${CONTAINER_IMAGE}-${GITHUB_USER}
7269
```
70+
71+
However, there should be no need to push the GCC image manually, as it is only
72+
used as a base image for other images in this repository.
73+
74+
Note, if you or the CI pipeline are pushing an image for the first time, it will
75+
be private by default. You will need to go to the
76+
[packages page](https://github.com/orgs/XRPLF/packages), select the relevant
77+
package, then "Package settings", and after clicking the "Change visibility"
78+
button make it "Public". In addition, on that same page, under "Manage Actions
79+
access" click the "Add repository" button, select the `ci` repository, and grant
80+
it "Admin" access.
81+
82+
#### Note on macOS
83+
84+
If you are using macOS and wish to push an image to the GitHub registry for use
85+
in GitHub Actions, you will need to append `--platform linux/amd64` to the
86+
`docker buildx build` commands above.

0 commit comments

Comments
 (0)