Skip to content

Commit 5cd8097

Browse files
Marco AguirreMarco Aguirre
authored andcommitted
Merge from master
2 parents 9dd2d22 + 2cfe188 commit 5cd8097

File tree

34 files changed

+188
-51
lines changed

34 files changed

+188
-51
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.dev.env filter=git-crypt diff=git-crypt
1+
.dev.env filter=git-crypt diff=git-crypt

.github/workflows/CD-time-tracker-ui.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ jobs:
2828

2929
- name: Inject Secrets
3030
env:
31+
AUTHORITY: ${{ secrets.authority }}
32+
API_URL: ${{ secrets.api_url }}
3133
SCOPES: ${{ secrets.scopes }}
3234
CLIENT_ID: ${{ secrets.client_id }}
33-
AUTHORITY: ${{ secrets.authority }}
35+
CLIENT_URL: ${{ secrets.client_url }}
3436
STACK_EXCHANGE_ID: ${{ secrets.stack_exchange_id }}
3537
STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.stack_exchange_access_token }}
3638
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.azure_app_configuration_connection_string }}
@@ -44,7 +46,7 @@ jobs:
4446
source .env
4547
set +a
4648
npm install
47-
npm run build --prod --if-present
49+
npm run build-legacy --if-present
4850
cp scripts/default-static-site.js ${BUILD_PATH}
4951
5052
- name: 'Deploy to Azure Web App'

.github/workflows/CI-time-tracker-ui.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ jobs:
4141

4242
- name: Inject Secrets
4343
env:
44+
AUTHORITY: ${{ secrets.AUTHORITY }}
45+
API_URL : ${{ secrets.API_URL }}
4446
SCOPES: ${{ secrets.SCOPES }}
4547
CLIENT_ID: ${{ secrets.CLIENT_ID }}
46-
AUTHORITY: ${{ secrets.AUTHORITY }}
48+
CLIENT_URL : ${{ secrets.CLIENT_URL }}
4749
STACK_EXCHANGE_ID: ${{ secrets.STACK_EXCHANGE_ID }}
4850
STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.STACK_EXCHANGE_ACCESS_TOKEN }}
4951
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING }}

.github/workflows/time-tracker-ui-cd-stage.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ jobs:
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: |

.github/workflows/time-tracker-ui-ci.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ jobs:
3232

3333
- name: Inject Secrets
3434
env:
35-
SCOPES: ${{ secrets.SCOPES }}
36-
CLIENT_ID: ${{ secrets.CLIENT_ID }}
3735
AUTHORITY: ${{ secrets.AUTHORITY }}
38-
STACK_EXCHANGE_ID: ${{ secrets.STACK_EXCHANGE_ID }}
39-
STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.STACK_EXCHANGE_ACCESS_TOKEN }}
36+
API_URL: ${{ secrets.STAGE_API_URL}}
37+
SCOPES: ${{ secrets.SCOPES }}
38+
CLIENT_ID: ${{ secrets.STAGE_CLIENT_ID }}
39+
CLIENT_URL: ${{ secrets.STAGE_CLIENT_URL }}
40+
STACK_EXCHANGE_ID: ${{ secrets.STAGE_STACK_EXCHANGE_ID }}
41+
STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.STAGE_STACK_EXCHANGE_ACCESS_TOKEN }}
4042
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING }}
4143
run: |
4244
chmod +x ./scripts/populate-keys.sh

Dockerfile

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:14 AS development
1+
FROM node:14 AS building
22

33
ENV USERNAME timetracker
44
ENV HOME /home/${USERNAME}
@@ -12,21 +12,30 @@ USER ${USERNAME}
1212
RUN npm cache clean --force && npm install
1313
EXPOSE 4200
1414
EXPOSE 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 .
2129
RUN npm run build
2230

31+
2332
FROM nginx:1.21 AS production
2433

2534
ENV USERNAME app
2635
RUN useradd -ms /bin/bash ${USERNAME}
2736

