FROM costbase:2.0 as build

WORKDIR /home/ConstructionCost

COPY package.json /home/ConstructionCost/
COPY .babelrc /home/ConstructionCost/

RUN cnpm install

FROM base-alpine:latest as babel
COPY --from=build /home/ConstructionCost /home/YangHuCost

COPY config /home/YangHuCost/src/config/
COPY logs /home/YangHuCost/src/logs/
COPY modules /home/YangHuCost/src/modules/
COPY public /home/YangHuCost/src/public/
COPY importserver.js server.js socket.js  /home/YangHuCost/src/

WORKDIR /home/YangHuCost

RUN babel src -d dist

FROM base-alpine:latest


COPY . /home/YangHuCost

WORKDIR /home/YangHuCost

COPY --from=babel /home/YangHuCost/dist /home/YangHuCost
COPY --from=babel /home/YangHuCost/node_modules /home/YangHuCost/node_modules/
COPY public/web /home/YangHuCost/public/web/


RUN gulp build

ENV NODE_ENV=prod

ENTRYPOINT ["npm", "run"]

CMD ["server"]


