【发布时间】:2020-10-28 05:11:21
【问题描述】:
我正在开发一个 nuxtjs 项目,我正在使用 docker 来部署它。但是在我的 nodejs 应用程序 dockerfile 中,当我将 pm2 作为 CMD 运行时,我有构建目录的目标错误,
我的节点应用程序 dockerfile:
FROM node:12.4-alpine
ADD package*.json ./
RUN npm install
RUN npm install -g pm2
ADD . .
RUN npm run build
CMD ["sh", "-c" ,"pm2-runtime start ecosystem.config.js"]
当我监控 pm2 时出错:
? Nuxt Fatal Error
build files found in /ecosystem.config.js/.nuxt/dist/server.
Use either `nuxt build` or `builder.build()` or start nuxt in development mode.
由于错误显示未找到构建文件,但构建文件已创建并且位于 /site/.nuxt 目录中。
和生态系统.config.js:
module.exports = {
apps: [
{
name: 'site',
exec_mode: 'cluster',
instances: '1', // Or a number of instances
script: './node_modules/nuxt/bin/nuxt.js',
cwd: './',
args: 'start',
env: {
"HOST": "0.0.0.0",
"PORT": 3000,
"APP_ENV": "production"
}
}
]
}
docker-compose 我的站点服务:
site:
container_name: site
build:
context: ./site
dockerfile: Dockerfile
networks:
- laravel
【问题讨论】:
-
你找到解决办法了吗?
-
你有解决办法吗?
标签: node.js docker docker-compose nuxt.js pm2