Skip to content

Commit dffc45c

Browse files
committed
Add aws pipeline
1 parent 005de40 commit dffc45c

9 files changed

Lines changed: 215 additions & 18 deletions

File tree

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"taskDefinitionArn": "arn:aws:ecs:us-east-2:621180867847:task-definition/fargate-basic-task:1",
3+
"containerDefinitions": [
4+
{
5+
"name": "app",
6+
"image": "621180867847.dkr.ecr.us-east-2.amazonaws.com/portfolio-web-repo:latest",
7+
"cpu": 0,
8+
"portMappings": [
9+
{
10+
"name": "app-80-tcp",
11+
"containerPort": 80,
12+
"hostPort": 80,
13+
"protocol": "tcp",
14+
"appProtocol": "http"
15+
}
16+
],
17+
"essential": true,
18+
"restartPolicy": {
19+
"enabled": true,
20+
"restartAttemptPeriod": 300
21+
},
22+
"environment": [],
23+
"environmentFiles": [],
24+
"mountPoints": [],
25+
"volumesFrom": [],
26+
"ulimits": [],
27+
"logConfiguration": {
28+
"logDriver": "awslogs",
29+
"options": {
30+
"awslogs-group": "/ecs/fargate-basic-task",
31+
"awslogs-create-group": "true",
32+
"awslogs-region": "us-east-2",
33+
"awslogs-stream-prefix": "ecs"
34+
},
35+
"secretOptions": []
36+
},
37+
"systemControls": []
38+
}
39+
],
40+
"family": "fargate-basic-task",
41+
"taskRoleArn": "arn:aws:iam::621180867847:role/ecsTaskExecutionRole",
42+
"executionRoleArn": "arn:aws:iam::621180867847:role/ecsTaskExecutionRole",
43+
"networkMode": "awsvpc",
44+
"revision": 1,
45+
"volumes": [],
46+
"status": "ACTIVE",
47+
"requiresAttributes": [
48+
{
49+
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
50+
},
51+
{
52+
"name": "ecs.capability.execution-role-awslogs"
53+
},
54+
{
55+
"name": "com.amazonaws.ecs.capability.ecr-auth"
56+
},
57+
{
58+
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
59+
},
60+
{
61+
"name": "ecs.capability.container-restart-policy"
62+
},
63+
{
64+
"name": "com.amazonaws.ecs.capability.task-iam-role"
65+
},
66+
{
67+
"name": "ecs.capability.execution-role-ecr-pull"
68+
},
69+
{
70+
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
71+
},
72+
{
73+
"name": "ecs.capability.task-eni"
74+
},
75+
{
76+
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.29"
77+
}
78+
],
79+
"placementConstraints": [],
80+
"compatibilities": [
81+
"EC2",
82+
"FARGATE"
83+
],
84+
"requiresCompatibilities": [
85+
"FARGATE"
86+
],
87+
"cpu": "1024",
88+
"memory": "3072",
89+
"runtimePlatform": {
90+
"cpuArchitecture": "X86_64",
91+
"operatingSystemFamily": "LINUX"
92+
},
93+
"registeredAt": "2025-08-04T18:34:06.217Z",
94+
"registeredBy": "arn:aws:iam::621180867847:user/and-aws_@856",
95+
"enableFaultInjection": false,
96+
"tags": []
97+
}

.github/workflows/cd.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# This workflow will build and push a new container image to Amazon ECR,
2+
# and then will deploy a new task definition to Amazon ECS, when there is a push to the "main" branch.
3+
#
4+
# To use this workflow, you will need to complete the following set-up steps:
5+
#
6+
# 1. Create an ECR repository to store your images.
7+
# For example: `aws ecr create-repository --repository-name my-ecr-repo --region us-east-2`.
8+
# Replace the value of the `ECR_REPOSITORY` environment variable in the workflow below with your repository's name.
9+
# Replace the value of the `AWS_REGION` environment variable in the workflow below with your repository's region.
10+
#
11+
# 2. Create an ECS task definition, an ECS cluster, and an ECS service.
12+
# For example, follow the Getting Started guide on the ECS console:
13+
# https://us-east-2.console.aws.amazon.com/ecs/home?region=us-east-2#/firstRun
14+
# Replace the value of the `ECS_SERVICE` environment variable in the workflow below with the name you set for the Amazon ECS service.
15+
# Replace the value of the `ECS_CLUSTER` environment variable in the workflow below with the name you set for the cluster.
16+
#
17+
# 3. Store your ECS task definition as a JSON file in your repository.
18+
# The format should follow the output of `aws ecs register-task-definition --generate-cli-skeleton`.
19+
# Replace the value of the `ECS_TASK_DEFINITION` environment variable in the workflow below with the path to the JSON file.
20+
# Replace the value of the `CONTAINER_NAME` environment variable in the workflow below with the name of the container
21+
# in the `containerDefinitions` section of the task definition.
22+
#
23+
# 4. Store an IAM user access key in GitHub Actions secrets named `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`.
24+
# See the documentation for each action used below for the recommended IAM policies for this IAM user,
25+
# and best practices on handling the access key credentials.
26+
27+
name: CD Pipeline Amazon ECS
28+
29+
on:
30+
push:
31+
branches: ["main"]
32+
33+
env:
34+
AWS_REGION: us-east-2
35+
ECR_REPOSITORY: portfolio-web-repo
36+
ECS_SERVICE: fargate-basic-service-portfolio
37+
ECS_CLUSTER: portfolio-web-cluster
38+
ECS_TASK_DEFINITION: .aws/fargate-basic-task-revision1.json
39+
CONTAINER_NAME: app
40+
41+
permissions:
42+
contents: read
43+
44+
jobs:
45+
deploy:
46+
name: Deploy
47+
runs-on: ubuntu-latest
48+
environment: production
49+
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v4
53+
54+
- name: Configure AWS credentials
55+
uses: aws-actions/configure-aws-credentials@v1
56+
with:
57+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
58+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
59+
aws-region: ${{ env.AWS_REGION }}
60+
61+
- name: Login to Amazon ECR
62+
id: login-ecr
63+
uses: aws-actions/amazon-ecr-login@v1
64+
65+
- name: Build, tag, and push image to Amazon ECR
66+
id: build-image
67+
env:
68+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
69+
IMAGE_TAG: ${{ github.sha }}
70+
run: |
71+
# Build a docker container and
72+
# push it to ECR so that it can
73+
# be deployed to ECS.
74+
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
75+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
76+
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
77+
78+
- name: Fill in the new image ID in the Amazon ECS task definition
79+
id: task-def
80+
uses: aws-actions/amazon-ecs-render-task-definition@v1
81+
with:
82+
task-definition: ${{ env.ECS_TASK_DEFINITION }}
83+
container-name: ${{ env.CONTAINER_NAME }}
84+
image: ${{ steps.build-image.outputs.image }}
85+
86+
- name: Deploy Amazon ECS task definition
87+
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
88+
with:
89+
task-definition: ${{ steps.task-def.outputs.task-definition }}
90+
service: ${{ env.ECS_SERVICE }}
91+
cluster: ${{ env.ECS_CLUSTER }}
92+
wait-for-service-stability: true

