相关文章推荐
幸福的芹菜  ·  docker alpine bashrc-掘金·  1 年前    · 
旅行中的书包  ·  Plan SIP Gateway - ...·  1 年前    · 
率性的稀饭  ·  C# ...·  1 年前    · 
多情的圣诞树  ·  java bson json ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm working on a nuxtjs project and I'm using docker for deploying it. but In my nodejs app dockerfile when I'm runinng pm2 as CMD I have destination error for build directory,

My node app 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"]

and error when I monit 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. 

As the error show build file not found but the build files are created and is in /site/.nuxt directory.

And 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-compose my site service:

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

Try to edit files:

ecosystem.json or ecosystem.yml:

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

ecosystem.config.js:

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

nuxt.config.js:

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

here is the issue on github: https://github.com/nuxt/nuxt.js/issues/8704#issuecomment-876441236

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.