20 lines
526 B
Docker
20 lines
526 B
Docker
FROM golang:1.23-alpine AS builder
|
|
ARG CGO_ENABLED=0
|
|
WORKDIR /app
|
|
|
|
COPY go.mod go.sum ./
|
|
RUN go env -w GO111MODULE=on
|
|
RUN go env -w GOPROXY=https://goproxy.cn,direct
|
|
RUN go mod download
|
|
COPY main.go ./
|
|
|
|
RUN go build -o api
|
|
|
|
FROM alpine:3.20 AS certs
|
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
|
|
RUN apk add --no-cache ca-certificates
|
|
|
|
FROM scratch
|
|
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
|
COPY --from=builder /app/api /api
|
|
ENTRYPOINT ["/api"] |