-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (26 loc) · 750 Bytes
/
Copy pathDockerfile
File metadata and controls
34 lines (26 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
ARG GO_IMAGE=golang:1.24-alpine
ARG RUN_IMAGE=alpine:3.20
FROM ${GO_IMAGE} AS builder
WORKDIR /src
ARG GOPROXY=https://proxy.golang.org,direct
ENV GOPROXY=${GOPROXY} \
CGO_ENABLED=0 \
GOOS=linux
COPY go.mod ./
RUN go mod download
COPY cmd ./cmd
COPY internal ./internal
RUN go build -trimpath -ldflags="-s -w" -o /out/cmd2api ./cmd/cmd2api
FROM ${RUN_IMAGE}
RUN apk --no-cache add ca-certificates tzdata wget \
&& adduser -D -H -u 65532 app
WORKDIR /app
COPY --from=builder /out/cmd2api /app/cmd2api
ENV HOST=0.0.0.0 \
PORT=8787 \
TZ=Asia/Shanghai
USER 65532
EXPOSE 8787
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s \
CMD wget -qO- http://127.0.0.1:8787/health >/dev/null || exit 1
ENTRYPOINT ["/app/cmd2api"]