Files
marktvogt.de/backend/deploy/Dockerfile
T

33 lines
739 B
Docker

FROM golang:1.25-alpine AS builder
RUN apk add --no-cache git ca-certificates
# Install golang-migrate CLI with postgres driver (pure Go, no CGO needed)
RUN go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@v4.18.1
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o /api ./cmd/api
FROM alpine:3.21
RUN apk add --no-cache ca-certificates tzdata
WORKDIR /app
COPY --from=builder /api .
COPY --from=builder /go/bin/migrate /usr/local/bin/migrate
COPY migrations/ ./migrations/
# alpine:3.21 already ships nobody at UID 65534 — matches podSecurityContext.runAsUser
USER nobody:nobody
EXPOSE 8080
ENTRYPOINT ["./api"]