Skip to content

Commit 8386270

Browse files
committed
add deployment files for docs-dev
1 parent 8b37c5f commit 8386270

File tree

4 files changed

+193
-0
lines changed

4 files changed

+193
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Docs Dev Deployment
2+
on:
3+
push:
4+
branches: ['dev']
5+
workflow_dispatch:
6+
7+
jobs:
8+
deploy_staging:
9+
name: Dev Deployment
10+
permissions:
11+
id-token: write
12+
contents: write
13+
environment: dev
14+
runs-on: ubuntu-latest
15+
env:
16+
AWS_REGION: eu-west-1
17+
ECR_REPOSITORY: docs-dev-ecr
18+
ECS_SERVICE: docs-dev-ecs-service
19+
ECS_CLUSTER: frontend-dev-ecs-cluster
20+
ECS_TASK_DEFINITION: dev-taskdef.json
21+
CONTAINER_NAME: docs-dev
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v3
25+
with:
26+
submodules: true
27+
28+
- name: Configure AWS credentials
29+
uses: aws-actions/configure-aws-credentials@v1-node16
30+
with:
31+
aws-region: ${{ env.AWS_REGION }}
32+
role-to-assume: arn:aws:iam::605436358845:role/docs-dev-GithubActionsRole
33+
role-session-name: GithubActionsSession
34+
35+
- name: Login to Amazon ECR
36+
id: login-ecr
37+
uses: aws-actions/amazon-ecr-login@v1
38+
39+
- uses: actions/setup-python@v4
40+
with:
41+
python-version: '3.11'
42+
43+
- name: pip Install
44+
run: pip install -r requirements.txt --no-cache-dir
45+
46+
- name: Build mkdocs
47+
run: mkdocs build
48+
49+
- name: Build, tag, and push image to Amazon ECR
50+
id: build-image
51+
env:
52+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
53+
IMAGE_TAG: ${{ github.sha }}
54+
run: |
55+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG Dockerfile.nginx
56+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
57+
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
58+
59+
- name: Fill in the new image ID in the Amazon ECS task definition
60+
id: task-def
61+
uses: aws-actions/amazon-ecs-render-task-definition@v1
62+
with:
63+
task-definition: ${{ env.ECS_TASK_DEFINITION }}
64+
container-name: ${{ env.CONTAINER_NAME }}
65+
image: ${{ steps.build-image.outputs.image }}
66+
67+
- name: Deploy Amazon ECS task definition
68+
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
69+
with:
70+
task-definition: ${{ steps.task-def.outputs.task-definition }}
71+
service: ${{ env.ECS_SERVICE }}
72+
cluster: ${{ env.ECS_CLUSTER }}
73+
wait-for-service-stability: true

Dockerfile.nginx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#Serve the app with NGINX
2+
FROM nginx:alpine
3+
4+
# Copy the build files from the build folder to /usr/share/nginx/html
5+
COPY site /usr/share/nginx/html
6+
7+
#Replace default nginx.conf with custom configuration
8+
COPY nginx.conf /etc/nginx/conf.d/default.conf
9+
10+
# Expose the desired port (default is 80 for NGINX)
11+
EXPOSE 80
12+
13+
# Start NGINX
14+
CMD ["nginx", "-g", "daemon off;"]

dev-taskdef.json

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
{
2+
"requiresCompatibilities": [
3+
"FARGATE"
4+
],
5+
"inferenceAccelerators": [],
6+
"containerDefinitions": [{
7+
"dnsSearchDomains": null,
8+
"environmentFiles": [],
9+
"entryPoint": null,
10+
"portMappings": [{
11+
"hostPort": 80,
12+
"protocol": "tcp",
13+
"containerPort": 80
14+
}],
15+
"command": null,
16+
"linuxParameters": null,
17+
"cpu": 0,
18+
"environment": null,
19+
"resourceRequirements": null,
20+
"ulimits": null,
21+
"dnsServers": null,
22+
"mountPoints": null,
23+
"workingDirectory": null,
24+
"secrets": null,
25+
"dockerSecurityOptions": null,
26+
"memory": null,
27+
"memoryReservation": null,
28+
"volumesFrom": null,
29+
"stopTimeout": null,
30+
"image": "test",
31+
"startTimeout": null,
32+
"firelensConfiguration": null,
33+
"dependsOn": null,
34+
"disableNetworking": null,
35+
"interactive": null,
36+
"healthCheck": null,
37+
"essential": true,
38+
"links": null,
39+
"hostname": null,
40+
"extraHosts": null,
41+
"pseudoTerminal": null,
42+
"user": null,
43+
"readonlyRootFilesystem": null,
44+
"dockerLabels": null,
45+
"systemControls": null,
46+
"privileged": null,
47+
"name": "docs-dev",
48+
"repositoryCredentials": {
49+
"credentialsParameter": ""
50+
}
51+
}],
52+
"volumes": [],
53+
"networkMode": "awsvpc",
54+
"memory": "1024",
55+
"cpu": "512",
56+
"executionRoleArn": "arn:aws:iam::605436358845:role/docs-dev-TaskRole",
57+
"family": "docs-dev-taskdefinition",
58+
"taskRoleArn": "arn:aws:iam::605436358845:role/docs-dev-TaskRole",
59+
"runtimePlatform": {
60+
"operatingSystemFamily": "LINUX"
61+
},
62+
"tags": [{
63+
"key": "Role",
64+
"value": "frontend-application"
65+
},
66+
{
67+
"key": "ParentService",
68+
"value": "docs-dev"
69+
},
70+
{
71+
"key": "Environment",
72+
"value": "dev"
73+
},
74+
{
75+
"key": "Service",
76+
"value": "docs-dev.polygon.technology"
77+
},
78+
{
79+
"key": "Host",
80+
"value": "AWS"
81+
},
82+
{
83+
"key": "IAC",
84+
"value": "terraform-workspace-aws-dev-applications-eu-west-1-apps-docs-dev-polygon-technology"
85+
},
86+
{
87+
"key": "Team",
88+
"value": "documentation"
89+
},
90+
{
91+
"key": "Name",
92+
"value": "docs-dev-taskdefinition"
93+
}
94+
]
95+
}

nginx.conf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
server {
2+
listen 0.0.0.0:80;
3+
root /usr/share/nginx/html;
4+
index index.html;
5+
6+
error_page 404 /404.html;
7+
8+
location / {
9+
try_files $uri.html $uri $uri/ /index.html;
10+
}
11+
}

0 commit comments

Comments
 (0)