Skip to content

feat: publish a polycli container image to GHCR on tag#963

Merged
minhd-vu merged 3 commits into
mainfrom
minhd-vu/polycli-docker-image
Jul 21, 2026
Merged

feat: publish a polycli container image to GHCR on tag#963
minhd-vu merged 3 commits into
mainfrom
minhd-vu/polycli-docker-image

Conversation

@minhd-vu

Copy link
Copy Markdown
Contributor

Summary

Adds a Dockerfile and a GitHub Actions workflow that builds and pushes a multi-arch polycli image to ghcr.io/0xPolygon/polygon-cli on every tag — mirroring the panoptichain build_and_publish setup.

Details

  • Dockerfile: multi-stage — build with the Go toolchain, ship on distroless/base (glibc). CGO is enabled because vectorized-poseidon-gold has no pure-Go path; buildx builds each platform natively under QEMU, so no cross-compilers are needed.
  • Workflow (.github/workflows/build_and_publish.yaml): on push tags → QEMU + Buildx → docker/build-push-action for linux/amd64 + linux/arm64, tags from docker/metadata-action (tag ref, semver, latest), plus build-provenance attestation. Uses the built-in GITHUB_TOKEN (packages: write).

Motivation

Lets polycli p2p sensor run as a container — e.g. the sensor VMs on Container-Optimized OS (polygon-infrastructure#1783) — removing the build-from-source/ansible step.

Validation

Built and ran locally (native arch): image is ~119 MB and docker run … version prints Polygon CLI Version …. Multi-arch is exercised in CI.

🤖 Generated with Claude Code

Add a Dockerfile and a GitHub Actions workflow that builds and pushes a
multi-arch (linux/amd64, linux/arm64) polycli image to
ghcr.io/0xPolygon/polygon-cli on every tag, mirroring the panoptichain setup.

CGO is enabled (vectorized-poseidon-gold has no pure-Go path); buildx builds
each platform natively under QEMU. Runtime is distroless/base (glibc).

Enables running `polycli p2p sensor` as a container (e.g. the sensor VMs on
Container-Optimized OS), removing the build-from-source/ansible step.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment thread .github/workflows/build_and_publish.yaml Fixed
Comment thread .github/workflows/build_and_publish.yaml Fixed
Comment thread .github/workflows/build_and_publish.yaml Dismissed
Comment thread .github/workflows/build_and_publish.yaml Dismissed
Comment thread .github/workflows/build_and_publish.yaml Dismissed
Dockerfile now runs `make build` instead of a bare `go build`, so the image
binary is version-stamped the same as a local build (git describe / commit /
date) rather than reporting "dev". Requires make in the builder and
fetch-depth: 0 in the publish workflow so `git describe --tags` sees the tags.

Verified: `docker run <img> version` -> "Polygon CLI Version v0.1.115-9-g...".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment thread .github/workflows/build_and_publish.yaml Dismissed
- Cross-compile on the native BUILDPLATFORM (mirroring the release
  `make cross` setup) instead of per-platform QEMU builds, via a new
  `docker-build` Makefile target that reuses VERSION_FLAGS. Ship the
  fully static binary on distroless/static (~119MB -> ~59MB).
- Own the /data working dir as the nonroot uid (65532) so the sensor
  can write its nodes.json discovery cache.
- Restrict the publish trigger to v* tags so ad-hoc tags can't move
  `latest`; drop the now-unneeded QEMU setup; share Go build/module
  cache mounts.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

💡 Need a hand with PR review? Try Gitar by Sonar!

@minhd-vu
minhd-vu merged commit 5fc2a58 into main Jul 21, 2026
15 of 16 checks passed
@minhd-vu
minhd-vu deleted the minhd-vu/polycli-docker-image branch July 21, 2026 14:22
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.

3 participants