Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Najah_farah|glasgow_6|fullstack_level300 #427

Closed
wants to merge 83 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
628aba7
removed all the node_modules
nfarah22 Sep 15, 2023
7fe5db4
added backend host to react components
nfarah22 Sep 15, 2023
84f4a42
Update App.js
nfarah22 Sep 15, 2023
00ce853
Update .gitignore
nfarah22 Sep 15, 2023
23e5b33
Delete .env
nfarah22 Sep 15, 2023
76b7edf
hello
nfarah22 Sep 16, 2023
a9ed35e
Remove build dir
nfarah22 Sep 16, 2023
de1e5e8
update
nfarah22 Sep 16, 2023
018a7fd
Update index.css
nfarah22 Sep 16, 2023
ae05319
Update VideoCard.js
nfarah22 Sep 16, 2023
15e511d
Update index.css
nfarah22 Sep 16, 2023
7cef194
Update index.css
nfarah22 Sep 16, 2023
38b96f6
css
nfarah22 Sep 16, 2023
bacdff8
Update index.css
nfarah22 Sep 16, 2023
bd137b2
css
nfarah22 Sep 16, 2023
eb2e4b1
embed videos function
nfarah22 Sep 16, 2023
0c85088
tiyding
nfarah22 Sep 18, 2023
c6f9705
update css
nfarah22 Sep 18, 2023
62649ce
remove button updated
nfarah22 Sep 18, 2023
6a10f07
Update VideoCard.js
nfarah22 Sep 18, 2023
1e581cc
Update AddVideo.js
nfarah22 Sep 18, 2023
d8ecced
Update AddVideo.js
nfarah22 Sep 18, 2023
5cbd020
Update config.js
nfarah22 Jan 23, 2024
ee99c46
added build
nfarah22 Jan 23, 2024
760cf27
update config
nfarah22 Jan 23, 2024
2f06413
added votes logic
nfarah22 Jan 23, 2024
5d68de3
added bootstrap styling
nfarah22 Jan 23, 2024
837a672
corrected errors
nfarah22 Jan 23, 2024
5225967
some new additions
nfarah22 Jan 23, 2024
2421ab7
aws
nfarah22 Jan 27, 2024
ed0f6d9
Update server.js
nfarah22 Jan 27, 2024
7bcc93a
Update server.js
nfarah22 Jan 27, 2024
9431746
Create youtubesaver
nfarah22 Jan 30, 2024
f5bc3c6
Rename youtubesaver to youtubesaver.yaml
nfarah22 Jan 30, 2024
0af7fbc
Update youtubesaver.yaml
nfarah22 Jan 30, 2024
ca1d4ef
Update youtubesaver.yaml
nfarah22 Jan 30, 2024
341d78b
Update youtubesaver.yaml
nfarah22 Jan 30, 2024
adfed3f
Update youtubesaver.yaml
nfarah22 Jan 30, 2024
6032a19
Create backend-ec2-deploy.yaml
nfarah22 Jan 31, 2024
e014b60
Update backend-ec2-deploy.yaml
nfarah22 Jan 31, 2024
821ff8d
Update backend-ec2-deploy.yaml
nfarah22 Feb 1, 2024
6b0e2b0
Update backend-ec2-deploy.yaml
nfarah22 Feb 1, 2024
c0208a7
Update package.json
nfarah22 Feb 1, 2024
70d6d9a
Update backend-ec2-deploy.yaml
nfarah22 Feb 1, 2024
09b3965
Update backend-ec2-deploy.yaml
nfarah22 Feb 1, 2024
d15bf6a
Update backend-ec2-deploy.yaml
nfarah22 Feb 1, 2024
959ab14
Update backend-ec2-deploy.yaml
nfarah22 Feb 1, 2024
d514cdd
Update server.js
nfarah22 Feb 3, 2024
d4de478
Merge branch 'backup' of https://github.com/nfarah22/Full-Stack-Proje…
nfarah22 Feb 3, 2024
05f1c25
Update config.js
nfarah22 Feb 3, 2024
79e370f
Update backend-ec2-deploy.yaml
nfarah22 Feb 4, 2024
aee6431
Update backend-ec2-deploy.yaml
nfarah22 Feb 4, 2024
88acf04
Update server.js
nfarah22 Feb 4, 2024
cf12bbe
Merge branch 'backup' of https://github.com/nfarah22/Full-Stack-Proje…
nfarah22 Feb 4, 2024
ae4a853
Merge branch 'backup' of https://github.com/nfarah22/Full-Stack-Proje…
nfarah22 Feb 4, 2024
5ea3793
update server.js
nfarah22 Feb 4, 2024
a4a7936
Update VideoCard.js
nfarah22 Feb 6, 2024
2a3e62f
Docker backend automation
nfarah22 Feb 10, 2024
dc156bd
updating aws region env
nfarah22 Feb 10, 2024
062ea00
Update
nfarah22 Feb 11, 2024
29b6b48
testing
nfarah22 Feb 11, 2024
68456fb
Update backend-ec2-deploy.yaml
nfarah22 Feb 11, 2024
3e7563e
Update backend-ec2-deploy.yaml
nfarah22 Feb 11, 2024
75208ac
Update backend-ec2-deploy.yaml
nfarah22 Feb 11, 2024
ff4d656
Update backend-ec2-deploy.yaml
nfarah22 Feb 16, 2024
f1ee5ae
update server.js
nfarah22 Feb 16, 2024
b901301
Merge branch 'backup' of https://github.com/nfarah22/Full-Stack-Proje…
nfarah22 Feb 16, 2024
f025f31
Update backend-ec2-deploy.yaml
nfarah22 Feb 16, 2024
0e0095e
Update backend-ec2-deploy.yaml
nfarah22 Feb 16, 2024
3a88c46
Update backend-ec2-deploy.yaml
nfarah22 Feb 16, 2024
a4c1565
Update backend-ec2-deploy.yaml
nfarah22 Feb 16, 2024
2129b28
Update backend-ec2-deploy.yaml
nfarah22 Feb 16, 2024
e88a8b4
Update backend-ec2-deploy.yaml
nfarah22 Feb 16, 2024
54c5034
terraform files
nfarah22 Feb 24, 2024
9c8527a
Merge branch 'backup' of https://github.com/nfarah22/Full-Stack-Proje…
nfarah22 Feb 24, 2024
e4bbcc3
Create .gitignore
nfarah22 Feb 24, 2024
62fb58f
Update backend-ec2-deploy.yaml
nfarah22 Feb 25, 2024
f9f3004
Update youtubesaver.yaml
nfarah22 Feb 25, 2024
503c06c
update permissions for s3
nfarah22 Feb 25, 2024
f07afeb
Merge branch 'backup' of https://github.com/nfarah22/Full-Stack-Proje…
nfarah22 Feb 25, 2024
9231761
Update backend-ec2-deploy.yaml
nfarah22 Feb 25, 2024
0ae304f
health check
nfarah22 Mar 5, 2024
b8510e6
Update server.js
nfarah22 Mar 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/backend-ec2-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@

