File tree Expand file tree Collapse file tree 4 files changed +39
-13
lines changed Expand file tree Collapse file tree 4 files changed +39
-13
lines changed Original file line number Diff line number Diff line change 3030 creds : ${{ secrets.AZURE_CREDENTIALS }}
3131
3232 - name : Build the docker image
33- run : make build_prod
33+ run : |-
34+ docker build \
35+ --target production -t timetracker_ui \
36+ --build-arg API_URL="${{secrets.API_URL_STAGE}}" \
37+ --build-arg AUTHORITY="${{secrets.AUTHORITY}}" \
38+ --build-arg CLIENT_ID="${{secrets.CLIENT_ID_STAGE}}" \
39+ --build-arg CLIENT_URL="${{ secrets.CLIENT_URL_STAGE}}" \
40+ --build-arg SCOPES="${{secrets.SCOPES}}" \
41+ --build-arg AZURE_APP_CONFIGURATION_CONNECTION_STRING="${{secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING}}" \
42+ .
3443
3544 - name : Publish docker image to stage azure container registry
3645 run : |
Original file line number Diff line number Diff line change 1- FROM node:14 AS development
1+ FROM node:14 AS building
22
33ENV USERNAME timetracker
44ENV HOME /home/${USERNAME}
@@ -12,21 +12,30 @@ USER ${USERNAME}
1212RUN npm cache clean --force && npm install
1313EXPOSE 4200
1414EXPOSE 9876
15- CMD ${HOME}/time-tracker-ui/node_modules/.bin/ng serve --host 0.0.0.0 --disableHostCheck
15+ ARG API_URL
16+ ARG AUTHORITY
17+ ARG CLIENT_ID
18+ ARG CLIENT_URL
19+ ARG SCOPES
20+ ARG AZURE_APP_CONFIGURATION_CONNECTION_STRING
21+
22+ RUN API_URL=${API_URL} \
23+ AUTHORITY=${AUTHORITY} \
24+ CLIENT_ID=${CLIENT_ID} \
25+ CLIENT_URL=${CLIENT_URL} \
26+ SCOPES=${SCOPES} \
27+ AZURE_APP_CONFIGURATION_CONNECTION_STRING=${AZURE_APP_CONFIGURATION_CONNECTION_STRING}
1628
17-
18-
19- FROM development as build
20- COPY .env .
2129RUN npm run build
2230
31+
2332FROM nginx:1.21 AS production
2433
2534ENV USERNAME app
2635RUN useradd -ms /bin/bash ${USERNAME}
2736
2837COPY nginx.conf /etc/nginx/conf.d/default.conf
29- COPY --from=build /home/timetracker/time-tracker-ui/dist/time-tracker /usr/share/nginx/html
38+ COPY --from=building /home/timetracker/time-tracker-ui/dist/time-tracker /usr/share/nginx/html
3039COPY .env /usr/share/nginx/html
3140RUN chown -R ${USERNAME}:${USERNAME} /var/cache/nginx && \
3241 chown -R ${USERNAME}:${USERNAME} /var/log/nginx && \
Original file line number Diff line number Diff line change @@ -55,12 +55,20 @@ publish: require-acr-arg require-image_tag-arg ## Upload a docker image to the s
5555 docker push $(acr ) .azurecr.io/timetracker_ui:$(image_tag )
5656
5757.PHONY : build_prod
58- build_prod : # # Create docker image with dependencies needed for production.
59- docker build --target production -t timetracker_ui_prod -f Dockerfile .
58+ build_prod : # # Create docker image with dependencies needed for production -- to test locally only
59+ docker build \
60+ --target production -t timetracker_ui_prod \
61+ --build-arg API_URL=" ${API_URL} " \
62+ --build-arg AUTHORITY=" ${AUTHORITY} " \
63+ --build-arg CLIENT_ID=" ${CLIENT_ID} " \
64+ --build-arg CLIENT_URL=" ${CLIENT_URL} " \
65+ --build-arg SCOPES=" ${SCOPES} " \
66+ --build-arg AZURE_APP_CONFIGURATION_CONNECTION_STRING=" ${AZURE_APP_CONFIGURATION_CONNECTION_STRING} " \
67+ .
6068
6169.PHONY : run_prod
62- run_prod : # # Execute timetracker_ui_prod docker container.
63- docker run -d -p 80:80 --env-file ./.env -- name timetracker_ui_prod timetracker_ui_prod
70+ run_prod : # # Execute timetracker_ui_prod docker container -- to test locally only
71+ docker run -d -p 80:80 --name timetracker_ui_prod timetracker_ui_prod
6472
6573.PHONY : stop_prod
6674stop_prod : # # Stop container timetracker_ui_prod.
You can’t perform that action at this time.
0 commit comments