Skip to content

Commit dfb2ae1

Browse files
rodolfoIOETMarco AguirreMarco Aguirre
authored
Tta 87 create secrets management for time tracker v 2 and time tracker UI (#901)
* Innecesary env files deleted * New changes to env files * Add 1 git-crypt collaborator New collaborators: F295BDD1 Marco Aguirre <[email protected]> * Add 1 git-crypt collaborator New collaborators: 1CC2872D Rodolfo Diaz <[email protected]> * Add 2 git-crypt collaborators New collaborators: 1CC2872D Rodolfo Diaz <[email protected]> F295BDD1 Marco Aguirre <[email protected]> * New keys and env variables added * env files added & modified * Make run now uses .dev.env * Pipeline modified * is the .env needed? * using encrypted .stage.env * load secrets * adding env variables * scopes cannot be empty * use env * using env var * using env file * adding mask * using docker buildkit * only on tags * using buildkit directly * using dash source * docker buildkit * missing folders added * nginx fix * fixing secrets * problem with double qoutes * fixing quotes in .stage.env * fixing secrets * loading to env * quotes fixed * replacing \r * fixing trailing \n * one line expose * fixing endpoint url * removing unnecessary jobs * update creds * adding with space at the end of the file Co-authored-by: Marco Aguirre <[email protected]> Co-authored-by: Marco Aguirre <[email protected]>
1 parent e189da6 commit dfb2ae1

File tree

18 files changed

+83
-120
lines changed

18 files changed

+83
-120
lines changed

.dev.env

-14 Bytes
Binary file not shown.

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ Makefile
66
.gitignore
77
*keys.ts
88
*.keys.json
9+
.git-crypt
10+
.git
11+
Dockerfile

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
ARM_CLIENT_SECRET: ${{secrets.TF_ARM_CLIENT_SECRET}}
1616
ARM_SUBSCRIPTION_ID: ${{secrets.TF_ARM_SUBSCRIPTION_ID}}
1717
ARM_TENANT_ID: ${{secrets.TF_ARM_TENANT_ID}}
18+
1819
steps:
1920
- name: Checkout
2021
uses: actions/checkout@v3
@@ -29,16 +30,15 @@ jobs:
2930
with:
3031
creds: ${{ secrets.AZURE_CREDENTIALS }}
3132

33+
- name: Unlock STAGE secrets
34+
uses: sliteteam/[email protected]
35+
env:
36+
GIT_CRYPT_KEY: ${{ secrets.GIT_CRYPT_KEY_STAGE }}
37+
3238
- name: Build the docker image
3339
run: |-
3440
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}}" \
41+
--target production -t timetracker_ui \
4242
.
4343
4444
- name: Publish docker image to stage azure container registry

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

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ jobs:
1414
runs-on: ubuntu-latest
1515
env:
1616
WORKING_DIR: infrastructure/
17-
DB_CONNECTION: ${{ secrets.DB_CONNECTION }}
1817
ARM_CLIENT_ID: ${{secrets.TF_ARM_CLIENT_ID}}
1918
ARM_CLIENT_SECRET: ${{secrets.TF_ARM_CLIENT_SECRET}}
2019
ARM_SUBSCRIPTION_ID: ${{secrets.TF_ARM_SUBSCRIPTION_ID}}
@@ -30,20 +29,6 @@ jobs:
3029
with:
3130
ssh-private-key: ${{ secrets.INFRA_TERRAFORM_MODULES_SSH_PRIV_KEY }}
3231

33-
- name: Inject Secrets
34-
env:
35-
AUTHORITY: ${{ secrets.AUTHORITY }}
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 }}
42-
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING }}
43-
run: |
44-
chmod +x ./scripts/populate-keys.sh
45-
sh ./scripts/populate-keys.sh
46-
4732
- name: build docker
4833
run: make build
4934

@@ -81,7 +66,8 @@ jobs:
8166

8267
- name: Terraform Plan Prod
8368
id: plan-prod
84-
run: terraform plan -var-file=${{ env.TF_WORKSPACE }}.tfvars -var image_tag=latest -no-color
69+
# run: terraform plan -var-file=${{ env.TF_WORKSPACE }}.tfvars -var image_tag=latest -no-color
70+
run: echo "Disabled for now up to restructure infra tiers"
8571
continue-on-error: true
8672
working-directory: ./${{ env.WORKING_DIR }}
8773
env:

