2020-04-12 04:09:41 +03:00
|
|
|
# build environment
|
|
|
|
FROM node:12 as builder
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
COPY package*.json ./
|
|
|
|
RUN npm install
|
|
|
|
|
|
|
|
COPY . ./
|
|
|
|
RUN npm run build
|
|
|
|
|
|
|
|
# production environment
|
|
|
|
FROM node:12
|
2020-04-14 17:51:31 +03:00
|
|
|
|
2020-04-15 00:15:32 +03:00
|
|
|
RUN printf '\n\n- Copy application frontend files\n'
|
|
|
|
COPY --from=builder /app/build ./application/front
|
|
|
|
COPY --from=builder /app/start/front.sh ./application/front/
|
|
|
|
RUN chmod +x application/front/front.sh
|
|
|
|
|
|
|
|
RUN printf '\n\n- Copy application api files\n'
|
|
|
|
COPY --from=builder /app/tools/mockData.js ./application/api/
|
|
|
|
COPY --from=builder /app/tools/createMockDb.js ./application/api/
|
|
|
|
COPY --from=builder /app/tools/apiServer.js ./application/api/
|
|
|
|
COPY --from=builder /app/start/api.sh ./application/api/
|
|
|
|
RUN chmod +x application/api/api.sh
|
|
|
|
|
|
|
|
RUN printf '\n\n- Copy application starting script\n'
|
2020-04-15 01:09:23 +03:00
|
|
|
COPY --from=builder /app/start/start2.sh ./application/
|
|
|
|
RUN chmod +x application/start2.sh
|
2020-04-14 17:51:31 +03:00
|
|
|
|
2020-04-14 23:04:58 +03:00
|
|
|
#install static server || Alternativ se poate utiliza si http-server
|
2020-04-14 17:51:31 +03:00
|
|
|
RUN npm install -g serve
|
|
|
|
|
2020-04-15 00:15:32 +03:00
|
|
|
WORKDIR /application/api
|
|
|
|
RUN printf '\n\n- Install json-server in api directory\n'
|
2020-04-14 23:04:58 +03:00
|
|
|
RUN npm install json-server --save-prod
|
|
|
|
|
2020-04-15 00:15:32 +03:00
|
|
|
WORKDIR /application
|
2020-04-14 23:04:58 +03:00
|
|
|
|
2020-04-15 01:02:39 +03:00
|
|
|
EXPOSE 80 3001
|
2020-04-14 17:51:31 +03:00
|
|
|
|
2020-04-15 01:09:23 +03:00
|
|
|
CMD ["./start2.sh"]
|
2020-04-15 00:15:32 +03:00
|
|
|
#CMD ["sh", "-c", "node application/api/createMockDb.js && node application/api/apiServer.js && serve -s application/front -p 80"]
|
2020-04-14 23:04:58 +03:00
|
|
|
#CMD ["serve", "-s", "build", "-p", "80"]
|
|
|
|
|
2020-04-15 00:15:32 +03:00
|
|
|
#CMD ["sh", "-c", "node application/api/createMockDb.js && node application/api/apiServer.js", "serve", "-s", "application/front", "-p", "80"]
|