1- FROM node:14-alpine AS building
1+ FROM node:14-alpine AS building_stage
22WORKDIR /app
3- # ENV USERNAME timetracker
4- # ENV HOME /home/${USERNAME}
5- # RUN useradd -ms /bin/bash ${USERNAME}
6- # WORKDIR ${HOME}/time-tracker-ui
73COPY . /app
8- # RUN chown ${USERNAME}:${USERNAME} -R ${HOME}/time-tracker-ui
9- # RUN chmod -R 777 ${HOME}/time-tracker-ui
10- # USER ${USERNAME}
114RUN npm cache clean --force && npm install
125EXPOSE 4200 9876
136RUN source .stage.env && npm run build
14- # >> scrt &&
15- #
167
17- FROM nginx:1.21 AS production
8+
9+ FROM nginx:1.21 AS production_stage
1810COPY nginx.conf /etc/nginx/conf.d/default.conf
19- COPY --from=building /app/dist/time-tracker /usr/share/nginx/html
20- # FIXME: Actually if we can deploy to azure in port 80 we need a root user
21- # Maybe we can refactor this dockerfile to use root user directly this is not a good approach y
22- # security terms. It's a good practice to have rootless in containers so for this
23- # we can to refactor this dockerfile and the terraform module to deploy in other ports because
24- # Ports below 1024 needs root permisions.
11+ COPY --from=building_stage /app/dist/time-tracker /usr/share/nginx/html
12+ EXPOSE 80
13+
14+
15+ FROM node:14-alpine AS building_prod
16+ WORKDIR /app
17+ COPY . /app
18+ RUN npm cache clean --force && npm install
19+ EXPOSE 4200 9876
20+ RUN source .prod.env && npm run build
2521
26- # USER ${USERNAME}
2722
23+ FROM nginx:1.21 AS production_prod
24+ COPY nginx.conf /etc/nginx/conf.d/default.conf
25+ COPY --from=building_prod /app/dist/time-tracker /usr/share/nginx/html
2826EXPOSE 80
0 commit comments