build: build Go images from the repo root for the shared module

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.
This commit is contained in:
2026-07-24 13:45:45 +01:00
parent 51622a922b
commit 42cd73c5b8
5 changed files with 26 additions and 14 deletions
+8 -5
View File
@@ -1,13 +1,16 @@
# Context is the repository root; sitesvc depends on the shared module.
FROM golang:1.26-alpine AS builder
WORKDIR /app
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY shared/go.mod shared/go.sum ./shared/
COPY sitesvc/go.mod sitesvc/go.sum ./sitesvc/
RUN cd sitesvc && go mod download
COPY . .
COPY shared/ ./shared/
COPY sitesvc/ ./sitesvc/
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /out/sitesvc ./cmd
RUN cd sitesvc && CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /out/sitesvc ./cmd
FROM alpine:3.20 AS runner