mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-21 23:22:34 +01:00
Allow Docker to distinguish a running container from one actually serving traffic by adding a /health endpoint that pings the database. Returns 200 when healthy, 503 when the DB connection is lost. Add HEALTHCHECK to Dockerfile and healthcheck config to the server service in docker-compose.yml. Also add start_period to the existing db healthcheck for consistency.
32 lines
649 B
Docker
32 lines
649 B
Docker
# Build stage
|
|
FROM golang:1.25-alpine3.21 AS builder
|
|
|
|
WORKDIR /build
|
|
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
COPY . .
|
|
RUN CGO_ENABLED=0 go build -o erupe-ce .
|
|
|
|
# Runtime stage
|
|
FROM alpine:3.21
|
|
|
|
RUN adduser -D -h /app erupe
|
|
WORKDIR /app
|
|
|
|
COPY --from=builder /build/erupe-ce .
|
|
COPY --from=builder /build/schemas/ ./schemas/
|
|
|
|
# www/ and bin/ are mounted at runtime if needed
|
|
|
|
# bin/ and savedata/ are mounted at runtime via docker-compose
|
|
# config.json is also mounted at runtime
|
|
|
|
USER erupe
|
|
|
|
HEALTHCHECK --interval=10s --timeout=3s --start-period=15s --retries=3 \
|
|
CMD wget -qO- http://localhost:8080/health || exit 1
|
|
|
|
ENTRYPOINT ["./erupe-ce"]
|