Skip to content

Commit cf5bf09

Browse files
Frontend CFT, ARM64 image creation
1 parent 1c74558 commit cf5bf09

2 files changed

Lines changed: 223 additions & 12 deletions

File tree

.github/workflows/develop.yml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
branches:
99
- develop
1010
- main # temporary until we get a "develop" branch set up
11-
- ci-github-actions # temporary branch for testing, to be removed once workflow is verified
11+
- dc-deployment-pipeline # temporary branch for testing, to be removed once workflow is verified
1212
permissions:
1313
id-token: write
1414
jobs:
@@ -27,21 +27,30 @@ jobs:
2727
echo "DOCKER_REPO=analytics-dashboard-ui" >> $GITHUB_ENV
2828
echo "DOCKER_TAG=$(git describe)" >> $GITHUB_ENV
2929
30-
- name: build docker image
31-
id: build-docker-image
32-
run: docker build -t ${{ env.DOCKER_REPO }}:${{ env.DOCKER_TAG }} -t ${{ env.DOCKER_REPO }}:latest -t ${{ env.DOCKER_REPO }}:develop .
33-
3430
- name: configure aws credentials
3531
id: configure-aws-credentials
3632
uses: aws-actions/configure-aws-credentials@v6.1.0
3733
with:
3834
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
3935
aws-region: ${{ secrets.AWS_REGION }}
4036

41-
- name: push to ecr
42-
id: push-to-ecr
43-
uses: jwalton/gh-ecr-push@v2
44-
with:
45-
region: ${{ secrets.AWS_REGION }}
46-
local-image: ${{ env.DOCKER_REPO }}:${{ env.DOCKER_TAG }}
47-
image: ${{ env.DOCKER_REPO }}:${{ env.DOCKER_TAG }}, ${{ env.DOCKER_REPO }}:latest, ${{ env.DOCKER_REPO }}:develop
37+
- name: set up QEMU
38+
uses: docker/setup-qemu-action@v3
39+
40+
- name: set up Docker Buildx
41+
uses: docker/setup-buildx-action@v3
42+
43+
- name: login to Amazon ECR
44+
id: login-ecr
45+
uses: aws-actions/amazon-ecr-login@v2
46+
47+
- name: build and push docker image
48+
id: build-push-docker-image
49+
run: |
50+
docker buildx build \
51+
--platform linux/arm64 \
52+
--push \
53+
-t ${{ steps.login-ecr.outputs.registry }}/${{ env.DOCKER_REPO }}:${{ env.DOCKER_TAG }} \
54+
-t ${{ steps.login-ecr.outputs.registry }}/${{ env.DOCKER_REPO }}:latest \
55+
-t ${{ steps.login-ecr.outputs.registry }}/${{ env.DOCKER_REPO }}:develop \
56+
.

