c0253c98f9
Scheduler now runs a token-protected HTTP server on scheduler.http_port (default 8081, -1 disables) that exposes Prometheus /metrics and the daily-task JSON snapshot endpoint. Workers gain a blocking Run(ctx) and are supervised by a WaitGroup: on SIGINT/SIGTERM the metrics server shuts down first, worker ticks stop scheduling but ongoing runOnce calls keep their own context and finish, and the process waits up to 60s before exiting. Adds scheduler.http_host/http_port/internal_metrics_token to config with SCHEDULER_* env overrides and exposes port 8081 in the Docker image. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
42 lines
1.3 KiB
Docker
42 lines
1.3 KiB
Docker
# syntax=docker/dockerfile:1
|
|
|
|
# ─── Stage 1: Build Go binaries ───────────────────────────────────────────────
|
|
FROM golang:1.22-alpine AS builder
|
|
|
|
ARG SERVICE=tenant-api
|
|
|
|
RUN apk --no-cache add ca-certificates git
|
|
|
|
WORKDIR /app
|
|
|
|
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 /bin/service ./cmd/${SERVICE}
|
|
|
|
# ─── Stage 2: Migration image (bundles SQL files + migrate binary) ─────────────
|
|
FROM migrate/migrate:v4.18.1 AS migrate-tool
|
|
|
|
FROM alpine:3.19 AS migrate
|
|
RUN apk --no-cache add ca-certificates
|
|
COPY --from=migrate-tool /usr/local/bin/migrate /usr/local/bin/migrate
|
|
COPY migrations/ /migrations/
|
|
COPY migrations_monitoring/ /migrations_monitoring/
|
|
ENTRYPOINT ["/usr/local/bin/migrate"]
|
|
|
|
# ─── Stage 3: Runtime image ────────────────────────────────────────────────────
|
|
FROM alpine:3.19 AS runtime
|
|
RUN apk --no-cache add ca-certificates tzdata
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=builder /bin/service /app/service
|
|
COPY configs/ /app/configs/
|
|
|
|
EXPOSE 8080 8081
|
|
ENTRYPOINT ["/app/service"]
|