Skip to content

Commit 9d83498

Browse files
authored
Merge pull request #3153 from samsrabin/doc-builder-podman-support
ctsm5.3.049: Preferentially use Podman for ctsm-docs container
2 parents a2782b4 + 4d3becb commit 9d83498

File tree

18 files changed

+88
-55
lines changed

18 files changed

+88
-55
lines changed

.github/ISSUE_TEMPLATE/03_documentation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ about: Something should be added to or fixed in the documentation
1212
- [ ] Something is broken.
1313

1414
### What part(s) of the documentation does this concern?
15-
- [ ] [Technical Note](https://escomp.github.io/ctsm/tech_note/index.html) (science and design of the model)
16-
- [ ] [User's Guide](https://escomp.github.io/ctsm/users_guide/index.html) (using the model and related tools)
15+
- [ ] [Technical Note](https://escomp.github.io/CTSM/tech_note/index.html) (science and design of the model)
16+
- [ ] [User's Guide](https://escomp.github.io/CTSM/users_guide/index.html) (using the model and related tools)
1717
- [ ] Somewhere else (e.g., README file, tool help text, or code comment): _Please specify_
1818
- [ ] I don't know
1919

.github/workflows/docker-image-common.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ jobs:
8484
id: set-image-tag
8585
run: |
8686
echo "IMAGE_TAG=$(echo '${{ steps.meta.outputs.tags }}' | head -n 1 | cut -d',' -f1)" >> $GITHUB_ENV
87-
- name: Build docs using container
87+
- name: Build docs using Docker (Podman has trouble on GitHub runners)
8888
id: build-docs
8989
run: |
90-
cd doc && ./build_docs -b ${PWD}/_build -c -d -i $IMAGE_TAG
90+
cd doc && ./build_docs -b ${PWD}/_build -c -d --container-cli-tool docker -i $IMAGE_TAG
9191
9292
9393
check-version:

.github/workflows/docs-build-and-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
run: |
5252
bin/git-fleximod update -o
5353
cd doc
54-
./build_docs_to_publish -d --site-root https://escomp.github.io/ctsm
54+
./build_docs_to_publish -d --container-cli-tool docker --site-root https://escomp.github.io/CTSM
5555
5656
- name: Upload artifact
5757
uses: actions/upload-pages-artifact@v3

.github/workflows/docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
run: |
5454
bin/git-fleximod update doc-builder
5555
56-
- name: Build docs using container
56+
- name: Build docs using Docker (Podman has trouble on GitHub runners)
5757
id: build-docs
5858
run: |
59-
cd doc && ./build_docs -b ${PWD}/_build -c -d
59+
cd doc && ./build_docs -b ${PWD}/_build -c -d --container-cli-tool docker

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ core.*
112112
*.pyc
113113
Depends
114114

115-
# Docs build output
115+
# Docs build and testing output
116116
_build*/
117117
_publish*/
118+
doc/.coverage

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ fxDONOTUSEurl = https://github.com/ESMCI/mpi-serial
124124
[submodule "doc-builder"]
125125
path = doc/doc-builder
126126
url = https://github.com/ESMCI/doc-builder
127-
fxtag = v2.1.2
127+
fxtag = v2.2.3
128128
fxrequired = ToplevelOptional
129129
# Standard Fork to compare to with "git fleximod test" to ensure personal forks aren't committed
130130
fxDONOTUSEurl = https://github.com/ESMCI/doc-builder

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ http://www.cesm.ucar.edu/models/cesm2.0/land/
1515

1616
and
1717

18-
https://escomp.github.io/ctsm/
18+
https://escomp.github.io/CTSM/
1919

2020
For help with how to work with CTSM in git, see
2121

doc/ctsm-docs_container/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ CMD ["/bin/bash", "-l"]
2929

3030
LABEL org.opencontainers.image.title="Container for building CTSM documentation"
3131
LABEL org.opencontainers.image.source=https://github.com/ESCOMP/CTSM
32-
LABEL org.opencontainers.image.version="v1.0.2"
32+
LABEL org.opencontainers.image.version="v1.0.2b"

doc/ctsm-docs_container/README.md

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
11
# The ctsm-docs container
2-
This directory and its Dockerfile are used to build a Docker container for building the CTSM documentation. Unless you're a developer working on the container, you probably don't need to care about anything in here.
2+
This directory and its Dockerfile are used to build a container for building the CTSM documentation. Unless you're a developer working on the container, you probably don't need to care about anything in here.
33

44
## Introduction
55

6-
This Readme tells you how to update the ctsm-docs Docker container if a need to do so arises—for example, adding a Python module that brings new functionality in the build. After you've followed all these instructions, you will probably want to push an update to [doc-builder](https://github.com/ESMCI/doc-builder) that updates `DEFAULT_DOCKER_IMAGE` in [build_commands.py](https://github.com/ESMCI/doc-builder/blob/master/doc_builder/build_commands.py) to point to the new tag.
6+
This Readme tells you how to update the ctsm-docs container if a need to do so arises—for example, adding a Python module that brings new functionality in the build. After you've followed all these instructions, you will probably want to push an update to [doc-builder](https://github.com/ESMCI/doc-builder) that updates `DEFAULT_IMAGE` in [build_commands.py](https://github.com/ESMCI/doc-builder/blob/master/doc_builder/build_commands.py) to point to the new tag.
77

88
## Building
99

10-
If you actually want to build the container, make sure Docker is running. In the Docker Desktop settings, make sure you've enabled the [`containerd` image store](https://docs.docker.com/desktop/features/containerd/), which allows multi-platform builds. Then do:
10+
If you actually want to build the container, you will need to have Podman installed. We previously used Docker for this, but had to move away from it due to licensing issues. Note that these issues have to do specifically with Docker Desktop, which is required to get the Docker Engine on some platforms. The Docker Engine itself is open-source, so our ctsm-docs container testing and publishing workflows are fine to continue using it. We are also fine to use the Docker Engine via Podman for local builds, which is what's described here.
11+
12+
Once you have Podman installed, you can do:
1113
```shell
12-
docker buildx build --platform linux/amd64,linux/arm64 -t ghcr.io/escomp/ctsm/ctsm-docs .
14+
podman build --no-cache -t ctsm-docs .
1315
```
1416

15-
To use your new version for local testing, you'll need to tell doc-builder to use that image. Call `docker images`, which should return something like this:
17+
To use your new version for local testing, you'll need to tell doc-builder to use that image. Call `podman images`, which should return something like this:
1618
```shell
17-
REPOSITORY TAG IMAGE ID CREATED SIZE
18-
ghcr.io/escomp/ctsm/ctsm-docs latest ab51446519a4 3 seconds ago 233MB
19+
REPOSITORY TAG IMAGE ID CREATED SIZE
20+
localhost/ctsm-docs latest 6464f26339bc 22 seconds ago 241 MB
1921
...
2022
```
2123

22-
To test, you can tell `build_docs` to use your new version by adding `--docker-image IMAGE_ID` to your call, where in the example above `IMAGE_ID` is `ab51446519a4`.
24+
To test, you can tell `build_docs` to use your new version by adding `--container-image IMAGE_ID` to your call, where in the example above `IMAGE_ID` is `6464f26339bc`.
2325

2426
## Publishing automatically
2527

2628
The `docker-image-build-publish.yml` workflow makes it so that new versions of the workflow will be published to the GitHub Container Registry whenever changes to the container setup are merged to CTSM's `master` branch. This will fail (as will a similar, no-publish workflow that happens on PRs) unless you specify exactly one new version number in the Dockerfile. This version number will be used as a tag that can be referenced by, e.g., doc-builder.
2729

28-
Lots of Docker instructions tell you to use the `latest` tag, and indeed the workflow will add that tag automatically. However, actually _using_ `latest` can lead to support headaches as users think they have the right version but actually don't. Instead, you'll make a new version number incremented from the [previous one](https://github.com/ESCOMP/CTSM/pkgs/container/ctsm%2Fctsm-docs/versions), in the `vX.Y.Z` format.
30+
Lots of container instructions tell you to use the `latest` tag, and indeed the workflow will add that tag automatically. However, actually _using_ `latest` can lead to support headaches as users think they have the right version but actually don't. Instead, you'll make a new version number incremented from the [previous one](https://github.com/ESCOMP/CTSM/pkgs/container/ctsm%2Fctsm-docs/versions), in the `vX.Y.Z` format.
2931

3032
Here's where you need to specify the version number in the Dockerfile:
3133
```docker
@@ -36,33 +38,44 @@ The string there can technically be anything as long as (a) it starts with a low
3638
You can check the results of the automatic publication on the [container's GitHub page](https://github.com/ESCOMP/CTSM/pkgs/container/ctsm%2Fctsm-docs).
3739

3840
### Updating doc-builder
39-
After the new version of the container is published, you will probably want to tell [doc-builder](https://github.com/ESMCI/doc-builder) to use the new one. Open a PR where you change the tag (the part after the colon) in the definition of `DEFAULT_DOCKER_IMAGE` in `doc_builder/build_commands.py`. Remember, **use the version number**, not "latest".
41+
After the new version of the container is published, you will probably want to tell [doc-builder](https://github.com/ESMCI/doc-builder) to use the new one. Open a PR where you change the tag (the part after the colon) in the definition of `DEFAULT_IMAGE` in `doc_builder/build_commands.py`. Remember, **use the version number**, not "latest".
4042

4143
## Publishing manually (NOT recommended)
4244

4345
It's vastly preferable to let GitHub build and publish the new repo using the `docker-image-build-publish.yml` workflow as described above. However, if you need to publish manually for some reason, here's how.
4446

47+
### Building the multi-architecture version
48+
49+
When publishing our container, we need to make sure it can run on either arm64 or amd64 processor architecture. This requires a special build process:
50+
```shell
51+
podman manifest create ctsm-docs-manifest
52+
podman build --platform linux/amd64,linux/arm64 --manifest ctsm-docs-manifest .
53+
```
54+
4555
### Pushing to GitHub Container Registry
4656
If you want to publish the container, you first need a [GitHub Personal Access Token (Classic)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#personal-access-tokens-classic) with the `write:packages` permissions. You can see your existing PAT(C)s [here](https://github.com/settings/tokens). If you don't have one with the right permissions, [this link](https://github.com/settings/tokens/new?scopes=write:packages) should start the setup process for you.
4757

4858
Once you have a PAT(C), you can authenticate in your shell session like so:
4959

50-
```shell
51-
echo YOUR_PERSONAL_ACCESS_TOKEN_CLASSIC | docker login ghcr.io -u YOUR_USERNAME --password-stdin
60+
```bash
61+
# bash: Make it so that, in this session, commands with a leading space are not saved to terminal history
62+
export HISTCONTROL=ignoreboth
63+
64+
# Include leading spaces so that your secret PAT(C) isn't included in terminal history
65+
echo YOUR_PERSONAL_ACCESS_TOKEN_CLASSIC | podman login ghcr.io -u YOUR_USERNAME --password-stdin
5266
```
53-
The leading spaces are intended to prevent this command, which contains your secret PAT(C), from being written to your shell's history file. That at least works in bash... sometimes. To be extra safe, in bash you can do `history -c` and it will clear your entire bash history. That can be pretty disruptive, but fortunately you should only need to authenticate once.
5467

5568
### Tagging
56-
You'll next need to tag the image. Lots of Docker instructions tell you to use the `latest` tag, and Docker may actually do that for you. However, `latest` can lead to support headaches as users think they have the right version but actually don't. Instead, you'll make a new version number incremented from the [previous one](https://github.com/ESCOMP/CTSM/pkgs/container/ctsm%2Fctsm-docs/versions), in the `vX.Y.Z` format.
69+
You'll next need to tag the image. Lots of container instructions tell you to use the `latest` tag, and Podman may actually add that for you. However, `latest` can lead to support headaches as users think they have the right version but actually don't. Instead, you'll make a new version number incremented from the [previous one](https://github.com/ESCOMP/CTSM/pkgs/container/ctsm%2Fctsm-docs/versions), in the `vX.Y.Z` format.
5770

58-
Copy the relevant image ID (see `docker images` instructions above) and tag it with your version number like so:
71+
Copy the relevant image ID (see `podman images` instructions above) and tag it with your version number like so:
5972
```shell
60-
docker tag ab51446519a4 ghcr.io/escomp/ctsm/ctsm-docs:vX.Y.Z
73+
podman tag 6464f26339bc ghcr.io/escomp/ctsm/ctsm-docs:vX.Y.Z
6174
```
6275

6376
Push to the repo:
6477
```shell
65-
docker push ghcr.io/escomp/ctsm/ctsm-docs:vX.Y.Z
78+
podman manifest push --all ctsm-docs-manifest ghcr.io/escomp/ctsm/ctsm-docs:vX.Y.Z
6679
```
6780

6881
Then browse to the [container's GitHub page](https://github.com/ESCOMP/CTSM/pkgs/container/ctsm%2Fctsm-docs) to make sure this all worked and the image is public.

0 commit comments

Comments
 (0)