Files
Mycontent/soul-api/deploy/Dockerfile
Alex-larget 36b8524bc9 123123
2026-04-07 15:59:13 +08:00

44 lines
1.1 KiB
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.

# 以下由「部署管理器」根据项目配置在保存时自动生成/更新
# 根据「构建命令」解析编译目标;可在项目表单中修改 buildCmd
FROM golang:1.25 AS builder
WORKDIR /src
# 与 deploy-manager 传入的 --build-arg GOPROXY 对应;无 ARG 时 build-arg 会被忽略go 会走默认 proxy.golang.org
ARG GOPROXY=https://goproxy.cn,direct
ENV GOPROXY=${GOPROXY}
ARG GOSUMDB=sum.golang.google.cn
ENV GOSUMDB=${GOSUMDB}
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w" -o /out/soul-api ./cmd/server
FROM alpine:3.19
WORKDIR /app
RUN apk add --no-cache ca-certificates tzdata wget && \
addgroup -S app && adduser -S -G app app
COPY --from=builder /out/soul-api /app/soul-api
# 若需要微信支付证书,创建 certs/ 后取消下行注释
# COPY certs/ /app/certs/
RUN mkdir -p /app/uploads /app/log && chown -R app:app /app
ENV APP_ENV=production
ENV GIN_MODE=release
ENV PORT=8080
ENV UPLOAD_DIR=/app/uploads
EXPOSE 8080
USER app
CMD ["/app/soul-api"]