# ─── Stage 1: Build backend ─── FROM golang:1.26-alpine AS backend-builder RUN apk add --no-cache git ca-certificates WORKDIR /app COPY go.mod go.sum ./ RUN go mod download COPY . . RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /sub-store . # ─── Stage 2: Runtime ─── FROM alpine:3.21 RUN apk add --no-cache ca-certificates tzdata WORKDIR /app COPY --from=backend-builder /sub-store /app/sub-store COPY config/config.example.yaml /app/config/config.example.yaml RUN mkdir -p /app/data ENV TZ=Asia/Shanghai ENV SUB_STORE_CONFIG=/app/config/config.yaml EXPOSE 3000 ENTRYPOINT ["/app/sub-store"] CMD ["serve", "-c", "/app/config/config.yaml"]