Dockerfile
·
24 lines
·
677 B
| 1 | # Stage 1: Build static Go binary |
| 2 | FROM golang:1.23-alpine AS builder |
| 3 | WORKDIR /src |
| 4 | COPY go.mod go.sum ./ |
| 5 | RUN go mod download |
| 6 | COPY . . |
| 7 | RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/polar ./cmd/polar |
| 8 | |
| 9 | # Stage 2: Minimal runtime image with git |
| 10 | FROM alpine:3.20 |
| 11 | RUN apk add --no-cache git ca-certificates tzdata && \ |
| 12 | adduser -D -u 10001 polar |
| 13 | WORKDIR /app |
| 14 | COPY --from=builder /out/polar /app/polar |
| 15 | RUN mkdir -p /app/data && chown -R polar:polar /app |
| 16 | |
| 17 | USER polar |
| 18 | EXPOSE 3000 |
| 19 | VOLUME ["/app/data"] |
| 20 | |
| 21 | HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ |
| 22 | CMD wget -qO- http://127.0.0.1:3000/healthz || exit 1 |
| 23 | |
| 24 | ENTRYPOINT ["/app/polar"] |
| 25 |