为什么PM2在Docker容器上找不到构建文件?

问题描述

我正在研究nuxtjs项目,并且正在使用docker进行部署。但是当我将pm2作为CMD运行时,在我的nodejs应用dockerfile中,构建目录存在目标错误

我的节点应用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目录中。

和ecosystem.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-撰写我的站点服务:

  site:
      container_name: site
      build:
         context: ./site
         dockerfile: Dockerfile
      networks:
         - laravel

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)