name: EC2 Deployment

on:
push:
branches: [ backup ]

jobs:
deploy-to-ec2:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
env:
AWS_REGION: eu-north-1
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: arn:aws:iam::058264451725:role/githutactionsECRAcess
role-session-name: GitHubActionsSession

- name: Log in to AWS ECR
uses: aws-actions/amazon-ecr-login@v1

- name: Build Docker image
run: |
ECR_REPOSITORY=058264451725.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/backend.docker
IMAGE_TAG=latest
docker build -t $ECR_REPOSITORY:$IMAGE_TAG .
working-directory: ./server

- name: Tag Docker image
run: |
ECR_REPOSITORY=058264451725.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/backend.docker
IMAGE_TAG=latest
docker tag $ECR_REPOSITORY:$IMAGE_TAG $ECR_REPOSITORY:$IMAGE_TAG
working-directory: ./server

- name: Push Docker image to ECR
run: |
ECR_REPOSITORY=058264451725.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/backend.docker
IMAGE_TAG=latest
docker push $ECR_REPOSITORY:$IMAGE_TAG
working-directory: ./server

- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_SSH_USERNAME }}
key: ${{ secrets.EC2_SSH_PRIVATE_KEY }}
port: 22
script: |
sudo su - root <<'EOF'
echo "Switching to root user to perform tasks"
export ECR_REPOSITORY=058264451725.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/backend.docker
export IMAGE_TAG=latest
aws ecr get-login-password --region ${{ env.AWS_REGION }} | docker login --username AWS --password-stdin $ECR_REPOSITORY
docker stop sharp_zhukovsky || true && docker rm sharp_zhukovsky || true
docker run -d -p 5000:5000 \
-e DB_NAME='${{ secrets.DB_NAME }}' \
-e DB_HOST='${{ secrets.DB_HOST }}' \
-e DB_PASSWORD='${{ secrets.DB_PASSWORD }}' \
-e DB_PORT='${{ secrets.DB_PORT }}' \
-e DB_USER='${{ secrets.DB_USER }}' \
$ECR_REPOSITORY:$IMAGE_TAG
EOF
41 changes: 41 additions & 0 deletions .github/workflows/youtubesaver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Youtubesaver CI/CD

on:
push:
branches: [ backup ]

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install dependencies
run: npm install
working-directory: ./client

- name: Build
run: npm run build
working-directory: ./client

- name: Test
run: npm test -- --passWithNoTests
working-directory: ./client

- name: Accessing AWS secret
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: 'eu-north-1'

- name: Deploy
run: aws s3 sync build/ s3://youtubesaver2 --delete
working-directory: ./client
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

