AIClient-2-API/Dockerfile
hex2077 ddc9533f21 build(Dockerfile): 添加必要的系统工具并优化依赖安装
添加 tar 和 git 工具以支持更新功能和版本检查,同时保持 npm install 命令的简洁性
2026-01-07 23:16:42 +08:00

41 lines
No EOL
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.

# 使用官方Node.js运行时作为基础镜像
# 选择20-alpine版本以满足undici包的要求需要Node.js >=20.18.1
FROM node:20-alpine
# 设置标签
LABEL maintainer="AIClient2API Team"
LABEL description="Docker image for AIClient2API server"
# 安装必要的系统工具tar 用于更新功能git 用于版本检查)
RUN apk add --no-cache tar git
# 设置工作目录
WORKDIR /app
# 复制package.json和package-lock.json如果存在
COPY package*.json ./
# 安装依赖
# 使用--production标志只安装生产依赖减小镜像大小
# 使用--omit=dev来排除开发依赖
RUN npm install
# 复制源代码
COPY . .
USER root
# 创建目录用于存储日志和系统提示文件
RUN mkdir -p /app/logs
# 暴露端口
EXPOSE 3000 8085 8086 19876-19880
# 添加健康检查
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node healthcheck.js || exit 1
# 设置启动命令
# 使用默认配置启动服务器,支持通过环境变量配置
# 通过环境变量传递参数例如docker run -e ARGS="--api-key mykey --port 8080" ...
CMD ["sh", "-c", "node src/master.js $ARGS"]