infrastructure/frontend.yml

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
AWSTemplateFormatVersion: 2010-09-09
2+
Description: Template for Analytics Dashboard UI deployment on AWS ECS Fargate with NLB
3+
4+
Parameters:
5+
StaticStackName:
6+
Type: String
7+
Default: analytics-dashboard
8+
Environment:
9+
Type: String
10+
Default: staging
11+
AllowedValues:
12+
- staging
13+
- production
14+
UIPort:
15+
Type: String
16+
Default: 8050
17+
FrontEndImage:
18+
Type: String
19+
ApiBaseUrl:
20+
Type: String
21+
VpcId:
22+
Type: String
23+
SubnetA:
24+
Type: String
25+
SubnetB:
26+
Type: String
27+
SubnetC:
28+
Type: String
29+
Region:
30+
Type: String
31+
Prefix:
32+
Type: String
33+
Default: ecs
34+
ExecutionRole:
35+
Type: String
36+
ClusterName:
37+
Type: String
38+
CertificateArn:
39+
Type: String
40+
ShortName:
41+
Type: String
42+
Default: an-db
43+
44+
Resources:
45+
ALBSecurityGroup:
46+
Type: AWS::EC2::SecurityGroup
47+
Properties:
48+
GroupDescription: Allow inbound HTTP/HTTPS to ALB
49+
VpcId: !Ref VpcId
50+
SecurityGroupIngress:
51+
- IpProtocol: tcp
52+
FromPort: 80
53+
ToPort: 80
54+
CidrIp: 0.0.0.0/0
55+
- IpProtocol: tcp
56+
FromPort: 443
57+
ToPort: 443
58+
CidrIp: 0.0.0.0/0
59+
60+
ALB:
61+
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
62+
Properties:
63+
Name: !Sub "${ShortName}-${Environment}-fe-alb"
64+
Type: application
65+
Scheme: internet-facing
66+
IpAddressType: ipv4
67+
SecurityGroups:
68+
- !Ref ALBSecurityGroup
69+
Subnets:
70+
- Ref: SubnetA
71+
- Ref: SubnetB
72+
- Ref: SubnetC
73+
74+
TargetGroup:
75+
Type: AWS::ElasticLoadBalancingV2::TargetGroup
76+
Properties:
77+
Name: !Sub "${ShortName}-${Environment}-fe-tg"
78+
TargetType: ip
79+
Protocol: HTTP
80+
Port: !Ref UIPort
81+
VpcId: !Ref VpcId
82+
HealthCheckEnabled: true
83+
HealthCheckProtocol: HTTP
84+
HealthCheckPath: /health
85+
HealthCheckPort: traffic-port
86+
HealthCheckIntervalSeconds: 30
87+
HealthyThresholdCount: 2
88+
UnhealthyThresholdCount: 5
89+
Matcher:
90+
HttpCode: 200-399
91+
92+
ALBListenerHTTP:
93+
Type: AWS::ElasticLoadBalancingV2::Listener
94+
DependsOn:
95+
- ALB
96+
Properties:
97+
LoadBalancerArn: !Ref ALB
98+
Port: 80
99+
Protocol: HTTP
100+
DefaultActions:
101+
- Type: redirect
102+
RedirectConfig:
103+
Protocol: HTTPS
104+
Port: "443"
105+
StatusCode: HTTP_301
106+
107+
ALBListenerHTTPS:
108+
Type: AWS::ElasticLoadBalancingV2::Listener
109+
DependsOn:
110+
- TargetGroup
111+
- ALB
112+
Properties:
113+
LoadBalancerArn: !Ref ALB
114+
Port: 443
115+
Protocol: HTTPS
116+
Certificates:
117+
- CertificateArn: !Ref CertificateArn
118+
DefaultActions:
119+
- Type: forward
120+
TargetGroupArn: !Ref TargetGroup
121+
122+
ECSCluster:
123+
Type: AWS::ECS::Cluster
124+
Properties:
125+
ClusterName: !Ref ClusterName
126+
127+
ECSTaskSecurityGroup:
128+
Type: AWS::EC2::SecurityGroup
129+
Properties:
130+
GroupDescription: Allow ALB to reach ECS tasks on Dash port
131+
VpcId: !Ref VpcId
132+
SecurityGroupIngress:
133+
- IpProtocol: tcp
134+
FromPort: !Ref UIPort
135+
ToPort: !Ref UIPort
136+
SourceSecurityGroupId: !Ref ALBSecurityGroup
137+
SecurityGroupEgress:
138+
- IpProtocol: -1
139+
CidrIp: 0.0.0.0/0
140+
141+
ECSFrontEndService:
142+
Type: AWS::ECS::Service
143+
DependsOn:
144+
- ECSFrontEndTaskDefinition
145+
- ALBListenerHTTPS
146+
- TargetGroup
147+
Properties:
148+
Cluster: !Ref ECSCluster
149+
LaunchType: FARGATE
150+
DesiredCount: 1
151+
HealthCheckGracePeriodSeconds: 120
152+
ServiceName: !Sub "${StaticStackName}-${Environment}-fe-service"
153+
TaskDefinition: !Ref ECSFrontEndTaskDefinition
154+
NetworkConfiguration:
155+
AwsvpcConfiguration:
156+
AssignPublicIp: ENABLED
157+
SecurityGroups:
158+
- Fn::ImportValue: !Sub "${StaticStackName}-${Environment}-SGId"
159+
- !Ref ECSTaskSecurityGroup
160+
Subnets:
161+
- !Ref SubnetA
162+
- !Ref SubnetB
163+
- !Ref SubnetC
164+
LoadBalancers:
165+
- TargetGroupArn: !Ref TargetGroup
166+
ContainerName: !Sub "${StaticStackName}-${Environment}-fe-container"
167+
ContainerPort: !Ref UIPort
168+
169+
ECSFrontEndTaskDefinition:
170+
Type: AWS::ECS::TaskDefinition
171+
Properties:
172+
Cpu: 1024
173+
Memory: 4096
174+
NetworkMode: awsvpc
175+
ExecutionRoleArn: !Ref ExecutionRole
176+
RequiresCompatibilities:
177+
- FARGATE
178+
RuntimePlatform:
179+
CpuArchitecture: ARM64
180+
OperatingSystemFamily: LINUX
181+
ContainerDefinitions:
182+
- Name: !Sub "${StaticStackName}-${Environment}-fe-container"
183+
Image: !Ref FrontEndImage
184+
Environment:
185+
- Name: GA4GH_ANALYTICS_DASHBOARD_API_BASE_URL
186+
Value: !Ref ApiBaseUrl
187+
- Name: GA4GH_ANALYTICS_DASHBOARD_UI_PORT
188+
Value: !Ref UIPort
189+
LogConfiguration:
190+
LogDriver: awslogs
191+
Options:
192+
awslogs-group:
193+
Fn::ImportValue: !Sub "${StaticStackName}-${Environment}-frontend-logs"
194+
awslogs-region: !Ref Region
195+
awslogs-stream-prefix: !Ref Prefix
196+
PortMappings:
197+
- ContainerPort: !Ref UIPort
198+
199+
Outputs:
200+
ALBDNSName:
201+
Description: DNS name of the ALB (use this in CNAME record)
202+
Value: !GetAtt ALB.DNSName

0 commit comments

Comments
 (0)