Commit 7886d148 authored by xiezhi's avatar xiezhi

简化 Dockerfile

- 移除复杂的用户权限设置
- 移除健康检查配置
- 移除启动脚本依赖
- 保留核心功能:依赖安装、构建、启动
- 从42行简化到21行
parent 470ac4d9
# 使用 Node.js 22 官方镜像作为基础镜像
FROM hb.eazytec-cloud.com/eazytec/eazydevelop-node:ubuntu22.04-node22-latest FROM hb.eazytec-cloud.com/eazytec/eazydevelop-node:ubuntu22.04-node22-latest
# 设置工作目录
WORKDIR /app WORKDIR /app
# 设置环境变量 # 复制依赖文件
ENV NODE_ENV=production
ENV PORT=${APP_PORT_1:-8000}
# 复制 package.json 和 package-lock.json(如果存在)
COPY package*.json ./ COPY package*.json ./
# 安装依赖 # 安装依赖
...@@ -17,25 +11,11 @@ RUN npm ci ...@@ -17,25 +11,11 @@ RUN npm ci
# 复制应用代码 # 复制应用代码
COPY . . COPY . .
# 创建非 root 用户 # 构建应用
RUN addgroup -g 1001 -S nodejs RUN npm run build
RUN adduser -S threejs -u 1001
# 更改文件所有权
RUN chown -R threejs:nodejs /app
USER threejs
# 暴露端口 # 暴露端口
EXPOSE ${APP_PORT_1:-8000} EXPOSE ${APP_PORT_1:-8000}
# 设置启动脚本
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# 健康检查
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:${APP_PORT_1:-8000} || exit 1
# 启动应用 # 启动应用
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["npm", "run", "serve"] CMD ["npm", "run", "serve"]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment