Also pins the explicit shared require in both go.mod files. `go mod tidy` in workspace mode drops it, which breaks the Docker build where no workspace exists.
30 lines
747 B
Docker
30 lines
747 B
Docker
# Context is the repository root; sitesvc depends on the shared module.
|
|
FROM golang:1.26-alpine AS builder
|
|
|
|
WORKDIR /src
|
|
|
|
COPY shared/go.mod shared/go.sum ./shared/
|
|
COPY sitesvc/go.mod sitesvc/go.sum ./sitesvc/
|
|
RUN cd sitesvc && go mod download
|
|
|
|
COPY shared/ ./shared/
|
|
COPY sitesvc/ ./sitesvc/
|
|
|
|
RUN cd sitesvc && CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /out/sitesvc ./cmd
|
|
|
|
FROM alpine:3.20 AS runner
|
|
|
|
# Needed to verify the SMTP server's TLS certificate.
|
|
RUN apk add --no-cache ca-certificates && \
|
|
addgroup --system --gid 1001 sitesvc && \
|
|
adduser --system --uid 1001 --ingroup sitesvc sitesvc
|
|
|
|
COPY --from=builder /out/sitesvc /usr/local/bin/sitesvc
|
|
|
|
USER sitesvc
|
|
|
|
EXPOSE 8082
|
|
ENV PORT=8082
|
|
|
|
CMD ["/usr/local/bin/sitesvc"]
|