Skip to content

ci: publish official multi-arch Docker image to GHCR - #2

Merged
0xABCD01 merged 3 commits into
0xABCD01:mainfrom
patsevanton:ci/docker-image
Nov 15, 2026
Merged

0xABCD01 merged 3 commits into
0xABCD01:mainfrom
patsevanton:ci/docker-image

Conversation

@patsevanton

Copy link
Copy Markdown
Contributor

Summary

Adds an official multi-arch container image published to GHCR, so cachelint can be used in CI without installing it via pip on every run.

Changes

  • Dockerfile — multi-stage build on python:3.12-slim; the wheel is built in a builder stage and only the installed package lands in the final image. Runs as a non-root cachelint user (uid 1001). ENTRYPOINT ["cachelint"], WORKDIR /work.
  • .github/workflows/docker.yml — triggers on v* tags (same as release.yml). Builds linux/amd64 + linux/arm64 via QEMU/Buildx and pushes to ghcr.io/<owner>/<repo> with tags vX.Y.Z, vX.Y, latest. Uses docker/metadata-action for tagging and cache-from: type=gha for incremental builds.
  • README.md — GHCR badge, a "Container image" section with docker run and digest examples, and a CI snippet using docker://.

Image

ghcr.io/0xabcd01/cachelint:v0.1.0
ghcr.io/0xabcd01/cachelint:latest
  • multi-arch: linux/amd64, linux/arm64
  • non-root user
  • ~50 MB (pure stdlib, slim base)
  • usable from any CI provider, e.g. GitLab CI:
    cachelint:
      image:
        name: ghcr.io/0xabcd01/cachelint:v0.1.0
        entrypoint: [""]
      script:
        - cachelint Dockerfile --fail-on high

Checklist

  • pytest passes locally
  • New behavior has tests (positive and negative cases)
  • If a rule/ecosystem was added, the README rules table / ecosystem list is updated
  • No new runtime dependencies (standard library only)
  • Any auto-fix change cannot produce a Dockerfile that fails to build

@patsevanton

Copy link
Copy Markdown
Contributor Author

@0xABCD01 plz review

@0xABCD01 0xABCD01 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this — the multi-arch GHCR setup looks good. Minimal workflow permissions, GITHUB_TOKEN login, multi-stage build and the non-root user are all the right calls, and the Dockerfile matches the src layout.

Approving, but one fix before this merges: in docker.yml the latest tag is gated on {{is_default_branch}}. On a tag push the ref is refs/tags/vX.Y.Z, not the default branch, so that condition evaluates false and latest would never get published on releases — which is the main trigger of this workflow. Could you enable it for version tags instead, e.g. enable=${{ startsWith(github.ref, 'refs/tags/v') }}?

Everything else in the diff looks fine to me.

@patsevanton

Copy link
Copy Markdown
Contributor Author

Fixed in cd759d8 — the latest tag is now gated on the version tag instead of the default branch:

-            type=raw,value=latest,enable={{is_default_branch}}
+            type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}

So a v* tag push now publishes vX.Y.Z, vX.Y and latest.

One pre-existing thing I left alone to keep this diff minimal: workflow_dispatch produces no tags at all (the semver patterns need a semver ref), so a manual run with push: true would fail. Happy to add a dedicated tag for manual runs in a follow-up if you want that path to work.

@0xABCD01
0xABCD01 merged commit dd27f7d into 0xABCD01:main Nov 15, 2026
@patsevanton

Copy link
Copy Markdown
Contributor Author

Post-merge note: no image has been published yet.

The workflow only runs on a v* tag push, and the only tag that exists, v0.1.0 (created 21 Oct 2026), points at 1ff6a7b — the initial-release commit, which predates docker.yml. GitHub resolves workflows from the tagged commit, so pushing that tag never triggered a build, and there has been no Docker Image run at all. GHCR also has no cachelint package yet (404).

Proposal: cut a new version tag on main so this workflow actually fires:

  1. bump version in pyproject.toml (still 0.1.0) and add a CHANGELOG.md entry, e.g. 0.1.1;
  2. git tag v0.1.1 && git push origin v0.1.1.

That runs both Release (PyPI) and Docker Image, producing v0.1.1, v0.1 and latest for linux/amd64 + linux/arm64:

ghcr.io/0xabcd01/cachelint:v0.1.1
ghcr.io/0xabcd01/cachelint:latest

Two caveats:

  • Moving the existing v0.1.0 tag onto the merge commit would publish the image, but it rewrites an already-public tag and re-fires the PyPI publish, which failed on 21 Oct on the publish step. A fresh patch version avoids both.
  • workflow_dispatch still builds nothing publishable: every tag in docker.yml is either semver (needs a semver ref) or gated on refs/tags/v, so a manual run ends up with an empty tag list. Worth a follow-up with a dedicated :edge tag if you want manual builds to work.

Happy to open that PR (v0.1.1 bump + :edge for manual runs) if you want it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants