Skip to content

Commit

Permalink
added
Browse files Browse the repository at this point in the history
docker install
terraforms
  • Loading branch information
OlhaDanylevska committed Feb 20, 2024
1 parent 00705e8 commit 95fd769
Show file tree
Hide file tree
Showing 10 changed files with 508 additions and 10 deletions.
Empty file added .aws/credentials
Empty file.
18 changes: 10 additions & 8 deletions .github/workflows/deploy-image.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
name: Deploy to VM

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Deploy to VM
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.AWS_HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
sudo apt-get update
sudo apt-get install -y docker.io
- name: Create tag for image
id: create_tag
run: |
Expand Down Expand Up @@ -57,7 +60,6 @@ jobs:
docker rm $CONTAINER_ID
fi
- name: Run container on VM server
uses: appleboy/ssh-action@master
with:
Expand Down
37 changes: 36 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,37 @@
node_modules
.env
.env

# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,45 @@ You are welcome to use [Bootstrap](https://getbootstrap.com/docs/4.0/getting-sta
Fork this repository and then clone it to your computer.

Progress to Level 100 when you are ready.



name: Node.js Deployment

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Update and Upgrade EC2 inst
run: |
sudo apt update
sudo apt upgrade -y

- name: Checkout Repository
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 12

- name: Install Dependencies
run: |
npm install

- name: rsync deployments
uses: burnett01/[email protected]
with:
switches: -avzr --exclude=node_modules --delete
path: ./server/
remote_path: ~/.video-app/
remote_host: ${{ secrets.AWS_HOST }}
remote_port: 22
remote_user: ${{ secrets.USERNAME }}
remote_key: ${{ secrets.SSH_PRIVATE_KEY }}
24 changes: 24 additions & 0 deletions client/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions client/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
provider "aws" {
region = "eu-west-2"
access_key = var.access_key
secret_key = var.secret_key
}

# Define variables
variable "access_key" {}
variable "secret_key" {}

resource "aws_s3_bucket" "video-app-olha" {
bucket = "video-app-olha"
}


resource "aws_s3_bucket_ownership_controls" "video-app-olha" {
bucket = aws_s3_bucket.video-app-olha.id
rule {
object_ownership = "BucketOwnerPreferred"
}
}

resource "aws_s3_bucket_public_access_block" "video-app-olha" {
bucket = aws_s3_bucket.video-app-olha.id

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

resource "aws_s3_bucket_acl" "video-app-olha" {
depends_on = [
aws_s3_bucket_ownership_controls.video-app-olha,
aws_s3_bucket_public_access_block.video-app-olha,
]

bucket = aws_s3_bucket.video-app-olha.id
acl = "public-read"
}

resource "aws_s3_bucket_website_configuration" "video-app-olha-web" {
bucket = aws_s3_bucket.video-app-olha.id

index_document {
suffix = "index.html"
}

error_document {
key = "error.html"
}

routing_rule {
condition {
key_prefix_equals = "docs/"
}
redirect {
replace_key_prefix_with = "documents/"
}
}

depends_on = [aws_s3_bucket.video-app-olha]
}
37 changes: 36 additions & 1 deletion server/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,37 @@
node_modules
.env
.env

# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc
20 changes: 20 additions & 0 deletions server/terraform/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 95fd769

Please sign in to comment.