.prod.env

46 Bytes
Binary file not shown.

.stage.env

66 Bytes
Binary file not shown.

Docker/Dockerfile.test

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@ RUN useradd -ms /bin/bash ${USERNAME}
3535

3636
WORKDIR ${HOME}/time-tracker-ui
3737
COPY . .
38-
RUN rm -f .env
3938
RUN chown ${USERNAME}:${USERNAME} -R ${HOME}/time-tracker-ui
4039
RUN chmod -R 777 ${HOME}/time-tracker-ui
4140

4241
USER ${USERNAME}
43-
COPY .env .
4442
EXPOSE 4200
4543
EXPOSE 9876
4644
RUN npm cache clean --force && npm install

Dockerfile

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,22 @@
1-
FROM node:14 AS building
2-
3-
ENV USERNAME timetracker
4-
ENV HOME /home/${USERNAME}
5-
RUN useradd -ms /bin/bash ${USERNAME}
6-
WORKDIR ${HOME}/time-tracker-ui
7-
COPY . .
8-
RUN chown ${USERNAME}:${USERNAME} -R ${HOME}/time-tracker-ui
9-
RUN chmod -R 777 ${HOME}/time-tracker-ui
10-
11-
USER ${USERNAME}
1+
FROM node:14-alpine AS building
2+
WORKDIR /app
3+
# ENV USERNAME timetracker
4+
# ENV HOME /home/${USERNAME}
5+
# RUN useradd -ms /bin/bash ${USERNAME}
6+
# WORKDIR ${HOME}/time-tracker-ui
7+
COPY . /app
8+
# RUN chown ${USERNAME}:${USERNAME} -R ${HOME}/time-tracker-ui
9+
# RUN chmod -R 777 ${HOME}/time-tracker-ui
10+
# USER ${USERNAME}
1211
RUN npm cache clean --force && npm install
13-
EXPOSE 4200
14-
EXPOSE 9876
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}
28-
29-
RUN npm run build
30-
12+
EXPOSE 4200 9876
13+
RUN source .stage.env && npm run build
14+
# >> scrt &&
15+
#
3116

3217
FROM nginx:1.21 AS production
33-
34-
ENV USERNAME app
35-
RUN useradd -ms /bin/bash ${USERNAME}
36-
3718
COPY nginx.conf /etc/nginx/conf.d/default.conf
38-
COPY --from=building /home/timetracker/time-tracker-ui/dist/time-tracker /usr/share/nginx/html
39-
COPY .env /usr/share/nginx/html
40-
RUN chown -R ${USERNAME}:${USERNAME} /var/cache/nginx && \
41-
chown -R ${USERNAME}:${USERNAME} /var/log/nginx && \
42-
chown -R ${USERNAME}:${USERNAME} /etc/nginx/conf.d
43-
RUN touch /var/run/nginx.pid && chown -R ${USERNAME}:${USERNAME} /var/run/nginx.pid
44-
19+
COPY --from=building /app/dist/time-tracker /usr/share/nginx/html
4520
# FIXME: Actually if we can deploy to azure in port 80 we need a root user
4621
# Maybe we can refactor this dockerfile to use root user directly this is not a good approach y
4722
# security terms. It's a good practice to have rootless in containers so for this

scripts/populate-keys.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
> .env
44
echo "API_URL='$API_URL'" >> .env
55
echo "AUTHORITY='$AUTHORITY'" >> .env
6-
echo "API_URL='$API_URL'" >> .env
76
echo "CLIENT_ID='$CLIENT_ID'" >> .env
87
echo "CLIENT_URL='$CLIENT_URL'" >> .env
98
echo "SCOPES='$SCOPES'" >> .env

src/app/modules/activities-management/store/activity-management.selectors.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('ActivityManagement Selectors', () => {
4242
description: 'Some description'
4343
},
4444
];
45-
45+
4646
const activitiesOrdered = [
4747
{
4848
id: '002',

0 commit comments

Comments
 (0)