petervmeijgaard/vue-2-boilerplate

Can't make it work under docker.

PiotrSierankiewicz opened this issue · 2 comments

Hi,
Could you deliver sample dockerfile that would work with this boilerplate?
I can't make it work, mine is:
FROM node:4.6.1

RUN apt-get update && apt-get install python-dev -y
RUN npm cache clean -f
RUN npm install npm@4.6.1 -g

RUN mkdir /project
&& chmod -R 777 /project

RUN useradd -ms /bin/bash docker
USER docker

WORKDIR /project

#CMD [bash]

after npm run dev i get:
(Error is somehow connected with babel I guess)

error in ./src/App.vue

Syntax Error: Unexpected token {

@ ./src/main.js 50:0-24
@ multi ./build/dev-client ./src/main.js

error in ./src/routes/index.js

Syntax Error: Unexpected token (13:21)

11 | path: '/home',
12 | name: 'home.index',

13 | component: () => import('@/pages/Home/Index'),
|

@PiotrSierankiewicz, I'm not sure if this will help at all, but this is how I got the app running in a local Docker image:

I first did a npm run build, which creates the assets in a /dist directory. Then, I created an image with the following Dockerfile:

FROM node:9.3-alpine

RUN addgroup -S vue && adduser -S -g vue vue

ENV SRC=dist
ENV HOME=/home/vue
ENV HOME_APP=$HOME/app
ENV NODE_ENV=production

WORKDIR $HOME_APP

RUN chown -R vue:vue $HOME/* /usr/local/
RUN npm install http-server -g

COPY $SRC $HOME_APP

USER vue

ENTRYPOINT ["http-server", "--"]

This will copy the /dist directory over, and install the http-server module. The container will auto-start launching a web server on (default) port 8080 - I mapped this to port 9090 on my localhost.

Open the browser with http://localhost:9090, and the app is served.

Hope this helps.

Thanks!
for some reason docker requires:
npm install -g eslint
npm install --save-dev node-sass
in dockerfile