Merge pull request 'fix(images): prune the unused Go binaries from the ci image' (#123) from ci/ci-image-prune-go-binaries into main
Build / build (push) Successful in 11s
Images / image (Dockerfile, ubuntu:24.04@sha256:fe81560990fae86dc4743202b2cb4d3df98d0bcf949173cecef15ce1127ef852, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.6) (push) Successful in 9s
Lint / lint (push) Successful in 48s
Images / image (Dockerfile, ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.3) (push) Successful in 11s
Images / image (images/ci/Dockerfile, ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c, ci, , 0.2.17) (push) Successful in 3m42s
Build / build (push) Successful in 11s
Images / image (Dockerfile, ubuntu:24.04@sha256:fe81560990fae86dc4743202b2cb4d3df98d0bcf949173cecef15ce1127ef852, molecule-ubuntu2404, images/molecule-ubuntu2404, 0.1.6) (push) Successful in 9s
Lint / lint (push) Successful in 48s
Images / image (Dockerfile, ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c, molecule-ubuntu2604, images/molecule-ubuntu2604, 0.1.3) (push) Successful in 11s
Images / image (images/ci/Dockerfile, ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c, ci, , 0.2.17) (push) Successful in 3m42s
Reviewed-on: #123
This commit was merged in pull request #123.
This commit is contained in:
commit
c258a107fe
3 files changed
+21
-5
No files matched your search
@@ -87,7 +87,7 @@ jobs:
|
|||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
job_image: ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c
|
job_image: ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c
|
||||||
- name: ci
|
- name: ci
|
||||||
version: 0.2.16
|
version: 0.2.17
|
||||||
subpath: ""
|
subpath: ""
|
||||||
dockerfile: images/ci/Dockerfile
|
dockerfile: images/ci/Dockerfile
|
||||||
job_image: ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c
|
job_image: ubuntu:26.04@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c
|
||||||
|
|||||||
+4
-2
@@ -14,7 +14,8 @@ Ubuntu 26.04 with:
|
|||||||
`ansible-lint --offline` resolves their modules instead of mocking them.
|
`ansible-lint --offline` resolves their modules instead of mocking them.
|
||||||
- **Every pre-commit hook environment** of `.pre-commit-config.yaml` in `/opt/pre-commit`
|
- **Every pre-commit hook environment** of `.pre-commit-config.yaml` in `/opt/pre-commit`
|
||||||
(`PRE_COMMIT_HOME`): conventional-pre-commit, gitleaks, yamllint, ruff, shellcheck-py, pre-commit-hooks and actionlint. The Go
|
(`PRE_COMMIT_HOME`): conventional-pre-commit, gitleaks, yamllint, ruff, shellcheck-py, pre-commit-hooks and actionlint. The Go
|
||||||
hooks are prebuilt; their toolchains are removed to keep layers small. The local hooks (`reuse-lint`,
|
hooks are prebuilt; their toolchains, and the binaries of those repositories that no hook runs, are removed to
|
||||||
|
keep layers small. The local hooks (`reuse-lint`,
|
||||||
`antsibull-changelog-lint`, `ansible-lint`) are `language: system`: they run from `/opt/venv`, which is why
|
`antsibull-changelog-lint`, `ansible-lint`) are `language: system`: they run from `/opt/venv`, which is why
|
||||||
that directory must be on `PATH` (it is, in the image).
|
that directory must be on `PATH` (it is, in the image).
|
||||||
- **`ansible-test sanity` virtualenvs**, primed in `/root/.ansible/test`, and Python 3.11 and 3.13 as
|
- **`ansible-test sanity` virtualenvs**, primed in `/root/.ansible/test`, and Python 3.11 and 3.13 as
|
||||||
@@ -77,7 +78,8 @@ files are copied in). The workflow runs on pushes to `main` that touch `images/*
|
|||||||
`version:` in the workflow's matrix is not yet published. A change to the image's inputs therefore needs a new
|
`version:` in the workflow's matrix is not yet published. A change to the image's inputs therefore needs a new
|
||||||
`version:` (Lint enforces it, and Renovate's bump step does it for dependency updates), and the merge builds
|
`version:` (Lint enforces it, and Renovate's bump step does it for dependency updates), and the merge builds
|
||||||
the image. Each pushed layer stays below 100 MB (Cloudflare's request limit), which is why the Go toolchains
|
the image. Each pushed layer stays below 100 MB (Cloudflare's request limit), which is why the Go toolchains
|
||||||
are deleted from the hook cache.
|
and the unused Go binaries are deleted from the hook cache, and why the build prints the compressed size of each layer
|
||||||
|
directory.
|
||||||
|
|
||||||
## Image metadata
|
## Image metadata
|
||||||
|
|
||||||
|
|||||||
+16
-2
@@ -82,9 +82,19 @@ RUN python3 -m venv /opt/uv-venv \
|
|||||||
# downloads into <env>/.go, about 170 MB per environment, which alone pushed the
|
# downloads into <env>/.go, about 170 MB per environment, which alone pushed the
|
||||||
# /opt/pre-commit layer past Cloudflare's 100 MB limit (413 on the first push). At run
|
# /opt/pre-commit layer past Cloudflare's 100 MB limit (413 on the first push). At run
|
||||||
# time only the built binaries in <env>/bin run, so the toolchains and the Go build
|
# time only the built binaries in <env>/bin run, so the toolchains and the Go build
|
||||||
# cache are deleted. The hooks below run on a staged sample before and after the
|
# cache are deleted. So are the binaries no hook runs: pre-commit installs every main
|
||||||
|
# package of a hook repository, which leaves gitleaks' `config` and actionlint's
|
||||||
|
# `check-checks` and `generate-*` (about 60 MB raw, 20 MB compressed) next to the
|
||||||
|
# `gitleaks` and `actionlint` that the hooks call. Without them the ruff and shellcheck
|
||||||
|
# environments fit: with them the layer was about 103 MB compressed and the push of
|
||||||
|
# ci 0.2.16 got a 413. The hooks below run on a staged sample before and after the
|
||||||
# deletion: a cache that is incomplete (a missing environment would be rebuilt, which
|
# deletion: a cache that is incomplete (a missing environment would be rebuilt, which
|
||||||
# needs the network) or no longer works fails the image build, not the jobs.
|
# needs the network) or no longer works fails the image build, not the jobs.
|
||||||
|
#
|
||||||
|
# The last lines print the compressed size of each directory a later COPY turns into a
|
||||||
|
# layer, which is what the 100 MB (95 MiB) limit applies to. These gzip -6 figures run
|
||||||
|
# about 9% below the sizes the registry stores, and every new hook environment adds
|
||||||
|
# 15 to 25 MB to /opt/pre-commit, so read them before adding one.
|
||||||
RUN set -eu; \
|
RUN set -eu; \
|
||||||
git init -q /tmp/hooks; \
|
git init -q /tmp/hooks; \
|
||||||
cp .pre-commit-config.yaml /tmp/hooks/; \
|
cp .pre-commit-config.yaml /tmp/hooks/; \
|
||||||
@@ -101,10 +111,14 @@ RUN set -eu; \
|
|||||||
smoke() { for h in yamllint gitleaks actionlint ruff-check ruff-format shellcheck; do /opt/venv/bin/pre-commit run "$h" --all-files; done; }; \
|
smoke() { for h in yamllint gitleaks actionlint ruff-check ruff-format shellcheck; do /opt/venv/bin/pre-commit run "$h" --all-files; done; }; \
|
||||||
smoke; \
|
smoke; \
|
||||||
rm -rf /opt/pre-commit/repo*/golangenv-*/.go /root/.cache/go-build; \
|
rm -rf /opt/pre-commit/repo*/golangenv-*/.go /root/.cache/go-build; \
|
||||||
|
find /opt/pre-commit/repo*/golangenv-*/bin -mindepth 1 -maxdepth 1 -type f \
|
||||||
|
! -name gitleaks ! -name actionlint -delete; \
|
||||||
smoke; \
|
smoke; \
|
||||||
rm -rf /tmp/hooks; \
|
rm -rf /tmp/hooks; \
|
||||||
find /opt/pre-commit -maxdepth 1 -mindepth 1 -exec du -sh {} + | sort -h; \
|
find /opt/pre-commit -maxdepth 1 -mindepth 1 -exec du -sh {} + | sort -h; \
|
||||||
du -sh /opt/venv /opt/python /opt/pre-commit
|
gz() { tar -C "$(dirname "$1")" -cf - "$(basename "$1")" | gzip -6 | wc -c \
|
||||||
|
| awk -v d="$1" '{printf "%7.1f MB compressed %s\n", $1 / 1048576, d}'; }; \
|
||||||
|
for d in /opt/venv /opt/python /opt/collections /opt/pre-commit; do gz "$d"; done
|
||||||
|
|
||||||
# ansible-test builds one virtualenv per sanity test under ~/.ansible/test/venv, keyed
|
# ansible-test builds one virtualenv per sanity test under ~/.ansible/test/venv, keyed
|
||||||
# by the hash of the test's requirements (so by the ansible-core pin), and reuses it on
|
# by the hash of the test's requirements (so by the ansible-core pin), and reuses it on
|
||||||
|
|||||||
Reference in new issue
Block a user