Skip to content

Commit

Permalink
Merge pull request #3 from ntampakas/main
Browse files Browse the repository at this point in the history
AWS ECS deployment
  • Loading branch information
Meyanis95 authored Sep 13, 2024
2 parents 8688459 + c97b4db commit 0262a6b
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 117 deletions.
16 changes: 16 additions & 0 deletions .github/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -ex

ISSUER_URL="https://issuer.anon-aadhaar.pse.dev"

aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin 490752553772.dkr.ecr.eu-central-1.amazonaws.com

docker build --build-arg "NEXT_PUBLIC_ISSUER_URL=$ISSUER_URL" -t anon-aadhaar-client -f client/Dockerfile client
docker tag anon-aadhaar-client:latest 490752553772.dkr.ecr.eu-central-1.amazonaws.com/anon-aadhaar-client:latest
docker push 490752553772.dkr.ecr.eu-central-1.amazonaws.com/anon-aadhaar-client:latest

docker build -t anon-aadhaar-issuer .
docker tag anon-aadhaar-issuer:latest 490752553772.dkr.ecr.eu-central-1.amazonaws.com/anon-aadhaar-issuer:latest
docker push 490752553772.dkr.ecr.eu-central-1.amazonaws.com/anon-aadhaar-issuer:latest

exit 0
13 changes: 13 additions & 0 deletions .github/scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -ex

tasks="anon-aadhaar-client anon-aadhaar-issuer"
for task in $tasks; do
anon_aadhaar_revision=$(aws ecs describe-task-definition --task-definition $task --query "taskDefinition.revision")
aws ecs update-service --cluster anon-aadhaar --service $task --force-new-deployment --task-definition $task:$anon_aadhaar_revision
done

for loop in {1..3}; do
[ "$loop" -eq 3 ] && exit 1
aws ecs wait services-stable --cluster anon-aadhaar --services $tasks && break || continue
done
37 changes: 37 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Deploy
on:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read

steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::490752553772:role/privado-frontend-ecs-deploy-slc
role-duration-seconds: 2700
aws-region: eu-central-1

- name: Build and Push images to ECR
run: |
.github/scripts/build.sh
- name: Trigger ECS Deployment
run: |
.github/scripts/deploy.sh
57 changes: 0 additions & 57 deletions .github/workflows/push-backend-erc.yaml

This file was deleted.

60 changes: 0 additions & 60 deletions .github/workflows/push-frontend-erc.yaml

This file was deleted.

1 change: 1 addition & 0 deletions client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM node:21
RUN apt-get update ; apt-get install -y netcat-openbsd

WORKDIR /app

Expand Down

0 comments on commit 0262a6b

Please sign in to comment.