Files
web/server/Dockerfile

18 lines
644 B
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 需在项目根目录构建: docker build -f server/Dockerfile .
# 使用 vendor 构建,无需在构建时访问 proxy.golang.org服务器无外网时也能 build
FROM golang:1.21-alpine AS builder
WORKDIR /build
COPY server/ ./
# 构建参数:脚本可传 GOPROXY避免 proxy.golang.org 超时;有 vendor 时主要用 -mod=vendor 离线构建
ARG GOPROXY=https://goproxy.cn,direct
ENV GOPROXY=$GOPROXY
RUN CGO_ENABLED=0 go build -mod=vendor -o /app/server .
FROM alpine:3.19
WORKDIR /app
RUN apk add --no-cache ca-certificates tzdata
ENV TZ=Asia/Shanghai
COPY --from=builder /app/server .
EXPOSE 9527
ENTRYPOINT ["./server"]