Skip to content

Commit 0e11c2e

Browse files
Rodrigo Dos SantosRodrigo Dos Santos
authored andcommitted
Add AWS ECS Configuration - build authentication-service
1 parent ea9abe3 commit 0e11c2e

File tree

2 files changed

+188
-6
lines changed

2 files changed

+188
-6
lines changed
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
{
2+
"taskDefinitionArn": "arn:aws:ecs:eu-west-1:525674930738:task-definition/authentication-service:1",
3+
"containerDefinitions": [
4+
{
5+
"name": "authentication-service",
6+
"image": "525674930738.dkr.ecr.eu-west-1.amazonaws.com/authentication-service:latest",
7+
"cpu": 0,
8+
"portMappings": [
9+
{
10+
"name": "authentication-service-9999-tcp",
11+
"containerPort": 9999,
12+
"hostPort": 9999,
13+
"protocol": "tcp",
14+
"appProtocol": "http"
15+
}
16+
],
17+
"essential": true,
18+
"environment": [
19+
{
20+
"name": "MANAGEMENT_HEALTH_REDIS_ENABLED",
21+
"value": "false"
22+
},
23+
{
24+
"name": "SPRING_SESSION_STORE_TYPE",
25+
"value": "none"
26+
},
27+
{
28+
"name": "SPRING_MAIN_ALLOW_CIRCULAR_REFERENCES",
29+
"value": "true"
30+
},
31+
{
32+
"name": "SPRING_DATA_MONGODB_URI",
33+
"value": "mongodb+srv://mongoadmin:zitfoh-zynwU9-kivgod@serverlessinstance0.vhszn.mongodb.net"
34+
},
35+
{
36+
"name": "OPENTRACING_JAEGER_ENABLED",
37+
"value": "false"
38+
},
39+
{
40+
"name": "COM_MICROSERVICE_AUTHENTICATION_REDIS_ENABLED",
41+
"value": "false"
42+
},
43+
{
44+
"name": "COM_MICROSERVICE_AUTHENTICATION_JWT_KEY_VALUE",
45+
"value": "dGVzdC1zcHJpbmctYm9vdC1hcHBsaWNhdGlvbi13aXRoLXJlYWN0LXNpbmdsZS1wYWdlLWFwcGxpY2F0aW9uCg=="
46+
},
47+
{
48+
"name": "SPRING_PROFILES_ACTIVE",
49+
"value": "auth"
50+
},
51+
{
52+
"name": "MANAGEMENT_ENDPOINTS_WEB_CORS_ALLOW_CREDENTIALS",
53+
"value": "false"
54+
},
55+
{
56+
"name": "SPRING_DATA_MONGODB_DATABASE",
57+
"value": "test"
58+
},
59+
{
60+
"name": "SPRING_CLOUD_KUBERNETES_ENABLED",
61+
"value": "false"
62+
}
63+
],
64+
"environmentFiles": [],
65+
"mountPoints": [],
66+
"volumesFrom": [],
67+
"logConfiguration": {
68+
"logDriver": "awslogs",
69+
"options": {
70+
"awslogs-create-group": "true",
71+
"awslogs-group": "/ecs/authentication-service",
72+
"awslogs-region": "eu-west-1",
73+
"awslogs-stream-prefix": "ecs"
74+
}
75+
},
76+
"healthCheck": {
77+
"command": [
78+
"CMD-SHELL",
79+
" curl -f http://localhost:9999/actuator/health || exit 1"
80+
],
81+
"interval": 60,
82+
"timeout": 5,
83+
"retries": 3
84+
}
85+
}
86+
],
87+
"family": "authentication-service",
88+
"executionRoleArn": "arn:aws:iam::525674930738:role/ecsTaskExecutionRole",
89+
"networkMode": "awsvpc",
90+
"revision": 1,
91+
"volumes": [],
92+
"status": "ACTIVE",
93+
"requiresAttributes": [
94+
{
95+
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
96+
},
97+
{
98+
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.24"
99+
},
100+
{
101+
"name": "ecs.capability.execution-role-awslogs"
102+
},
103+
{
104+
"name": "com.amazonaws.ecs.capability.ecr-auth"
105+
},
106+
{
107+
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
108+
},
109+
{
110+
"name": "ecs.capability.container-health-check"
111+
},
112+
{
113+
"name": "ecs.capability.execution-role-ecr-pull"
114+
},
115+
{
116+
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
117+
},
118+
{
119+
"name": "ecs.capability.task-eni"
120+
},
121+
{
122+
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.29"
123+
}
124+
],
125+
"placementConstraints": [],
126+
"compatibilities": [
127+
"EC2",
128+
"FARGATE"
129+
],
130+
"requiresCompatibilities": [
131+
"FARGATE"
132+
],
133+
"cpu": "1024",
134+
"memory": "2048",
135+
"runtimePlatform": {
136+
"cpuArchitecture": "X86_64",
137+
"operatingSystemFamily": "LINUX"
138+
},
139+
"registeredAt": "2023-01-22T17:18:22.977Z",
140+
"registeredBy": "arn:aws:iam::525674930738:root",
141+
"tags": [
142+
{
143+
"key": "ecs:taskDefinition:createdFrom",
144+
"value": "ecs-console-v2"
145+
}
146+
]
147+
}

