【问题标题】:Why PM2 can not found builds file on docker container?为什么 PM2 在 docker 容器上找不到构建文件?
【发布时间】: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


【解决方案1】:

尝试编辑文件:

ecosystem.json 或生态系统.yml:

args: "start -c /xxx/xxx/nuxt.config.js"

生态系统.config.js:

args: `start -c ${process.cwd()}/nuxt.config.js`,

nuxt.config.js:

rootDir: process.cwd()
buildDir: process.cwd() + '/.nuxt/'

这里是github上的问题:https://github.com/nuxt/nuxt.js/issues/8704#issuecomment-876441236

【讨论】:

    猜你喜欢
    • 2017-06-29
    • 1970-01-01
    • 2022-07-22
    • 2020-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-01
    • 1970-01-01
    相关资源
    最近更新 更多