Files
pamietnik/Dockerfile
Christoph K. 73665e1bc7
Some checks failed
Deploy to NAS / deploy (push) Failing after 3m0s
Run go test inside Docker build instead of separate docker run step
Bind-mounted source causes Go module resolution issues in the runner
container. Tests now run as a Dockerfile layer (after go mod download,
before SPA inject + go build) — no bind mount, no extra step needed.
A failed test aborts the build and the deploy never happens.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 08:16:04 +02:00

26 lines
762 B
Docker

# Stage 1: Build Vite SPA
FROM node:22-alpine AS webapp-builder
WORKDIR /webapp
COPY webapp/package.json webapp/package-lock.json ./
RUN npm ci
COPY webapp/ ./
RUN npm run build
# Stage 2: Build Go server
FROM golang:1.25-alpine AS go-builder
WORKDIR /app
COPY backend/go.mod backend/go.sum ./
RUN go mod download
COPY backend/ ./
RUN go test ./...
# Inject built SPA into embed path
COPY --from=webapp-builder /webapp/dist ./internal/api/webapp/
RUN CGO_ENABLED=0 GOOS=linux go build -o /server ./cmd/server
RUN CGO_ENABLED=0 GOOS=linux go build -o /createuser ./cmd/createuser
# Stage 3: Minimal runtime image
FROM gcr.io/distroless/static-debian12
COPY --from=go-builder /server /server
COPY --from=go-builder /createuser /createuser
ENTRYPOINT ["/server"]