backend/app.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ const uploadRoute = require('./routes/uploads.route');
1414

1515
const app = express();
1616

17+
const whitelist = [
18+
"http://localhost:3000",
19+
"http://localhost:5173",
20+
"http://localhost:8080",
21+
];
1722
const corsConfig = {
18-
origin: [
19-
"http://localhost:3000",
20-
"http://localhost:5173",
21-
],
23+
origin: whitelist,
2224
credentials: true,
2325
optionsSuccessStatus: 200
2426
};

compose.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ services:
66
env_file:
77
- backend/.env
88
restart: on-failure
9-
expose:
10-
- 3000
9+
ports:
10+
- "3000:3000"
1111
frontend:
1212
build: frontend
1313
ports:
14-
- "3000:5173"
14+
- "8080:5173"

frontend/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ RUN npm ci
55
COPY . .
66
RUN npm run build
77
EXPOSE 5173
8-
CMD [ "npm", "start", "--host" ]
8+
CMD [ "npm", "start"]

frontend/src/adminComponents/AdminEditProject/AdminEditProject.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function AdminEditProject({ projectObj, saveProject }) {
3939
return (
4040
<section className="project edit-container">
4141
<h3>New Project</h3>
42-
<form onSubmit={createProject}>
42+
<form>
4343
<div className="edit-item">
4444
<label htmlFor="name">Name: </label>
4545
<input
@@ -123,7 +123,9 @@ function AdminEditProject({ projectObj, saveProject }) {
123123
</label>
124124
</div>
125125

126-
<button type="submit">Create</button>
126+
<button type="submit" onClick={createProject}>
127+
Create
128+
</button>
127129
</form>
128130
</section>
129131
);

frontend/src/components/Contact/Contact.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@ form button {
5454
}
5555

5656
.contact-button {
57-
align-self: center;
57+
align-items: center;
5858
justify-self: center;
59+
display: flex;
60+
flex-direction: column;
61+
gap: 1rem;
5962
}
6063

6164
form button:hover {

frontend/src/components/Contact/Contact.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function Contact() {
7979
<section id="contact">
8080
<h2>Contact</h2>
8181
<div className="contact-section">
82-
<form className="section-item" onSubmit={handleSubmit}>
82+
<form className="section-item">
8383
<div>
8484
<input
8585
type="text"
@@ -122,13 +122,14 @@ function Contact() {
122122
></textarea>
123123
</div>
124124
<div className="contact-button">
125-
<button type="submit">Send message</button>
125+
<button type="submit" onClick={handleSubmit}>
126+
Send message
127+
</button>
126128
<div
127129
style={{
128-
alignSelf: "center",
129-
marginLeft: "1rem",
130130
color: submitMessageObj.color,
131-
fontSize: "1rem",
131+
fontSize: "1.25rem",
132+
marginTop: "-0.5rem",
132133
}}
133134
>
134135
<p>{submitMessageObj.message}</p>

frontend/src/components/Listing/Listing.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
text-decoration: none;
2323
color: inherit;
2424
display: flex;
25-
align-items: center;
25+
align-self: flex;
2626
}
2727

2828
.listingItem img {
@@ -36,7 +36,7 @@
3636
.listingItem p {
3737
text-align: left;
3838
display: inline;
39-
align-self: flex-end;
39+
align-self: center;
4040
}
4141

4242
.listingItem:hover {

0 commit comments

Comments
 (0)