universal-vue / uvue

Vue CLI plugin to create universal Vue applications with ease
https://universal-vue.github.io/docs/
MIT License
127 stars 13 forks source link

Docker: server is not defined #19

Closed cannap closed 5 years ago

cannap commented 5 years ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce docker-compose build docker-compose up -d and this is in my logs

(node:1) UnhandledPromiseRejectionWarning: ReferenceError: server is not defined
    at catch.err (/home/node/app/node_modules/@uvue/server/start.js:100:3)
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:

Expected behavior Server running?

Additional context

Please indicate versions of:

node: 11.6
vue-cli: 3.2.2
uvue:  "@uvue/core": "^0.1.0-alpha.13",
    "@uvue/server": "^0.1.0-alpha.13",
os: Windows 10 Pro
browser: 

thanks it looks like it hits the catch block and then server is just not defined but i cant tell why its hitting the catch block

yabab-dev commented 5 years ago

I'll take a look soon

Tjark-Kuehl commented 5 years ago

I have no errors running the same uvue version. Here is my config

version: '3'

volumes:
    app-dist: {}

services:
    app:
        build: .
        ports:
            - '8000:8000'
        volumes:
            - app-dist:/home/node/exomia-cloud/dist
            - ./config/:/home/node/exomia-cloud/config/:ro

    nginx:
        image: nginx:1.15-alpine
        ports:
            - '80:80'
        volumes:
            - ./nginx:/etc/nginx/conf.d
            - app-dist:/var/www/html
FROM node:10 as builder

ENV NODE_ENV production

RUN mkdir -p /home/node/exomia-cloud
WORKDIR /home/node/exomia-cloud

COPY package.json /home/node/exomia-cloud
RUN npm run install:prod

COPY . /home/node/exomia-cloud

RUN npm run build && \
    rm -rf /home/node/exomia-cloud/public

FROM node:10-alpine

ENV NODE_ENV production
ENV HOST 0.0.0.0
ENV PORT 8000

COPY --from=builder /home/node/exomia-cloud /home/node/exomia-cloud

RUN chown -R node:node /home/node/exomia-cloud

USER node
WORKDIR /home/node/exomia-cloud

CMD ["./node_modules/@uvue/server/start.js"]

maybe need a reproduction repository? Or did you fixed it by now?

cannap commented 5 years ago

i have no idea i use the ExpressAdapter its always hits the catch block https://github.com/universal-vue/uvue/blob/master/packages/%40uvue/server/start.js#L100

my server.config

import { ExpressAdapter } from '@uvue/server'

let plugins = [
  '@uvue/server/plugins/gzip',
  '@uvue/server/plugins/serverError',
  '@uvue/server/plugins/static',
  '@uvue/server/plugins/modernBuild',
  './src/server/plugin.js'
]

export default {
  adapter: ExpressAdapter,
  plugins,
  watch: [
    'server.config.js',
    'src/server/**/*.js',
    '.env',
    '.env.development.local'
  ]
}

my server plugin

import bodyParser from 'body-parser'
import routes from './apiRoutes'
import { connect } from './database/connect'
import morgan from 'morgan'
import { setup, webhookListener } from './services/mailchimp'
const mailchimpListenerPath = process.env.MAILCHIMP_LISTENER_URL
export default {
  install (server) {
    const io = require('socket.io')(process.env.SOCKET_PORT)

    setup()
    const app = server.getApp()
    connect()
    app.use(function (req, res, next) {
      req.io = io
      next()
    })

    app.use(morgan('dev'))
    app.use(bodyParser.urlencoded({ extended: true }))
    app.use(bodyParser.json())
    app.post('/' + mailchimpListenerPath, webhookListener)
    app.use('/api/v1', routes)
  }
}
yabab-dev commented 5 years ago

Sorry for late answer, i've tested it too and do not encounter your issue actually.

Can you make a simple repro repository ?

yabab-dev commented 5 years ago

Closing, no activity