Skip to content

Commit 11ca32d

Browse files
committed
move helper code into a central container
1 parent fc50d3d commit 11ca32d

File tree

19 files changed

+552
-364
lines changed

19 files changed

+552
-364
lines changed

.github/workflows/docker.yml

+11-9
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ env:
2121
PSUM_LABEL: be.backplane.image.context_psum
2222
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7
2323
LICENSES: Various Open Source
24-
PLATFORMS_OVERRIDE: .build_platforms.txt
25-
LICENSES_OVERRIDE: LICENSES.txt
24+
PLATFORMS_OVERRIDE_FILE: .build_platforms.txt
25+
LICENSES_OVERRIDE_FILE: LICENSES.txt
2626

2727
jobs:
2828
build-push:
@@ -45,11 +45,12 @@ jobs:
4545
- black
4646
- blampy
4747
- bpython
48-
- cdk
48+
- cdk-python
4949
- chardet
5050
- checkmake
5151
- chrome
5252
- compose_sort
53+
- conex-helper
5354
- firefox
5455
- fzf
5556
- ghlatest
@@ -102,13 +103,13 @@ jobs:
102103
: "${REGISTRY:?}" # this is used in subsequent steps
103104
: "${ORG:?}"
104105
: "${PSUM_LABEL:?}"
105-
: "${PLATFORMS_OVERRIDE:?}"
106106
107-
# generate some useful outputs
108-
.helpers/cdata.py \
109-
--forcebuild '${{ github.event.inputs.force_build }}' \
110-
--repo "${ORG}/${{ matrix.container }}" \
111-
'${{ matrix.container }}'
107+
# generate some outputs about the container being built
108+
docker pull -q backplane/conex-helper
109+
docker run --rm -it --volume "$(pwd):/work" backplane/conex-helper \
110+
metadata \
111+
--forcedbuilds '${{ github.event.inputs.force_build }}' \
112+
'${{ matrix.container }}'
112113
113114
# https://github.com/docker/setup-qemu-action
114115
- name: Set up QEMU
@@ -144,6 +145,7 @@ jobs:
144145
org.opencontainers.image.title=${{ matrix.container }}
145146
org.opencontainers.image.source=https://github.com/backplane/conex/${{ matrix.container }}
146147
org.opencontainers.image.licenses=${{ steps.cdata.outputs.licenses }}
148+
org.opencontainers.image.description=${{ steps.cdata.outputs.description }}
147149
148150
# Build and push Docker image with Buildx (don't push on PR)
149151
# https://github.com/docker/build-push-action

.helpers/cdata.py

-151
This file was deleted.

Makefile

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ all: README.md .github/workflows/docker.yml
77

88
README.md: */README.md docs/about.md
99
@printf '==> %s\n' "$@"
10-
.helpers/readme_generator.py \
11-
--dhuser "backplane" \
12-
--header docs/about.md \
13-
*/README.md \
14-
>"$@"
10+
docker run --rm -it --volume "$$(pwd):/work" backplane/conex-helper \
11+
update-readme \
12+
-i docs/about.md \
13+
*/README.md
1514

