Skip to content

Commit c5bf09a

Browse files
Merge pull request 0xPolygon#20 from 0xPolygon/dev
add deployment files for staging and prod
2 parents 1139b9c + e3a94c2 commit c5bf09a

File tree

10 files changed

+562
-1
lines changed

10 files changed

+562
-1
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
- name: Use Python
40+
uses: actions/setup-python@v4
41+
with:
42+
python-version: '3.11'
43+
44+
- name: pip Install
45+
run: pip install -r requirements.txt --no-cache-dir
46+
47+
- name: Build mkdocs
48+
run: mkdocs build
49+
50+
- name: Build, tag, and push image to Amazon ECR
51+
id: build-image
52+
env:
53+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
54+
IMAGE_TAG: ${{ github.sha }}
55+
run: |
56+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f Dockerfile.nginx .
57+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
58+
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
59+
60+
- name: Fill in the new image ID in the Amazon ECS task definition
61+
id: task-def
62+
uses: aws-actions/amazon-ecs-render-task-definition@v1
63+
with:
64+
task-definition: ${{ env.ECS_TASK_DEFINITION }}
65+
container-name: ${{ env.CONTAINER_NAME }}
66+
image: ${{ steps.build-image.outputs.image }}
67+
68+
- name: Deploy Amazon ECS task definition
69+
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
70+
with:
71+
task-definition: ${{ steps.task-def.outputs.task-definition }}
72+
service: ${{ env.ECS_SERVICE }}
73+
cluster: ${{ env.ECS_CLUSTER }}
74+
wait-for-service-stability: true
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Merge Main to Dev
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *' # Run daily at midnight UTC
6+
7+
jobs:
8+
merge:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v2
14+
15+
- name: Merge Main to Dev
16+
run: |
17+
git checkout dev
18+
git pull origin dev
19+
git fetch origin main
20+
git merge origin/main --no-edit
21+
git push origin dev
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Prod Deployment
2+
on:
3+
push:
4+
branches: ['main']
5+
workflow_dispatch:
6+
inputs:
7+
stage:
8+
description: 'Stage to deploy (production)'
9+
required: true
10+
run_production:
11+
description: 'Staging deployment completed (yes, no)'
12+
required: true
13+
14+
jobs:
15+
deploy_prod:
16+
name: Prod Deployment
17+
permissions:
18+
id-token: write
19+
contents: write
20+
environment: prod
21+
runs-on: ubuntu-latest
22+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.stage == 'production' && github.event.inputs.run_production == 'yes'
23+
env:
24+
AWS_REGION: eu-west-1
25+
ECR_REPOSITORY: docs-ecr
26+
ECS_SERVICE: docs-ecs-service
27+
ECS_CLUSTER: frontend-prod-ecs-cluster
28+
ECS_TASK_DEFINITION: prod-taskdef.json
29+
CONTAINER_NAME: docs
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v3
33+
with:
34+
submodules: true
35+
36+
- name: Configure AWS credentials
37+
uses: aws-actions/configure-aws-credentials@v1-node16
38+
with:
39+
aws-region: ${{ env.AWS_REGION }}
40+
role-to-assume: arn:aws:iam::042947190491:role/docs-GithubActionsRole
41+
role-session-name: GithubActionsSession
42+
43+
- name: Login to Amazon ECR
44+
id: login-ecr
45+
uses: aws-actions/amazon-ecr-login@v1
46+
47+
- name: Use Python
48+
uses: actions/setup-python@v4
49+
with:
50+
python-version: '3.11'
51+
52+
- name: pip Install
53+
run: pip install -r requirements.txt --no-cache-dir
54+
55+
- name: Build mkdocs
56+
run: mkdocs build
57+
58+
- name: Build, tag, and push image to Amazon ECR
59+
id: build-image
60+
env:
61+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
62+
IMAGE_TAG: ${{ github.sha }}
63+
run: |
64+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f Dockerfile.nginx .
65+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
66+
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
67+
68+
- name: Fill in the new image ID in the Amazon ECS task definition
69+
id: task-def
70+
uses: aws-actions/amazon-ecs-render-task-definition@v1
71+
with:
72+
task-definition: ${{ env.ECS_TASK_DEFINITION }}
73+
container-name: ${{ env.CONTAINER_NAME }}
74+
image: ${{ steps.build-image.outputs.image }}
75+
76+
- name: Deploy Amazon ECS task definition
77+
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
78+
with:
79+
task-definition: ${{ steps.task-def.outputs.task-definition }}
80+
service: ${{ env.ECS_SERVICE }}
81+
cluster: ${{ env.ECS_CLUSTER }}
82+
wait-for-service-stability: true
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Staging Deployment
2+
on:
3+
push:
4+
branches: ['main']
5+
workflow_dispatch:
6+
7+
jobs:
8+
deploy_staging:
9+
name: Staging Deployment
10+
permissions:
11+
id-token: write
12+
contents: write
13+
environment: staging
14+
runs-on: ubuntu-latest
15+
env:
16+
AWS_REGION: eu-west-1
17+
ECR_REPOSITORY: docs-staging-ecr
18+
ECS_SERVICE: docs-staging-ecs-service
19+
ECS_CLUSTER: frontend-staging-ecs-cluster
20+
ECS_TASK_DEFINITION: staging-taskdef.json
21+
CONTAINER_NAME: docs-staging
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::070528468658:role/docs-staging-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+
- name: Use Python
40+
uses: actions/setup-python@v4
41+
with:
42+
python-version: '3.11'
43+
44+
- name: pip Install
45+
run: pip install -r requirements.txt --no-cache-dir
46+
47+
- name: Build mkdocs
48+
run: mkdocs build
49+
50+
- name: Build, tag, and push image to Amazon ECR
51+
id: build-image
52+
env:
53+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
54+
IMAGE_TAG: ${{ github.sha }}
55+
run: |
56+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f Dockerfile.nginx .
57+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
58+
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
59+
60+
- name: Fill in the new image ID in the Amazon ECS task definition
61+
id: task-def
62+
uses: aws-actions/amazon-ecs-render-task-definition@v1
63+
with:
64+
task-definition: ${{ env.ECS_TASK_DEFINITION }}
65+
container-name: ${{ env.CONTAINER_NAME }}
66+
image: ${{ steps.build-image.outputs.image }}
67+
68+
- name: Deploy Amazon ECS task definition
69+
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
70+
with:
71+
task-definition: ${{ steps.task-def.outputs.task-definition }}
72+
service: ${{ env.ECS_SERVICE }}
73+
cluster: ${{ env.ECS_CLUSTER }}
74+
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+
}

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ nav:
6464
- Validium: cdk/get-started/deploy-validium.md
6565
- Rollup: cdk/get-started/deploy-rollup.md
6666
- How to:
67-
- Manage policies - allowlists, denylists, ACLs: cdk/how-to/manage-allowlists.md
67+
- Manage policies - allowlists, denylists: cdk/how-to/manage-allowlists.md
6868
#- Architecture:
6969
- Specification:
7070
- Validium vs rollup: cdk/specification/validium-vs-rollup.md

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)