Skip to content

Commit ed217e5

Browse files
nicolsssmmaquina
andauthored
Fast api implementation (#979)
* refactor: change endpoints route * refactor: backend port * fix make publish * fix aws login * change backend link * fix findEntriesByProjectId endpoint url * fix url createEntry * triggers by: tag->prod, publish release->stage * disable triggers to azure workflow * fix dockerfiles for aws --------- Co-authored-by: Nicole Garcia <nicolsss> Co-authored-by: mmaquina <[email protected]>
1 parent a35a658 commit ed217e5

File tree

15 files changed

+160
-24
lines changed

15 files changed

+160
-24
lines changed

.gitattributes

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.dev.env filter=git-crypt diff=git-crypt
22
.prod.env filter=git-crypt-PROD diff=git-crypt-PROD
3-
.stage.env filter=git-crypt-STAGE diff=git-crypt-STAGE
3+
.stage.env filter=git-crypt-STAGE diff=git-crypt-STAGE
4+
.stage.aws.env filter=git-crypt-STAGE diff=git-crypt-STAGE
5+
.prod.aws.env filter=git-crypt-PROD diff=git-crypt-PROD

.github/workflows/aws-ui-cd-prod.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: time-tracker-ui-cd-prod
2+
3+
on:
4+
push:
5+
branches:
6+
- 'fast-api*'
7+
8+
jobs:
9+
cd:
10+
runs-on: ubuntu-latest
11+
env:
12+
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
13+
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
19+
- name: Get the release_version
20+
run: |
21+
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
22+
echo $RELEASE_VERSION
23+
24+
- name: Unlock PROD secrets
25+
uses: sliteteam/[email protected]
26+
env:
27+
GIT_CRYPT_KEY: ${{ secrets.GIT_CRYPT_KEY_PROD }}
28+
29+
- name: Build the docker image
30+
run: |-
31+
docker build \
32+
--target production -t timetracker_ui -f Dockerfile_prod \
33+
.
34+
35+
- name: Publish docker image to prod aws container registry
36+
run: |
37+
make login publish_prod image_tag=$RELEASE_VERSION
38+
39+
- name: SCP files via ssh key
40+
uses: appleboy/scp-action@master
41+
env:
42+
USERNAME: ${{ secrets.AWS_EC2_USER }}
43+
HOST: ${{ secrets.PROD_UI_URL }}
44+
KEY: ${{ secrets.PROD_AWS_PRIVATE_KEY }}
45+
with:
46+
source: './infrastructure/aws_ec2.sh'
47+
target: '.'
48+
49+
- name: SCP files via ssh key - .prod.aws.env
50+
uses: appleboy/scp-action@master
51+
env:
52+
USERNAME: ${{ secrets.AWS_EC2_USER }}
53+
HOST: ${{ secrets.PROD_UI_URL }}
54+
KEY: ${{ secrets.PROD_AWS_PRIVATE_KEY }}
55+
with:
56+
source: '.prod.aws.env'
57+
target: '.'
58+
59+
- name: Deploy
60+
run: |
61+
TEMP=$(mktemp)
62+
echo "${{ secrets.PROD_AWS_PRIVATE_KEY }}" > $TEMP
63+
chmod 400 $TEMP
64+
ssh -o 'StrictHostKeyChecking no' -i $TEMP ${{ secrets.AWS_EC2_USER }}@${{ secrets.PROD_UI_URL }} "chmod +x ./infrastructure/aws_ec2.sh"
65+
ssh -o 'StrictHostKeyChecking no' -i $TEMP ${{ secrets.AWS_EC2_USER }}@${{ secrets.PROD_UI_URL }} "./infrastructure/aws_ec2.sh $RELEASE_VERSION" prod

.github/workflows/aws-ui-cd-stage.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: time-tracker-ui-cd-stage
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
cd:
10+
runs-on: ubuntu-latest
11+
env:
12+
TF_WORKSPACE: stage
13+
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
14+
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
20+
- name: Get the release_version
21+
run: |
22+
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
23+
echo $RELEASE_VERSION
24+
25+
26+
- name: Unlock STAGE secrets
27+
uses: sliteteam/[email protected]
28+
env:
29+
GIT_CRYPT_KEY: ${{ secrets.GIT_CRYPT_KEY_STAGE }}
30+
31+
- name: Build the docker image
32+
run: |-
33+
docker build \
34+
--target production -t timetracker_ui -f Dockerfile_stage \
35+
.
36+
37+
- name: Publish docker image to stage AWS container registry
38+
run: |
39+
make login publish image_tag=$RELEASE_VERSION
40+
41+
- name: SCP files via ssh key - script
42+
uses: appleboy/scp-action@master
43+
env:
44+
USERNAME: ${{ secrets.AWS_EC2_USER }}
45+
HOST: ${{ secrets.STAGE_UI_URL }}
46+
KEY: ${{ secrets.STAGE_AWS_PRIVATE_KEY }}
47+
with:
48+
source: './infrastructure/aws_ec2.sh'
49+
target: '.'
50+
51+
- name: SCP files via ssh key - .stage.aws.env
52+
uses: appleboy/scp-action@master
53+
env:
54+
USERNAME: ${{ secrets.AWS_EC2_USER }}
55+
HOST: ${{ secrets.STAGE_UI_URL }}
56+
KEY: ${{ secrets.STAGE_AWS_PRIVATE_KEY }}
57+
with:
58+
source: '.stage.aws.env'
59+
target: '.'
60+
61+
- name: Deploy
62+
run: |
63+
TEMP=$(mktemp)
64+
echo "${{ secrets.STAGE_AWS_PRIVATE_KEY }}" > $TEMP
65+
chmod 400 $TEMP
66+
ssh -o 'StrictHostKeyChecking no' -i $TEMP ${{ secrets.AWS_EC2_USER }}@${{ secrets.STAGE_UI_URL }} "chmod +x ./infrastructure/aws_ec2.sh"
67+
ssh -o 'StrictHostKeyChecking no' -i $TEMP ${{ secrets.AWS_EC2_USER }}@${{ secrets.STAGE_UI_URL }} "./infrastructure/aws_ec2.sh $RELEASE_VERSION" stage

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
name: time-tracker-ui-cd-prod
22

33
on:
4-
release:
5-
types:
6-
- published
4+
workflow_dispatch # deactivate workflow and run it manually only
75

86
jobs:
97
cd:

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
name: time-tracker-ui-cd-stage
22

33
on:
4-
push:
5-
tags:
6-
- 'v*.*.*'
4+
workflow_dispatch # deactivate workflow and run it manually only
75

86
jobs:
97
cd:

.prod.aws.env

566 Bytes
Binary file not shown.

.prod.env

-3 Bytes
Binary file not shown.

.stage.aws.env

578 Bytes
Binary file not shown.

.stage.env

-5 Bytes
Binary file not shown.

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ testdev: ## Run all tests on docker container timetracker_ui at the Dev
5050
docker exec timetracker_ui bash -c "npm run ci-test"
5151

5252
.PHONY: publish
53-
publish: require-acr-arg require-image_tag-arg ## Upload a docker image to the stage azure container registry acr=<name_of_the_azure_container_registry> image_tag=<tag_for_the_image>
54-
docker tag timetracker_ui:latest $(acr).azurecr.io/timetracker_ui:$(image_tag)
55-
docker push $(acr).azurecr.io/timetracker_ui:$(image_tag)
53+
publish: require-image_tag-arg ## Upload a docker image to the stage AWS container registry image_tag=<tag_for_the_image>
54+
docker tag timetracker_ui:latest 568748651446.dkr.ecr.us-east-1.amazonaws.com/time-tracker/stage-ui:$(image_tag)
55+
docker push 568748651446.dkr.ecr.us-east-1.amazonaws.com/time-tracker/stage-ui:$(image_tag)
5656

5757
.PHONY: build_prod
5858
build_prod: ## Create docker image with dependencies needed for production -- to test locally only
@@ -80,13 +80,13 @@ remove_prod: ## Delete container timetracker_ui_prod.
8080
docker rm timetracker_ui_prod
8181

8282
.PHONY: publish_prod
83-
publish_prod: ## Upload a docker image to the prod azure container registry acr=<name_of_the_azure_container_registry> image_tag=<tag_for_the_image>
84-
docker tag timetracker_ui_prod:latest $(acr).azurecr.io/timetracker_ui:$(image_tag)
85-
docker push $(acr).azurecr.io/timetracker_ui:$(image_tag)
83+
publish_prod: require-image_tag-arg ## Upload a docker image to the prod AWS container registry image_tag=<tag_for_the_image>
84+
docker tag timetracker_ui:latest 568748651446.dkr.ecr.us-east-1.amazonaws.com/time-tracker/prod-ui:$(image_tag)
85+
docker push 568748651446.dkr.ecr.us-east-1.amazonaws.com/time-tracker/prod-ui:$(image_tag)
8686

8787
.PHONY: login
8888
login: ## Login in respository of docker images
89-
az acr login --name $(acr)
89+
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 568748651446.dkr.ecr.us-east-1.amazonaws.com
9090

9191
.PHONY: release
9292
release: require-VERSION-arg require-COMMENT-arg ## Creates an pushes a new tag.

0 commit comments

Comments
 (0)