FROM node:14-alpine as Builder

WORKDIR /app

ARG VUE_APP_SERVER_HOST
ARG VUE_APP_SERVER_PORT

ENV VUE_APP_SERVER_HOST=${VUE_APP_SERVER_HOST}
ENV VUE_APP_SERVER_PORT=${VUE_APP_SERVER_PORT}

COPY package.json ./
COPY package-lock.json ./
COPY public ./public
COPY src ./src
COPY vue.config.js ./
COPY babel.config.js ./
COPY jsconfig.json ./
COPY .eslint* ./
COPY server/src/client-server-shared ./server/src/client-server-shared
RUN npm install
RUN npm run build

FROM node:14-alpine

WORKDIR /app

COPY --from=Builder /app/package.json ./
COPY --from=Builder /app/package-lock.json ./
COPY --from=Builder /app/dist ./dist
COPY --from=Builder /app/node_modules ./node_modules
COPY app-server ./app-server

EXPOSE ${VUE_APP_PORT}
CMD [ "npm", "run", "appserver" ]