update
This commit is contained in:
27
Dockerfile
Normal file
27
Dockerfile
Normal file
@ -0,0 +1,27 @@
|
||||
# ---- 构建阶段 ----
|
||||
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"]
|
||||
Reference in New Issue
Block a user