.github/workflows/docker-build-push-image-authentication-service.yml

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ env:
1717
GKE_CLUSTER: ${{ secrets.GKE_CLUSTER }}
1818
GKE_KEY: ${{ secrets.GKE_KEY }}
1919
IMAGE: authentication-service
20+
AWS_REGION: ${{ secrets.AWS_REGION }}
21+
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
22+
ECS_SERVICE: ${{ secrets.ECS_SERVICE }}
23+
ECS_CLUSTER: ${{ secrets.ECS_CLUSTER }}
24+
ECS_TASK_DEFINITION: ".github/.aws/authentication-service-task-definition.json"
25+
CONTAINER_NAME: ${{ secrets.CONTAINER_NAME }}
2026

2127
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
2228
jobs:
@@ -32,7 +38,7 @@ jobs:
3238
steps:
3339
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
3440
- name: Checkout
35-
uses: actions/checkout@v2
41+
uses: actions/checkout@v3
3642

3743
# Set up JDK
3844
- name: JDK
@@ -47,11 +53,23 @@ jobs:
4753
uses: docker/setup-buildx-action@v1
4854

4955
# Login to Dockerhub
50-
- name: Login to DockerHub
51-
uses: docker/login-action@v1
56+
# - name: Login to DockerHub
57+
# uses: docker/login-action@v1
58+
# with:
59+
# username: ${{ secrets.DOCKERHUB_USERNAME }}
60+
# password: ${{ secrets.DOCKERHUB_TOKEN }}
61+
#
62+
63+
- name: Configure AWS credentials
64+
uses: aws-actions/configure-aws-credentials@13d241b293754004c80624b5567555c4a39ffbe3
5265
with:
53-
username: ${{ secrets.DOCKERHUB_USERNAME }}
54-
password: ${{ secrets.DOCKERHUB_TOKEN }}
66+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
67+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
68+
aws-region: ${{ env.AWS_REGION }}
69+
70+
- name: Login to Amazon ECR
71+
id: login-ecr
72+
uses: aws-actions/amazon-ecr-login@aaf69d68aa3fb14c1d5a6be9ac61fe15b48453a2
5573

5674
# Build Docker image using docker:build
5775
- name: Build Service using docker:build
@@ -72,7 +90,24 @@ jobs:
7290
file: ./authentication-service/target/docker/authentication-service/build/Dockerfile
7391
platforms: linux/amd64,linux/arm64
7492
push: true
75-
tags: fielcapao/microservices-design-patterns-authentication-service:latest
93+
#tags: fielcapao/microservices-design-patterns-authentication-service:latest
94+
tags: $ECR_REPOSITORY:latest
95+
96+
- name: Fill in the new image ID in the Amazon ECS task definition
97+
id: task-def
98+
uses: aws-actions/amazon-ecs-render-task-definition@97587c9d45a4930bf0e3da8dd2feb2a463cf4a3a
99+
with:
100+
task-definition: ${{ env.ECS_TASK_DEFINITION }}
101+
container-name: ${{ env.CONTAINER_NAME }}
102+
image: ${{ steps.build-image.outputs.image }}
103+
104+
- name: Deploy Amazon ECS task definition
105+
uses: aws-actions/amazon-ecs-deploy-task-definition@de0132cf8cdedb79975c6d42b77eb7ea193cf28e
106+
with:
107+
task-definition: ${{ steps.task-def.outputs.task-definition }}
108+
service: ${{ env.ECS_SERVICE }}
109+
cluster: ${{ env.ECS_CLUSTER }}
110+
wait-for-service-stability: true
76111

77112
- name: Image digest
78113
run: echo ${{ steps.docker_build.outputs.digest }}

0 commit comments

Comments
 (0)