xiaowei-system/skills/devops/docker/templates/newapi.Dockerfile

34 lines
801 B
Docker
Executable File
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.

# newapi Dockerfile — production-ready example
# LLM 网关服务,使用 Go 静态编译二进制
# 路径templates/newapi/Dockerfile
FROM alpine:3.19 AS runner
# 安装证书和时区数据
RUN apk add --no-cache ca-certificates tzdata && \
update-ca-certificates
# 创建非 root 用户
RUN addgroup -S app && adduser -S app -G app
# 数据卷目录(挂载点)
RUN mkdir -p /data /logs && chown app:app /data /logs
WORKDIR /app
# 复制二进制(通过 --build-arg 或 COPY --from=builder 传入)
COPY newapi /app/newapi
RUN chown app:app /app/newapi && chmod +x /app/newapi
USER app
ENV PYTHONUNBUFFERED=1
ENV PORT=3000
EXPOSE 3000
# 数据卷声明(持久化数据)
VOLUME ["/data", "/logs"]
ENTRYPOINT ["/app/newapi"]
CMD ["--port", "3000", "--log-dir", "/logs"]