Files
kms/Dockerfile.operator
T
zeekay d912da333c fix(operator): COPY in-module deps (pkg/envelope, pkg/zap) into build context
zapclient imports github.com/luxfi/kms/pkg/{envelope,zap}, which are the
module's own packages. -mod=vendor only vendors external deps, so these
must be present in the Docker build context as source. The selective COPY
missed them, so the build failed:

  pkg/zapclient/client.go:34:2: cannot find module providing package
    github.com/luxfi/kms/pkg/envelope: import lookup disabled by -mod=vendor

COPY both packages; also add them to the workflow paths filter so the
operator image rebuilds when they change.
2026-06-22 08:13:46 -07:00

38 lines
1.4 KiB
Docker

# luxfi/kms-operator — minimal KMSSecret reconciler.
# Single static Go binary, no CGO, scratch runtime.
FROM golang:1.26.4-bookworm AS builder
ENV GOTOOLCHAIN=auto
ARG GITHUB_TOKEN
RUN git config --global url."https://${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
ENV GOPRIVATE=github.com/luxfi/*,github.com/hanzoai/*
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates tzdata \
&& rm -rf /var/lib/apt/lists/* \
&& echo 'nonroot:x:65532:65532:nonroot:/home/nonroot:/sbin/nologin' >> /etc/passwd \
&& echo 'nonroot:x:65532:' >> /etc/group
WORKDIR /build
COPY go.mod go.sum ./
COPY vendor ./vendor
COPY cmd/kms-operator ./cmd/kms-operator
# zapclient and its in-module deps (envelope, zap) — vendor only carries
# external deps, so the module's own packages must be in the build context.
COPY pkg/zapclient ./pkg/zapclient
COPY pkg/envelope ./pkg/envelope
COPY pkg/zap ./pkg/zap
RUN CGO_ENABLED=0 go build -mod=vendor \
-ldflags="-s -w" -o /usr/local/bin/kms-operator ./cmd/kms-operator
FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
COPY --from=builder /usr/local/bin/kms-operator /usr/local/bin/kms-operator
USER 65532:65532
EXPOSE 8080
ENTRYPOINT ["/usr/local/bin/kms-operator"]