diff --git a/Dockerfile b/Dockerfile index 5106843..b654200 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,22 @@ FROM golang:1.26-alpine AS build WORKDIR /src -COPY go.* ./ + +# Keep dependency resolution deterministic. Do NOT run `go mod tidy` before +# source files are present: it can remove required modules because no packages +# are visible yet. +COPY go.mod go.sum ./ RUN go mod download -RUN go mod tidy + COPY cmd ./cmd COPY internal ./internal -RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/neuralhunt ./cmd/server -RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/neuralhunt-client ./cmd/client + +# Fail early with a useful message if a repository/.dockerignore rule ever +# drops the application's internal data package from the build context. +RUN test -f /src/internal/data/store.go \ + && test -f /src/internal/data/schema.sql + +RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/neuralhunt ./cmd/server \ + && CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/neuralhunt-client ./cmd/client FROM alpine:3.24 RUN adduser -D -H app && mkdir -p /data /app && chown -R app:app /data /app