2837
COPY 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
3039
COPY .env /usr/share/nginx/html
3140
RUN chown -R ${USERNAME}:${USERNAME} /var/cache/nginx && \
3241
chown -R ${USERNAME}:${USERNAME} /var/log/nginx && \

Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff 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
6674
stop_prod: ## Stop container timetracker_ui_prod.

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ Yo have 2 ways to run this project in dev mode:
8585
- In your project path, open your favourite command line and run the follwing commands: `make build` then `make run` and finally `make logs`. When the project is successfully compiled you can go to `http://localhost:4200/` in your browser. Remember you must have your Docker running.
8686

8787
**Second**:
88+
89+
note: If you're on windows, use para bash to set up the environment.
90+
- Set the environment variables executing the following commands:
91+
```bash
92+
set -a
93+
source .env
94+
set +a
95+
```
8896
- Run `ng serve` to run the app in dev mode. After executing this command, you can navigate to `http://localhost:4200/` to see the app working. This method is usefull when you want to run a specific branch using less time but not recommended when doing QA.
8997

9098
In any case, the app will automatically reload if you change anything in the source files.

angular.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,34 @@
7878
"maximumError": "10kb"
7979
}
8080
]
81+
},
82+
"productionlegacy": {
83+
"fileReplacements": [
84+
{
85+
"replace": "src/environments/environment.ts",
86+
"with": "src/environments/environment.prodlegacy.ts"
87+
}
88+
],
89+
"optimization": true,
90+
"outputHashing": "all",
91+
"sourceMap": false,
92+
"extractCss": true,
93+
"namedChunks": false,
94+
"extractLicenses": true,
95+
"vendorChunk": false,
96+
"buildOptimizer": true,
97+
"budgets": [
98+
{
99+
"type": "initial",
100+
"maximumWarning": "2mb",
101+
"maximumError": "5mb"
102+
},
103+
{
104+
"type": "anyComponentStyle",
105+
"maximumWarning": "6kb",
106+
"maximumError": "10kb"
107+
}
108+
]
81109
}
82110
}
83111
},

docker-compose.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ services:
1111
- 9876:9876
1212
environment:
1313
AUTHORITY: ${AUTHORITY}
14+
API_URL: ${API_URL}
1415
CLIENT_ID: ${CLIENT_ID}
16+
CLIENT_URL: ${CLIENT_URL}
1517
SCOPES: ${SCOPES}
1618
STACK_EXCHANGE_ID: ${STACK_EXCHANGE_ID}
1719
STACK_EXCHANGE_ACCESS_TOKEN: ${STACK_EXCHANGE_ACCESS_TOKEN}
1820
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${AZURE_APP_CONFIGURATION_CONNECTION_STRING}
19-
AUTHORITY_JSON: ${AUTHORITY_JSON}
20-
CLIENT_ID_JSON: ${CLIENT_ID_JSON}
21-
SCOPES_JSON: ${SCOPES_JSON}
2221
volumes:
2322
- ./src:/home/timetracker/time-tracker-ui/src/
2423
- ./scripts:/home/timetracker/time-tracker-ui/scripts/
@@ -39,12 +38,11 @@ services:
3938
- 9876:9876
4039
environment:
4140
CHROME_BIN: /opt/google/chrome/google-chrome
41+
API_URL: ${API_URL}
4242
AUTHORITY: ${AUTHORITY}
4343
CLIENT_ID: ${CLIENT_ID}
44+
CLIENT_URL: ${CLIENT_URL}
4445
SCOPES: ${SCOPES}
4546
STACK_EXCHANGE_ID: ${STACK_EXCHANGE_ID}
4647
STACK_EXCHANGE_ACCESS_TOKEN: ${STACK_EXCHANGE_ACCESS_TOKEN}
4748
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${AZURE_APP_CONFIGURATION_CONNECTION_STRING}
48-
AUTHORITY_JSON: ${AUTHORITY_JSON}
49-
CLIENT_ID_JSON: ${CLIENT_ID_JSON}
50-
SCOPES_JSON: ${SCOPES_JSON}

0 commit comments

Comments
 (0)