46 lines
1.0 KiB
Docker
46 lines
1.0 KiB
Docker
FROM golang:1.27.1-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
COPY cmd/api/ ./cmd/api/
|
|
COPY cmd/jobs/ ./cmd/jobs/
|
|
COPY cmd/relay/ ./cmd/relay/
|
|
COPY internal/ ./internal/
|
|
|
|
RUN --mount=type=cache,id=highload-go-build,target=/root/.cache/go-build,sharing=locked \
|
|
CGO_ENABLED=0 GOOS=linux go build -p 2 -trimpath -o /app/server ./cmd/api && \
|
|
CGO_ENABLED=0 GOOS=linux go build -p 2 -trimpath -o /app/jobs ./cmd/jobs && \
|
|
CGO_ENABLED=0 GOOS=linux go build -p 2 -trimpath -o /app/relay ./cmd/relay
|
|
|
|
|
|
FROM alpine:3.22 AS runtime
|
|
|
|
RUN addgroup -S app && adduser -S app -G app
|
|
|
|
WORKDIR /app
|
|
|
|
USER app
|
|
|
|
FROM runtime AS cleanup
|
|
|
|
COPY --from=builder /app/jobs ./jobs
|
|
ENTRYPOINT ["/app/jobs"]
|
|
CMD ["cleanup"]
|
|
|
|
FROM runtime AS relay
|
|
COPY --from=builder /app/relay ./relay
|
|
CMD ["./relay"]
|
|
|
|
FROM runtime AS api
|
|
|
|
COPY --from=builder /app/server ./server
|
|
EXPOSE 8080
|
|
|
|
HEALTHCHECK --interval=10s --timeout=3s --start-period=3s --retries=3 \
|
|
CMD wget -q -O /dev/null http://127.0.0.1:8080/health/ready || exit 1
|
|
|
|
CMD ["./server"]
|