Add container image build
Ship a distroless image so the plugin can run in-cluster in serve mode, letting developer laptops use the shared cache without S3 credentials. - Dockerfile: golang builder running `make build`, distroless static nonroot - `make docker` for a local smoke build - `.woodpecker/docker.yaml` pushes to docker-internal on tag - README: image name and the SSL_CERT_DIR mount the internal CA needs
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
when:
|
||||
- event: tag
|
||||
ref: refs/tags/v*
|
||||
|
||||
steps:
|
||||
- name: docker
|
||||
image: artifactapi.k8s.syd1.au.unkin.net/docker-internal/plugin-docker-buildx:latest
|
||||
settings:
|
||||
registry: artifactapi.k8s.syd1.au.unkin.net
|
||||
repo: artifactapi.k8s.syd1.au.unkin.net/docker-internal/go-cache-plugin
|
||||
dockerfile: Dockerfile
|
||||
platforms: linux/amd64
|
||||
buildkit_config: |
|
||||
[registry."artifactapi.k8s.syd1.au.unkin.net"]
|
||||
ca = ["/etc/docker/certs.d/artifactapi.k8s.syd1.au.unkin.net/ca.crt"]
|
||||
tags:
|
||||
- ${CI_COMMIT_TAG}
|
||||
- latest
|
||||
backend_options:
|
||||
kubernetes:
|
||||
serviceAccountName: default
|
||||
resources:
|
||||
requests:
|
||||
memory: 2Gi
|
||||
cpu: 2
|
||||
limits:
|
||||
memory: 6Gi
|
||||
cpu: 4
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
FROM docker.io/golang:1.26 AS builder
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN make build
|
||||
|
||||
# distroless static ships /etc/ssl/certs/ca-certificates.crt, which the S3
|
||||
# client needs to reach https://s3.ceph.unkin.net, and runs as an unprivileged
|
||||
# user. No shell, no package manager.
|
||||
FROM gcr.io/distroless/static-debian12:nonroot
|
||||
|
||||
COPY --from=builder /build/dist/go-cache-plugin /usr/local/bin/go-cache-plugin
|
||||
|
||||
ENTRYPOINT ["go-cache-plugin"]
|
||||
@@ -3,12 +3,14 @@ BINARY := go-cache-plugin
|
||||
# pinned by the tool directive in go.mod.
|
||||
PKG := github.com/tailscale/go-cache-plugin/cmd/go-cache-plugin
|
||||
DIST := dist
|
||||
IMAGE := artifactapi.k8s.syd1.au.unkin.net/docker-internal/$(BINARY)
|
||||
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
|
||||
UPSTREAM := $(shell go list -m -f '{{.Version}}' github.com/tailscale/go-cache-plugin)
|
||||
LDFLAGS := -s -w
|
||||
OS ?= $(shell go env GOOS)
|
||||
ARCH ?= $(shell go env GOARCH)
|
||||
|
||||
.PHONY: all build test lint fmt pre-commit clean upstream patch minor major _tag
|
||||
.PHONY: all build test lint fmt pre-commit docker clean upstream patch minor major _tag
|
||||
|
||||
all: build
|
||||
|
||||
@@ -30,6 +32,10 @@ fmt:
|
||||
pre-commit:
|
||||
uvx pre-commit run --all-files
|
||||
|
||||
# Local smoke test only; the tag pipeline builds and pushes the real image.
|
||||
docker:
|
||||
docker build -t $(IMAGE):$(VERSION) .
|
||||
|
||||
upstream:
|
||||
@echo $(UPSTREAM)
|
||||
|
||||
|
||||
@@ -42,6 +42,25 @@ exit, and `--expiry` to age entries out.
|
||||
For a shared cache daemon, run `go-cache-plugin serve --plugin <port>` once and
|
||||
have each build use `go-cache-plugin connect <port>` as its `GOCACHEPROG`.
|
||||
|
||||
## Container image
|
||||
|
||||
`artifactapi.k8s.syd1.au.unkin.net/docker-internal/go-cache-plugin`, built and
|
||||
pushed on tag. Distroless static, nonroot, no shell. `make docker` builds it
|
||||
locally.
|
||||
|
||||
The image carries only the public CA bundle, so a `serve`-mode Deployment must
|
||||
mount the internal CA and point Go at it:
|
||||
|
||||
```yaml
|
||||
env:
|
||||
- name: SSL_CERT_DIR
|
||||
value: /etc/ssl/internal
|
||||
```
|
||||
|
||||
`s3.ceph.unkin.net` is issued by `unkin.net Intermediate Authority`; without
|
||||
that mount the S3 client fails with `x509: certificate signed by unknown
|
||||
authority`.
|
||||
|
||||
## CI
|
||||
|
||||
Woodpecker steps fetch the released binary:
|
||||
@@ -55,4 +74,5 @@ commands:
|
||||
## Release
|
||||
|
||||
`make patch|minor|major` tags and pushes; the tag pipeline builds
|
||||
`linux/amd64` and `linux/arm64` and attaches them with `sha256sums.txt`.
|
||||
`linux/amd64` and `linux/arm64`, attaches them with `sha256sums.txt`, and
|
||||
pushes the container image tagged with the git tag and `latest`.
|
||||
|
||||
Reference in New Issue
Block a user