24 lines
837 B
Docker
24 lines
837 B
Docker
FROM golang:1.25-alpine AS build
|
|
WORKDIR /src
|
|
COPY go.mod go.sum* ./
|
|
# proxy.golang.org redirects module zips to storage.googleapis.com, which
|
|
# some networks/ISPs intermittently time out on. goproxy.cn is a
|
|
# non-Google-hosted mirror that avoids that specific route; go.sum already
|
|
# pins hashes so this doesn't weaken verification. Swap or drop this if it
|
|
# doesn't apply to your build environment.
|
|
ENV GOPROXY=https://goproxy.cn,direct
|
|
RUN go mod download
|
|
COPY . .
|
|
RUN CGO_ENABLED=0 go build -o /out/server ./cmd/server
|
|
|
|
FROM alpine:3.20
|
|
RUN apk add --no-cache ca-certificates \
|
|
&& addgroup -S app && adduser -S -G app app
|
|
WORKDIR /app
|
|
COPY --from=build --chown=app:app /out/server ./server
|
|
COPY --chown=app:app migrations ./migrations
|
|
COPY --chown=app:app CHANGELOG.md ./CHANGELOG.md
|
|
USER app
|
|
EXPOSE 3000
|
|
ENTRYPOINT ["./server"]
|