Files
backend_v2/Dockerfile
toom1996 30c9f21da4 update
2026-08-26 10:45:21 +08:00

28 lines
588 B
Docker
Raw Permalink 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.

# ---- 构建阶段 ----
FROM golang:1.26-alpine AS build
WORKDIR /src
# 先拉依赖,利用层缓存
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# 静态链接,便于在 alpine 运行时直接运行
RUN CGO_ENABLED=0 GOOS=linux go build -o /out/server ./cmd/server
# ---- 运行阶段 ----
FROM alpine:3.20
RUN apk add --no-cache ca-certificates tzdata
WORKDIR /app
COPY --from=build /out/server /app/server
COPY configs ./configs
# 上传目录(容器外挂 volume)
RUN mkdir -p /app/uploads
ENV CONFIG_PATH=/app/configs/config.yml
EXPOSE 8090
CMD ["/app/server"]