2020-04-12 04:09:41 +03:00
|
|
|
# build environment
|
|
|
|
FROM node:12 as builder
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
COPY package*.json ./
|
|
|
|
RUN npm install
|
2020-04-14 17:51:31 +03:00
|
|
|
#RUN printf '\nAm rulat npm install!\n\n'
|
|
|
|
#RUN echo '\nRezultat:\n'
|
|
|
|
#RUN ls
|
|
|
|
|
2020-04-12 04:09:41 +03:00
|
|
|
|
|
|
|
COPY . ./
|
|
|
|
RUN npm run build
|
|
|
|
|
2020-04-14 17:51:31 +03:00
|
|
|
#RUN printf '\nAm copiat restul fisierelor si am rulat build!\n\n'
|
|
|
|
#RUN echo '\nRezultat:\n'
|
|
|
|
#RUN ls
|
|
|
|
|
2020-04-12 04:09:41 +03:00
|
|
|
# production environment
|
|
|
|
FROM node:12
|
|
|
|
COPY --from=builder /app/build ./build
|
2020-04-14 23:04:58 +03:00
|
|
|
COPY --from=builder /app/tools/mockData.js ./build/api/
|
|
|
|
COPY --from=builder /app/tools/createMockDb.js ./build/api/
|
|
|
|
COPY --from=builder /app/tools/apiServer.js ./build/api/
|
2020-04-14 17:51:31 +03:00
|
|
|
|
|
|
|
#RUN printf '\nAm copiat fisierele din build in imaginea finala!\n\n'
|
|
|
|
#RUN echo '\nRezultat:\n'
|
|
|
|
#RUN ls
|
|
|
|
|
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-14 23:04:58 +03:00
|
|
|
WORKDIR /build
|
|
|
|
RUN npm install json-server --save-prod
|
|
|
|
|
|
|
|
RUN printf '\n- Am instalat json-server!\n\n'
|
2020-04-14 17:51:31 +03:00
|
|
|
#RUN ls
|
|
|
|
|
2020-04-14 23:04:58 +03:00
|
|
|
WORKDIR /
|
|
|
|
|
2020-04-12 04:09:41 +03:00
|
|
|
EXPOSE 80
|
2020-04-14 17:51:31 +03:00
|
|
|
|
2020-04-14 23:04:58 +03:00
|
|
|
#CMD ["sh", "-c", "node build/api/createMockDb.js && node build/api/apiServer.js && serve -s build -p 80"]
|
|
|
|
#CMD ["serve", "-s", "build", "-p", "80"]
|
|
|
|
|
|
|
|
#CMD ["sh", "-c", "node build/api/createMockDb.js && node build/api/apiServer.js", "serve", "-s", "build", "-p", "80"]
|