Files
cryptoHermes/Dockerfile
2026-05-24 21:40:23 +08:00

39 lines
1.1 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
FROM golang:1.23-alpine AS builder
ARG GOPROXY=https://proxy.golang.org,direct
ARG HTTP_PROXY
ARG HTTPS_PROXY
ARG NO_PROXY
ARG http_proxy
ARG https_proxy
ARG no_proxy
ENV GOPROXY=${GOPROXY} \
HTTP_PROXY=${HTTP_PROXY} \
HTTPS_PROXY=${HTTPS_PROXY} \
NO_PROXY=${NO_PROXY} \
http_proxy=${http_proxy} \
https_proxy=${https_proxy} \
no_proxy=${no_proxy}
WORKDIR /src
COPY go.mod go.sum* ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o /out/app ./cmd/app \
&& CGO_ENABLED=0 GOOS=linux go build -o /out/backfill ./cmd/backfill
FROM alpine:3.20
# wget 用于容器 healthcheckca-certificates 用于 TLStzdata 用于本地时区
RUN apk add --no-cache ca-certificates tzdata wget
WORKDIR /app
COPY --from=builder /out/app /app/app
COPY --from=builder /out/backfill /app/backfill
EXPOSE 8080
# 容器级 healthcheck拒绝把 unhealthy 容器纳入负载均衡
HEALTHCHECK --interval=15s --timeout=3s --start-period=20s --retries=3 \
CMD wget --spider -q http://127.0.0.1:8080/v1/health || exit 1
ENTRYPOINT ["/app/app"]