36 lines
910 B
Docker
36 lines
910 B
Docker
# syntax=docker/dockerfile:1
|
|
# Multi-stage build optimized for Dokploy / docker compose.
|
|
|
|
FROM golang:1.22-alpine AS builder
|
|
RUN apk add --no-cache git ca-certificates tzdata
|
|
WORKDIR /src
|
|
|
|
COPY go.mod go.sum* ./
|
|
RUN go mod download
|
|
|
|
COPY . .
|
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
|
|
go build -trimpath -ldflags="-s -w" -o /out/server ./cmd/server \
|
|
&& go build -trimpath -ldflags="-s -w" -o /out/cleanup ./cmd/cleanup
|
|
|
|
FROM alpine:3.20
|
|
RUN apk add --no-cache ca-certificates tzdata wget \
|
|
&& addgroup -S app && adduser -S -G app app
|
|
WORKDIR /app
|
|
|
|
COPY --from=builder /out/server /app/server
|
|
COPY --from=builder /out/cleanup /app/cleanup
|
|
COPY migrations /app/migrations
|
|
COPY web /app/web
|
|
|
|
ENV APP_PORT=30000 \
|
|
TZ=UTC
|
|
|
|
USER app
|
|
EXPOSE 30000
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
|
CMD wget -qO- http://127.0.0.1:30000/health || exit 1
|
|
|
|
ENTRYPOINT ["/app/server"]
|