Infrastructure/EC2/.terraform.lock.hcl
Infrastructure/EC2/.terraform/providers/registry.terraform.io/hashicorp/aws/5.37.0/windows_386/terraform-provider-aws_v5.37.0_x5.exe
Infrastructure/EC2/terraform.tfstate
Infrastructure/EC2/terraform.tfstate.backup
Infrastructure/RDS/.terraform.lock.hcl
Infrastructure/RDS/.terraform/providers/registry.terraform.io/hashicorp/aws/5.37.0/windows_386/terraform-provider-aws_v5.37.0_x5.exe
Infrastructure/RDS/terraform.tfstate
Infrastructure/RDS/terraform.tfstate.backup
Infrastructure/S3/.terraform.lock.hcl
Infrastructure/S3/.terraform/providers/registry.terraform.io/hashicorp/aws/5.37.0/windows_386/terraform-provider-aws_v5.37.0_x5.exe
Infrastructure/S3/terraform.tfstate
Infrastructure/S3/terraform.tfstate.backup
Infrastructure/.env
22 changes: 22 additions & 0 deletions Infrastructure/EC2/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
provider "aws" {
region = "eu-north-1"
}

resource "aws_instance" "backend" {
ami = "ami-0014ce3e52359afbd"
instance_type = "t3.micro"
key_name = "youtubesaver-nf"
iam_instance_profile = "s3toec2"
subnet_id = "subnet-08b756f6517a09fbe"
vpc_security_group_ids = ["sg-09c5dd40586ee7079"]

root_block_device {
volume_type = "gp2"
volume_size = 8
}

tags = {
Name = "backend"
}
}

34 changes: 34 additions & 0 deletions Infrastructure/RDS/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
provider "aws" {
region = "eu-north-1"
}

resource "aws_db_subnet_group" "default" {
name = var.db_subnet_group_name # Ensures variable usage for name
subnet_ids = var.subnet_ids

tags = {
Name = "My DB Subnet Group"
}
}

resource "aws_db_instance" "default" {
allocated_storage = 20
storage_type = "gp2"
engine = "postgres"
engine_version = "15.5"
instance_class = "db.t3.micro"
identifier = "database-terraform"
db_subnet_group_name = var.db_subnet_group_name
vpc_security_group_ids = ["sg-09c5dd40586ee7079"]

username = "postgres"
password = var.db_password
parameter_group_name = "default.postgres15"

db_name = "terraform_DB"
skip_final_snapshot = true
publicly_accessible = false

depends_on = [aws_db_subnet_group.default]
}

20 changes: 20 additions & 0 deletions Infrastructure/RDS/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
variable "db_password" {
description = "The password for the RDS database instance"
type = string
sensitive = true
}

variable "db_subnet_group_name" {
description = "The name of the DB subnet group for the RDS instance"
type = string
default = "tf_data"
}

variable "subnet_ids" {
description = "List of subnet IDs for the DB Subnet Group"
type = list(string)
default = [
"subnet-08b756f6517a09fbe",
"subnet-0acd6ca43de4591c7"
]
}
58 changes: 58 additions & 0 deletions Infrastructure/S3/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
provider "aws" {
region = "eu-north-1"
}

resource "aws_s3_bucket" "youtubesaver2" {
bucket = "youtubesaver2"

website {
index_document = "index.html"
error_document = "error.html"
}
}

resource "aws_s3_bucket_public_access_block" "youtubesaver2_public_access" {
bucket = aws_s3_bucket.youtubesaver2.id

block_public_acls = false
ignore_public_acls = false
block_public_policy = false
restrict_public_buckets = false
}

resource "aws_s3_bucket_policy" "youtubesaver2_policy" {
bucket = aws_s3_bucket.youtubesaver2.id

policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Statement1",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject"
],
"Resource": "arn:aws:s3:::youtubesaver2/*"
},
{
"Sid": "Statement2",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::youtubesaver2"
}
]
}

POLICY
}






1 change: 1 addition & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
13 changes: 13 additions & 0 deletions client/build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"files": {
"main.css": "/static/css/main.4d239a8c.css",
"main.js": "/static/js/main.07583670.js",
"index.html": "/index.html",
"main.4d239a8c.css.map": "/static/css/main.4d239a8c.css.map",
"main.07583670.js.map": "/static/js/main.07583670.js.map"
},
"entrypoints": [
"static/css/main.4d239a8c.css",
"static/js/main.07583670.js"
]
}
1 change: 1 addition & 0 deletions client/build/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.07583670.js"></script><link href="/static/css/main.4d239a8c.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
8 changes: 8 additions & 0 deletions client/build/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"short_name": "To Do App",
"name": "To Do App",
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions client/build/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
6 changes: 6 additions & 0 deletions client/build/static/css/main.4d239a8c.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions client/build/static/css/main.4d239a8c.css.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions client/build/static/js/main.07583670.js

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions client/build/static/js/main.07583670.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/

/** @license React v0.20.2
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/** @license React v17.0.2
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/** @license React v17.0.2
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/** @license React v17.0.2
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
1 change: 1 addition & 0 deletions client/build/static/js/main.07583670.js.map

Large diffs are not rendered by default.

Loading