Files
gin_layout/Dockerfile
T
2026-11-12 09:34:43 +08:00

21 lines
683 B
Docker

FROM golang:1.27.3-alpine AS builder
RUN apk add --no-cache git openssh-client
ENV GOPRIVATE=git.vitatech.com.cn
RUN git config --global url."ssh://git@git.vitatech.com.cn:12222/".insteadOf "https://git.vitatech.com.cn/" \
&& mkdir -p -m 0700 /root/.ssh
WORKDIR /src
COPY go.mod go.sum ./
RUN --mount=type=ssh,required=true \
--mount=type=secret,id=git_known_hosts,target=/root/.ssh/known_hosts,required=true \
go mod download
COPY . .
RUN CGO_ENABLED=0 go build -mod=readonly -trimpath -o /out/api ./cmd/api
FROM alpine:3.23
RUN apk add --no-cache ca-certificates tzdata
WORKDIR /app
COPY --from=builder /out/api ./api
USER 65532:65532
EXPOSE 8080
ENTRYPOINT ["./api"]