From 4905d62eeda600d38f12d71b35669b52fb17f8d3 Mon Sep 17 00:00:00 2001 From: Anton Patsev <10828883+patsevanton@users.noreply.github.com> Date: Thu, 13 Aug 2026 19:08:11 +0600 Subject: [PATCH 1/2] ci: publish official multi-arch Docker image to GHCR --- .github/workflows/docker.yml | 62 ++++++++++++++++++++++++++++++++++++ Dockerfile | 33 +++++++++++++++++++ README.md | 23 +++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 .github/workflows/docker.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..6e3f02a --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,62 @@ +name: Docker Image + +# Builds and publishes a multi-arch container image to GHCR when a version +# tag (v*) is pushed, mirroring the PyPI release trigger in release.yml. +# +# The image is tagged with: +# - the version (e.g. v0.1.0) +# - latest +# +# Usage: +# git tag v0.1.0 && git push origin v0.1.0 + +on: + push: + tags: ["v*"] + workflow_dispatch: + +permissions: + contents: read + packages: write + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=semver,pattern={{raw}} + type=semver,pattern=v{{major}}.{{minor}} + type=raw,value=latest,enable={{is_default_branch}} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6c11b1a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +# syntax=docker/dockerfile:1 +# +# Official container image for cachelint. +# +# docker run --rm -v "$PWD":/work ghcr.io/0xabcd01/cachelint Dockerfile +# +# The tool is pure standard-library Python, so a slim base is enough. +FROM python:3.12-slim AS builder + +# Build a wheel so the final stage stays small and dependency-free. +COPY src /src/src +COPY pyproject.toml README.md /src/ +RUN pip install --no-cache-dir --upgrade build \ + && python -m build --wheel --outdir /dist /src + +FROM python:3.12-slim + +# Non-root user for CI safety. +RUN groupadd --system --gid 1001 cachelint \ + && useradd --system --uid 1001 --gid cachelint \ + --create-home --home-dir /home/cachelint cachelint + +# Install the prebuilt wheel from the builder stage. +COPY --from=builder /dist/*.whl /tmp/ +RUN pip install --no-cache-dir /tmp/*.whl \ + && rm -f /tmp/*.whl + +# Run as the non-root user from now on. +USER cachelint +WORKDIR /work + +ENTRYPOINT ["cachelint"] +CMD ["--help"] diff --git a/README.md b/README.md index c2fa216..a25e46f 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ [![CI](https://github.com/0xABCD01/cachelint/actions/workflows/ci.yml/badge.svg)](https://github.com/0xABCD01/cachelint/actions/workflows/ci.yml) [![PyPI](https://img.shields.io/pypi/v/cachelint.svg)](https://pypi.org/project/cachelint/) +[![Container](https://ghcr-badge.egpl.dev/0xabcd01/cachelint/tags?label=ghcr)](https://github.com/0xABCD01/cachelint/pkgs/container/cachelint) [![Python versions](https://img.shields.io/pypi/pyversions/cachelint.svg)](https://pypi.org/project/cachelint/) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
@@ -103,6 +104,20 @@ pip install cachelint `cachelint` adds no other packages. It is pure standard library. +### Container image + +A multi-arch (`linux/amd64`, `linux/arm64`) image is published to GHCR on every +release tag: + +```bash +docker run --rm -v "$PWD":/work ghcr.io/0xabcd01/cachelint:v0.1.0 Dockerfile +# or pin by digest for locked-down environments: +# ghcr.io/0xabcd01/cachelint@sha256:... +``` + +The image runs as a non-root user. Mount your checkout at `/work` and pass the +Dockerfile path (relative to `/work`) as the argument. + ## 🚀 Usage ```bash @@ -127,6 +142,14 @@ Exit codes: `0` clean, `1` findings at or above `--fail-on` (default `high`), - run: cachelint Dockerfile # fails the job on a HIGH finding ``` +Or use the container image directly (no Python install): + +```yaml +- uses: docker://ghcr.io/0xabcd01/cachelint:v0.1.0 + with: + args: Dockerfile --fail-on high +``` + Upload findings to the GitHub Security tab: ```yaml From cd759d833c95be8359a402d628200ee6da701c69 Mon Sep 17 00:00:00 2001 From: Anton Patsev <10828883+patsevanton@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:04:41 +0600 Subject: [PATCH 2/2] =?UTF-8?q?ci:=20=D0=BF=D1=80=D0=B8=D0=B2=D1=8F=D0=B7?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=82=D0=B5=D0=B3=D0=B0=20latest=20=D0=BA=20?= =?UTF-8?q?=D0=BF=D1=83=D1=88=D1=83=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=BE?= =?UTF-8?q?=D0=BD=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=82=D0=B5=D0=B3=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 6e3f02a..8f3304f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -34,7 +34,7 @@ jobs: tags: | type=semver,pattern={{raw}} type=semver,pattern=v{{major}}.{{minor}} - type=raw,value=latest,enable={{is_default_branch}} + type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }} - name: Set up QEMU uses: docker/setup-qemu-action@v3