Files
micro_layout/build/srv/Dockerfile
T
2026-11-12 09:34:43 +08:00

24 lines
873 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/srv ./cmd/srv \
&& CGO_ENABLED=0 go build -mod=readonly -trimpath -o /out/grpc-health ./cmd/healthcheck
FROM alpine:3.23
RUN apk add --no-cache ca-certificates tzdata
WORKDIR /app
RUN mkdir -p logs && chown 65532:65532 logs
COPY --from=builder /out/srv ./srv
COPY --from=builder /out/grpc-health ./grpc-health
USER 65532:65532
EXPOSE 50112
ENTRYPOINT ["./srv"]