Files
backend_v2/Dockerfile.prebuilt

28 lines
942 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.

# 预构建镜像:二进制在本机(GOOS=linux)编好,服务器只负责打层。
# 用途:服务器资源紧张时,跳过容器内的 go build。
# 由 scripts/push-build.sh 与 deploy.sh --prebuilt 使用;构建上下文里的
# server-linux-amd64 由本机交叉编译产出(已在 .gitignore / .dockerignore 中)。
FROM alpine:3.20
RUN apk add --no-cache ca-certificates tzdata
WORKDIR /app
COPY server-linux-amd64 /app/server
# 从 Windows 传上来的文件没有执行位(644),必须显式补上,否则容器启动报
# exec: "/app/server": permission denied
RUN chmod +x /app/server
COPY configs ./configs
RUN mkdir -p /app/uploads
ENV CONFIG_PATH=/app/configs/config.yml \
GIN_MODE=release \
UPLOAD_DIR=/app/uploads
EXPOSE 8090 8091 8092
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD wget -qO- http://127.0.0.1:8090/api/health || exit 1
CMD ["/app/server"]