1615
.github/workflows/docker.yml: $(DOCKERFILES) $(CONTEXTS)
17-
.helpers/update_workflow.py "$@"
16+
docker run --rm -it --volume "$$(pwd):/work" backplane/conex-helper \
17+
update-workflow

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Name | Description | Dockerfile Link | Image Link
3030
[checkmake](checkmake) | [`alpine:edge`](https://hub.docker.com/_/alpine/)-based dockerization of [checkmake](https://github.com/mrtazz/checkmake/), the `Makefile` linter | [Dockerfile](checkmake/Dockerfile) | [backplane/checkmake](https://hub.docker.com/r/backplane/checkmake)
3131
[chrome](chrome) | [`debian:unstable-slim`](https://hub.docker.com/_/debian/)-based dockerization of the Google Chrome web browser | [Dockerfile](chrome/Dockerfile) | [backplane/chrome](https://hub.docker.com/r/backplane/chrome)
3232
[compose_sort](compose_sort) | [`alpine:edge`](https://hub.docker.com/_/alpine/)-based dockerization of `compose_sort`, a CLI utility for sorting docker-compose files | [Dockerfile](compose_sort/Dockerfile) | [backplane/compose_sort](https://hub.docker.com/r/backplane/compose_sort)
33+
[conex-helper](conex-helper) | [`python:3-alpine`](https://hub.docker.com/_/python/)-based dockerization of a utility program which helps manage the `backplane/conex` github repo | [Dockerfile](conex-helper/Dockerfile) | [backplane/conex-helper](https://hub.docker.com/r/backplane/conex-helper)
3334
[firefox](firefox) | [`debian:unstable-slim`](https://hub.docker.com/_/debian/)-based dockerization of the Firefox web browser | [Dockerfile](firefox/Dockerfile) | [backplane/firefox](https://hub.docker.com/r/backplane/firefox)
3435
[fzf](fzf) | [`alpine:edge`](https://hub.docker.com/_/alpine/)-based dockerization of [fzf](https://github.com/junegunn/fzf) the command line fuzzy finder | [Dockerfile](fzf/Dockerfile) | [backplane/fzf](https://hub.docker.com/r/backplane/fzf)
3536
[ghlatest](ghlatest) | scratch-based dockerization of [ghlatest](https://github.com/backplane/ghlatest), a release downloader utility | [Dockerfile](ghlatest/Dockerfile) | [backplane/ghlatest](https://hub.docker.com/r/backplane/ghlatest)

conex-helper/.dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
README.md
2+
venv
3+
**/__pycache__

conex-helper/Dockerfile

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM python:3-alpine
2+
LABEL maintainer="Backplane BV <[email protected]>"
3+
4+
COPY requirements.txt /
5+
6+
RUN set -eux; \
7+
pip install -r /requirements.txt; \
8+
pip cache purge;
9+
10+
COPY app /app/
11+
12+
WORKDIR /work
13+
14+
ARG NONROOT_GID=20000
15+
ARG NONROOT_UID=20000
16+
RUN set -ex; \
17+
addgroup \
18+
-g ${NONROOT_GID} \
19+
nonroot \
20+
; \
21+
adduser \
22+
-h /work \
23+
-u ${NONROOT_UID} \
24+
-G nonroot \
25+
-D \
26+
nonroot \
27+
;
28+
USER nonroot
29+
30+
ENTRYPOINT ["/app/main.py"]

conex-helper/README.md

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# conex-helper
2+
3+
[`python:3-alpine`](https://hub.docker.com/_/python/)-based dockerization of a utility program which helps manage the `backplane/conex` github repo
4+
5+
## Usage
6+
7+
The program has three primary subcommands: `update-readme`, `update-workflow`, and `metadata`.
8+
9+
### general help text
10+
11+
```
12+
usage: main.py [-h] [--debug] [--dhuser DHUSER] command ...
13+
14+
utility for maintaining the github.com/backplane/conex repo
15+
16+
positional arguments:
17+
command
18+
update-readme update the central readme from the readme files in the container subdirectories
19+
update-workflow
20+
update the github actions workflow file 'docker.yml' with the current list of container subdirectories
21+
metadata called during the container build github action to write workflow outputs that get used in later build steps
22+
23+
options:
24+
-h, --help show this help message and exit
25+
--debug enable debug output (default: False)
26+
--dhuser DHUSER the docker hub repo path to use when linking to images (default: backplane)
27+
```
28+
29+
### `update-readme` subcommand
30+
31+
This subcommand is used to update the central `README.md` from the `README.md` files in the container subdirectories.
32+
33+
```
34+
usage: main.py update-readme [-h] [-i HEADER] readme subdir_readmes [subdir_readmes ...]
35+
36+
positional arguments:
37+
readme the path to the markdown file to update
38+
subdir_readmes the source README.md files to build from
39+
40+
options:
41+
-h, --help show this help message and exit
42+
-i HEADER, --header HEADER
43+
header file(s) to include at the beginning of the output (default: [])
44+
45+
```
46+
47+
### `update-workflow` subcommand
48+
49+
This subcommand is used to update the github actions workflow file `docker.yml` with the current list of container subdirectories.
50+
51+
```
52+
usage: main.py update-workflow [-h] [--workflowfile WORKFLOWFILE] [--basedir BASEDIR] [-l]
53+
54+
options:
55+
-h, --help show this help message and exit
56+
--workflowfile WORKFLOWFILE
57+
the path to the workflow file to update (in-place) (default: .github/workflows/docker.yml)
58+
--basedir BASEDIR the path the repo base (default: .)
59+
-l, --list don't make any changes; instead print the container list from the current action file (default: False)
60+
61+
```
62+
63+
### `metadata` subcommand
64+
65+
This subcommand is called during the docker build github action to write workflow outputs that get used in later build steps.
66+
67+
This includes comparing the perishable checksum of the current build context to the perishable checksum label on the corresponding image already on docker hub. This allows builds to be skipped if nothing has changed in the build context.
68+
69+
```
70+
usage: main.py metadata [-h] [--forcedbuilds FORCEDBUILDS] [--repo REPO] [--psumlabel PSUMLABEL] [--platforms PLATFORMS] [--platforms-override-file PLATFORMS_OVERRIDE_FILE] [--licenses LICENSES]
71+
[--licenses-override-file LICENSES_OVERRIDE_FILE]
72+
contextname
73+
74+
positional arguments:
75+
contextname the name of the directory containing the Docker build context
76+
77+
options:
78+
-h, --help show this help message and exit
79+
--forcedbuilds FORCEDBUILDS
80+
comma-separated list of container contexts to build, without regard to the context's perishable checksum (default: )
81+
--repo REPO the image repo, as given to the 'docker pull' command (default: None)
82+
--psumlabel PSUMLABEL
83+
the namespaced perishable sum label name to apply to the image (default: be.backplane.image.context_psum)
84+
--platforms PLATFORMS
85+
the default list of platforms to build for (default: linux/amd64,linux/arm64,linux/arm/v7)
86+
--platforms-override-file PLATFORMS_OVERRIDE_FILE
87+
the name of a file inside the context directory which lists platforms to build for (default: .build_platforms.txt)
88+
--licenses LICENSES the default SPDX License Expression for the primary image content (default: Various Open Source)
89+
--licenses-override-file LICENSES_OVERRIDE_FILE
90+
the name of a file inside the context directory which lists SPDX License Expressions for the primary image content (default: LICENSES.txt)
91+
92+
```
93+
94+
### Interactive Use
95+
96+
The following shell function can assist in running this image interactively:
97+
98+
```sh
99+
100+
conex_helper() {
101+
docker run \
102+
--rm \
103+
--interactive \
104+
--tty \
105+
--volume "$(pwd):/work" \
106+
"backplane/conex-helper" \
107+
"$@"
108+
}
109+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env python3
2+
3+
from .core import *

0 commit comments

Comments
 (0)