how to start vuejs ssr server in docker

I have a vuejs application with @akryum/ssr

While doing

npm run ssr:serve

or

npm run ssr:start

everything works as it should. But when I try to use docker:

version: '3.7'

services:
  npm:
    build:
      context: ./
    ports:
      - "8080:8080"
    volumes:
      - ./:/var/www/html

Dockerfile

FROM node:14.0.0

WORKDIR /var/www/html

EXPOSE 8080

CMD ["npm", "run", "serve"]

Only the option without ssr works: npm run serve

Using

CMD ["npm", "run", "ssr:start"]

i open http://localhost:8080/ and get error

ERR_CONNECTION_RESET

In my package.json

  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "ssr:build": "vue-cli-service ssr:build",
    "ssr:serve": "vue-cli-service ssr:serve",
    "ssr:start": "PORT=8080 cross-env NODE_ENV=production vue-cli-service ssr:serve --mode production"
  },

On startup I see

npm_1  | [16:36:39] Server listening on localhost:8080

means the ports are correct

Source: Docker Questions

LEAVE A COMMENT