rxc-app/Dockerfile

45 lines
1.4 KiB
Docker

# 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
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'
COPY --from=builder /app/start/start2.sh ./application/
RUN chmod +x application/start2.sh
#install static server || Alternativ se poate utiliza si http-server
RUN npm install -g serve
WORKDIR /application/api
RUN printf '\n\n- Install json-server in api directory\n'
RUN npm install json-server --save-prod
WORKDIR /application
EXPOSE 80 3001
CMD ["./start2.sh"]
#CMD ["sh", "-c", "node application/api/createMockDb.js && node application/api/apiServer.js && serve -s application/front -p 80"]
#CMD ["serve", "-s", "build", "-p", "80"]
#CMD ["sh", "-c", "node application/api/createMockDb.js && node application/api/apiServer.js", "serve", "-s", "application/front", "-p", "80"]