Skip to content

Commit 5998b19

Browse files
authored
Merge pull request #3790 from Northeastern-Electric-Racing/infrastructure
Infrastructure
2 parents 4802aa0 + d460167 commit 5998b19

51 files changed

Lines changed: 4460 additions & 17 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,90 @@
1+
# Dependencies
12
**/node_modules
3+
.yarn/
4+
.pnp.*
5+
6+
# Build outputs
27
**/dist
8+
**/build
9+
10+
# Tests
311
**/tests
412
**/*.test.ts
5-
.vscode
13+
**/*.test.js
14+
**/*.spec.ts
15+
**/*.spec.js
16+
system-tests/
17+
coverage/
18+
__tests__/
19+
20+
# AWS & Infrastructure
21+
infrastructure/
22+
.elasticbeanstalk/
23+
.ebextensions/
24+
Dockerrun.aws.json
25+
*.tf
26+
*.tfvars
27+
*.tfstate
28+
*.tfstate.*
29+
ECR_DEPLOYMENT.md
30+
TERRAFORM_CHANGES.md
31+
32+
# Git
33+
.git/
34+
.gitignore
35+
.gitattributes
36+
.github/
37+
38+
# IDE
39+
.vscode/
40+
.idea/
41+
*.swp
42+
*.swo
43+
*~
44+
.DS_Store
45+
46+
# Documentation
47+
README.md
48+
*.md
49+
LICENSE
50+
51+
# Environment files
52+
.env
53+
.env.*
54+
*.env
55+
56+
# Logs
57+
*.log
58+
npm-debug.log*
59+
yarn-debug.log*
60+
yarn-error.log*
61+
62+
# Lock files (keep package.json though)
63+
package-lock.json
664
yarn.lock
65+
.yarnrc.yml
66+
67+
# Prettier
68+
.prettierrc*
69+
.prettierignore
70+
71+
# TypeScript config (keep for build)
72+
# tsconfig.json - commented out, may need this
73+
74+
# Docker files
75+
.dockerignore
76+
docker-compose*.yml
77+
docker-compose*.yaml
78+
Dockerfile.*
79+
80+
# Temporary files
81+
tmp/
82+
temp/
83+
*.tmp
84+
*.bak
85+
*.backup
86+
87+
# Containerization helpers
88+
containerization/
89+
devContainerization/
90+
scripts/
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
option_settings:
2+
# Relax health check settings for debugging
3+
aws:elasticbeanstalk:environment:process:default:
4+
HealthCheckInterval: 30
5+
HealthCheckTimeout: 10
6+
HealthyThresholdCount: 2
7+
UnhealthyThresholdCount: 10
8+
9+
# Ignore health check failures during deployment
10+
aws:elasticbeanstalk:command:
11+
IgnoreHealthCheck: true
12+
Timeout: 900
13+
14+
# Enhanced health reporting settings
15+
aws:elasticbeanstalk:healthreporting:system:
16+
HealthCheckSuccessThreshold: Ok
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
files:
2+
"/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json":
3+
mode: "000644"
4+
owner: root
5+
group: root
6+
content: |
7+
{
8+
"agent": {
9+
"metrics_collection_interval": 60,
10+
"run_as_user": "root"
11+
},
12+
"metrics": {
13+
"namespace": "CWAgent",
14+
"metrics_collected": {
15+
"mem": {
16+
"measurement": [
17+
{
18+
"name": "mem_used_percent",
19+
"rename": "MemoryUtilization",
20+
"unit": "Percent"
21+
}
22+
],
23+
"metrics_collection_interval": 60
24+
},
25+
"disk": {
26+
"measurement": [
27+
{
28+
"name": "used_percent",
29+
"rename": "DiskUtilization",
30+
"unit": "Percent"
31+
}
32+
],
33+
"metrics_collection_interval": 60,
34+
"resources": [
35+
"*"
36+
]
37+
}
38+
},
39+
"append_dimensions": {
40+
"AutoScalingGroupName": "${aws:AutoScalingGroupName}",
41+
"InstanceId": "${aws:InstanceId}"
42+
}
43+
}
44+
}
45+
46+
commands:
47+
01_install_cloudwatch_agent:
48+
command: |
49+
if ! command -v amazon-cloudwatch-agent-ctl &> /dev/null; then
50+
wget -q https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm
51+
rpm -U ./amazon-cloudwatch-agent.rpm
52+
rm -f ./amazon-cloudwatch-agent.rpm
53+
fi
54+
test: "[ ! -f /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl ]"
55+
56+
02_stop_cloudwatch_agent:
57+
command: |
58+
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl \
59+
-a fetch-config \
60+
-m ec2 \
61+
-c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json \
62+
-s
63+
ignoreErrors: true

