修复打包环境!

This commit is contained in:
2025-12-09 11:27:52 +08:00
parent 59c127806c
commit c3e669b61e
2 changed files with 15 additions and 26 deletions
+13 -24
View File
@@ -1,36 +1,25 @@
# 使用 Node.js 24 作为基础镜像(Alpine 版)
FROM node:24-alpine
FROM node:24
# 设置工作目录
WORKDIR /app
# 安装 PM2 全局
RUN npm install -g pm2
# 复制 package.json 和 package-lock.json
COPY package*.json ./
# 安装 pnpm
RUN npm install -g pnpm
# 安装依赖(包含 devDependencies 用于构建,包含可选依赖以获取 Linux 原生绑定)
RUN npm ci --include=dev
# 复制项目文件
# 复制源代码
COPY . .
# 安装项目依赖(建议使用 pnpm,但你写的是 npm install .
# 如果项目用 pnpm,请改为:RUN pnpm install --frozen-lockfile
RUN npm install .
# 构建应用
RUN npm run build:production:multi
# 设置 node_modules/.bin 目录的执行权限(通常不需要,但保留)
RUN chmod -R +x node_modules/.bin
# 安装 PM2
RUN npm install -g pm2
# 创建 logs 目录
RUN mkdir -p logs
EXPOSE 51703-51708
# 暴露端口
EXPOSE 51703 51704 51705 51706 51707 51708
# 设置环境变量
ENV NODE_ENV=production
# 确保 start.sh 可执行(777 权限过大,建议 755
RUN chmod +x ./start.sh
# 启动命令
CMD ["./start.sh"]
# 直接启动 PM2,不需要重新构建(构建已在上面完成
CMD ["pm2-runtime", "start", "ecosystem.config.cjs", "--env", "production"]
+2 -2
View File
@@ -1,6 +1,6 @@
services:
docreview:
build: .
image: docreview-app:latest
container_name: docreview-app
command: ["/bin/sh", "./start.sh"]
ports:
@@ -14,7 +14,7 @@ services:
- NODE_ENV=production
volumes:
- .:/app # 挂载整个项目目录
#- /app/node_modules # 排除node_modules,使用容器内的
- /app/node_modules # 排除node_modules,使用容器内的
restart: unless-stopped
networks:
- docreview-network