.ebignore

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Dockerfiles (use pre-built images from ECR)
2+
Dockerfile
3+
Dockerfile.*
4+
5+
# Docker Compose
6+
docker-compose*.yml
7+
docker-compose*.yaml
8+
9+
# Terraform
10+
infrastructure/
11+
*.tf
12+
*.tfvars
13+
*.tfstate
14+
*.tfstate.*
15+
16+
# Containerization helpers
17+
containerization/
18+
devContainerization/
19+
20+
# Git
21+
.git/
22+
.gitignore
23+
.gitattributes
24+
25+
# Documentation
26+
README.md
27+
*.md
28+
CHANGELOG.md
29+
LICENSE
30+
TERRAFORM_CHANGES.md
31+
ECR_DEPLOYMENT.md
32+
33+
# IDE and Editor
34+
.vscode/
35+
.idea/
36+
*.swp
37+
*.swo
38+
*~
39+
.DS_Store
40+
41+
# Node
42+
node_modules/
43+
npm-debug.log*
44+
yarn-debug.log*
45+
yarn-error.log*
46+
.yarn/
47+
.pnp.*
48+
49+
# Build artifacts
50+
dist/
51+
build/
52+
*.log
53+
54+
# Tests
55+
__tests__/
56+
*.test.js
57+
*.test.ts
58+
*.spec.js
59+
*.spec.ts
60+
test/
61+
tests/
62+
system-tests/
63+
coverage/
64+
65+
# CI/CD
66+
.github/
67+
68+
# Environment files (secrets should be in Terraform)
69+
.env
70+
.env.*
71+
*.env
72+
73+
# Elastic Beanstalk files that shouldn't be re-deployed
74+
.elasticbeanstalk/*
75+
!.elasticbeanstalk/*.cfg.yml
76+
!.elasticbeanstalk/*.global.yml
77+
78+
# Source code (we deploy pre-built containers)
79+
src/
80+
81+
# Package manager files
82+
package-lock.json
83+
yarn.lock
84+
.yarnrc.yml
85+
86+
# TypeScript
87+
tsconfig.json
88+
tsconfig.*.json
89+
90+
# Prettier
91+
.prettierrc*
92+
.prettierignore
93+
94+
# Backup files
95+
*.bak
96+
*.backup
97+
*.old
98+
99+
# Temporary files
100+
tmp/
101+
temp/
102+
*.tmp
103+
104+
# Scripts
105+
scripts/
106+
107+
# eb-deploy directory (if it exists)
108+
eb-deploy/

.github/workflows/deploy-prod.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Deploy to Production
2+
3+
on:
4+
push:
5+
branches:
6+
- multitenancy
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 30
12+
13+
steps:
14+
- name: Checkout source code
15+
uses: actions/checkout@v3
16+
17+
- name: Configure AWS credentials
18+
uses: aws-actions/configure-aws-credentials@v1
19+
with:
20+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
21+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
22+
aws-region: us-east-1
23+
24+
- name: Login to Amazon ECR
25+
id: login-ecr
26+
uses: aws-actions/amazon-ecr-login@v1
27+
28+
- name: Set up Docker Buildx (for multi-platform builds)
29+
uses: docker/setup-buildx-action@v2
30+
31+
- name: Build, tag, and push image to Amazon ECR
32+
env:
33+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
34+
ECR_REPOSITORY: finishline-production
35+
IMAGE_TAG: ${{ github.sha }}
36+
run: |
37+
echo "Building Docker image for AMD64 architecture..."
38+
39+
# Build for AMD64 architecture (t3.small instances are AMD64)
40+
docker buildx build \
41+
--platform linux/amd64 \
42+
--tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \
43+
--tag $ECR_REGISTRY/$ECR_REPOSITORY:latest \
44+
--push \
45+
.
46+
47+
echo "✅ Image pushed successfully"
48+
echo "Image: $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
49+
50+
- name: Update Dockerrun.aws.json
51+
env:
52+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
53+
ECR_REPOSITORY: finishline-production
54+
IMAGE_TAG: ${{ github.sha }}
55+
run: |
56+
# Create a deployment-specific Dockerrun.aws.json with the commit SHA
57+
cat > Dockerrun.aws.json <<EOF
58+
{
59+
"AWSEBDockerrunVersion": "1",
60+
"Image": {
61+
"Name": "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG",
62+
"Update": "true"
63+
},
64+
"Ports": [
65+
{
66+
"ContainerPort": 3001,
67+
"HostPort": 3001
68+
}
69+
]
70+
}
71+
EOF
72+
73+
echo "✅ Dockerrun.aws.json updated with image tag: $IMAGE_TAG"
74+
75+
- name: Create deployment package
76+
run: |
77+
# Include .ebextensions for health check configuration
78+
zip -r deploy.zip Dockerrun.aws.json .ebextensions/ .ebignore
79+
80+
echo "✅ Deployment package created"
81+
82+
- name: Deploy to Elastic Beanstalk
83+
uses: einaregilsson/beanstalk-deploy@v21
84+
with:
85+
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
86+
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
87+
application_name: finishline-production
88+
environment_name: finishline-production-env
89+
version_label: ${{ github.sha }}
90+
region: us-east-1
91+
deployment_package: deploy.zip
92+
wait_for_deployment: true
93+
wait_for_environment_recovery: 300
94+
95+
- name: Verify deployment
96+
run: |
97+
echo "🎉 Deployment completed successfully!"
98+
echo ""
99+
echo "Deployment Details:"
100+
echo " Image: ${{ steps.login-ecr.outputs.registry }}/finishline-production:${{ github.sha }}"
101+
echo " Version: ${{ github.sha }}"
102+
echo " Environment: finishline-production-env"

0 commit comments

Comments
 (0)