From 79900cad30c909dd1c5d5983e0c4ed222d3578e9 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 03:04:07 -0300 Subject: [PATCH 001/103] create instance ec2 --- .gitignore | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f57af93 --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +# Local .terraform directories +**/.terraform/* +/.terraform/* + +# .tfstate files +*.tfstate +*.tfstate.* + +# Crash log files +crash.log + +# Ignore any .tfvars files that are generated automatically for each Terraform run. Most +# .tfvars files are managed as part of configuration and so should be included in +# version control. +# +# example.tfvars + +# 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* + +.idea +*.zip +node_modules +.terraform +.DS_STORE \ No newline at end of file From 4736874d4e188703f2df8e682ddf873587872b07 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 03:10:41 -0300 Subject: [PATCH 002/103] create files terraform --- terraform/main.tf | 17 +++++++++++++++++ terraform/variables.tf | 23 +++++++++++++++++++++++ terraform/version.tf | 30 ++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 terraform/main.tf create mode 100644 terraform/variables.tf create mode 100644 terraform/version.tf diff --git a/terraform/main.tf b/terraform/main.tf new file mode 100644 index 0000000..c34c319 --- /dev/null +++ b/terraform/main.tf @@ -0,0 +1,17 @@ +data "aws_ami" "ubuntu" { + owners = ["amazon"] + most_recent = true + name_regex = "Ubuntu" +} + +resource "aws_instance" "web" { + ami = data.aws_ami.ubuntu.id + instance_type = var.instance_type + + + tags = { + Name = "${var.environment}: App" + Env = var.environment + Type = var.instance_type + } +} \ No newline at end of file diff --git a/terraform/variables.tf b/terraform/variables.tf new file mode 100644 index 0000000..47fe922 --- /dev/null +++ b/terraform/variables.tf @@ -0,0 +1,23 @@ +variable "aws_region" { + type = string + description = "The AWS region to deploy to" + default = "us-east-1" +} + +variable "aws_profile" { + type = string + description = "The AWS profile to use to execute the commands" + default = "default" +} + +variable "environment" { + type = string + description = "The environment to deploy to" + default = "dev" +} + +variable "instance_type" { + type = string + description = "The instance power" + default = "t2.micro" +} diff --git a/terraform/version.tf b/terraform/version.tf new file mode 100644 index 0000000..057952d --- /dev/null +++ b/terraform/version.tf @@ -0,0 +1,30 @@ +provider "aws" { + region = var.aws_region + + default_tags { + tags = { + Project = "Terraform GHA setup" + CreatedAt = "2021-06-05" + ManagedBy = "Terraform" + Owner = "Web enterprise" + } + } +} + + +terraform { +# required_version = "1.5.3" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 3.44.0" + } + } + + backend "s3" { + bucket = "richardneves-tfstate" + key = "dev/tfstate-challenge" + region = "us-east-1" +} +} From 1e98ede7ca26f08a861cd17eb9b6cff57a8e8811 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 03:15:08 -0300 Subject: [PATCH 003/103] create workflows --- .github/workflows/apply-dev.yml | 47 +++++++++++++++++++++++++++++++++ terraform/.terraform.lock.hcl | 25 ++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 .github/workflows/apply-dev.yml create mode 100644 terraform/.terraform.lock.hcl diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml new file mode 100644 index 0000000..1a63082 --- /dev/null +++ b/.github/workflows/apply-dev.yml @@ -0,0 +1,47 @@ +name: Apply terraform Instance AWS EC2 + +on: + push: + branches: + - main + - master + paths: + - 'terraform/**' + +env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + +jobs: + apply-dev: + name: 'terraform apply dev' + runs-on: ubuntu-latest + env: + TF_WORKING_DIR: 'terraform' + + defaults: + run: + shell: bash + working-directory: ${{ env.TF_WORKING_DIR }} + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Terraform + uses: hashicorp/setup-terraform@v1 + + - name: Terraform fmt + id: fmt + run: terraform fmt -check + + - name: Terraform Init + id: init + run: terraform init + + - name: Terraform Validate + id: validate + run: terraform validate -no-color + + - name: Terraform Apply + run: terraform apply \ No newline at end of file diff --git a/terraform/.terraform.lock.hcl b/terraform/.terraform.lock.hcl new file mode 100644 index 0000000..54261ee --- /dev/null +++ b/terraform/.terraform.lock.hcl @@ -0,0 +1,25 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "5.24.0" + constraints = ">= 3.44.0" + hashes = [ + "h1:5kF6+4jUPI73O/uDvm/8/NiKRhiaOqMTqdo5l8uAygo=", + "zh:164b4ac71c9fc6b991021dd6e829591b0c1a0ebfb5831da0a7eb4f10f92c76a7", + "zh:22e85772a1767498796f160b54a156db8173c4e238469dad8328a65093e033e1", + "zh:2655853a6e716a551190bed0ad083e2bdc8a6e9d21e9724bea3c4a97c5985bd8", + "zh:292bf6c084e23b0189d633600cde08eb61ff916e7083f9288c44daec6e566513", + "zh:2ff0f1c78a17cf11010a8beba338b9f72f3148fc37d349faa6278e523877886d", + "zh:643d3a464826b10d746cafea97739a69462c5982ac2dd31001cb798af3548a2e", + "zh:6fcaf09ebc03bc7aeb7340494dc3a75983875d309a93bf1f421774a10c65e994", + "zh:77a2f9b3f89c0a9d6c72be0724d1635cb9cbc69058e60e4bc78fe4091cc2f9a4", + "zh:7a9258d51b2b4437e8dda188a522ceff0df128cb1840713b0453f5d4fe35b452", + "zh:9231fbc0d27e7bdd214f55f05ad85af9d44a0b36a06a4e2747d7c634b2f443bb", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:a805f3caefb98d007958f900e1f55e6fbd0849df3d99cafd96a0c5898170c153", + "zh:aa034c4cefacae133027ec3ebd80b43856fe67b9617a8c854e2a95a637d99023", + "zh:ef0f5bb925e77f1f32210458a372523edc73c70a4cce1c25e39f4498f5b50aa7", + "zh:fc26f82eb289f1476a7486130e2c7e22416c40f77218a7b63c80d59a7ce0de3a", + ] +} From b79fd681c01d568f5f2db684703ebe8bf5c52447 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 03:20:04 -0300 Subject: [PATCH 004/103] create more workflos --- .github/workflows/apply-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 1a63082..160ea1c 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -33,7 +33,7 @@ jobs: - name: Terraform fmt id: fmt - run: terraform fmt -check + run: terraform fmt - name: Terraform Init id: init From 2c0cfeaab9c990ab2f37c66b5fd2ca366d4b38cb Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 03:21:51 -0300 Subject: [PATCH 005/103] create more workflos --- .github/workflows/apply-dev.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 160ea1c..7a99f45 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -31,9 +31,9 @@ jobs: - name: Setup Terraform uses: hashicorp/setup-terraform@v1 - - name: Terraform fmt - id: fmt - run: terraform fmt + # - name: Terraform fmt + # id: fmt + # run: terraform fmt - name: Terraform Init id: init From c7896e0b37336abf90cd3c8bfef2170d756ab251 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 03:23:02 -0300 Subject: [PATCH 006/103] testando workflows --- .github/workflows/apply-dev.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 7a99f45..160ea1c 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -31,9 +31,9 @@ jobs: - name: Setup Terraform uses: hashicorp/setup-terraform@v1 - # - name: Terraform fmt - # id: fmt - # run: terraform fmt + - name: Terraform fmt + id: fmt + run: terraform fmt - name: Terraform Init id: init From 668f145c443e736fb69bf797be2cde15919d7fed Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 03:24:49 -0300 Subject: [PATCH 007/103] alterando workflow --- .github/workflows/apply-dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 160ea1c..64081dd 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -43,5 +43,5 @@ jobs: id: validate run: terraform validate -no-color - - name: Terraform Apply - run: terraform apply \ No newline at end of file + - name: Terraform Apply + run: terraform apply --auto-approve \ No newline at end of file From 20c23139bd0c3d2ac4a25150370b54e0efbb95a8 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 03:26:45 -0300 Subject: [PATCH 008/103] teste --- .github/workflows/teste | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .github/workflows/teste diff --git a/.github/workflows/teste b/.github/workflows/teste new file mode 100644 index 0000000..e69de29 From 47947dc9fd4a6239ce06cc3761b74ae293b6b465 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 03:27:56 -0300 Subject: [PATCH 009/103] workflow --- .github/workflows/apply-dev.yml | 6 +++--- .github/workflows/teste | 0 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 .github/workflows/teste diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 64081dd..1a63082 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -33,7 +33,7 @@ jobs: - name: Terraform fmt id: fmt - run: terraform fmt + run: terraform fmt -check - name: Terraform Init id: init @@ -43,5 +43,5 @@ jobs: id: validate run: terraform validate -no-color - - name: Terraform Apply - run: terraform apply --auto-approve \ No newline at end of file + - name: Terraform Apply + run: terraform apply \ No newline at end of file diff --git a/.github/workflows/teste b/.github/workflows/teste deleted file mode 100644 index e69de29..0000000 From 922e017044fad2951c6b8d7933a214fc95e7b614 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 03:37:06 -0300 Subject: [PATCH 010/103] testando runner --- .github/workflows/apply-dev.yml | 47 --------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 .github/workflows/apply-dev.yml diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml deleted file mode 100644 index 1a63082..0000000 --- a/.github/workflows/apply-dev.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Apply terraform Instance AWS EC2 - -on: - push: - branches: - - main - - master - paths: - - 'terraform/**' - -env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - -jobs: - apply-dev: - name: 'terraform apply dev' - runs-on: ubuntu-latest - env: - TF_WORKING_DIR: 'terraform' - - defaults: - run: - shell: bash - working-directory: ${{ env.TF_WORKING_DIR }} - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup Terraform - uses: hashicorp/setup-terraform@v1 - - - name: Terraform fmt - id: fmt - run: terraform fmt -check - - - name: Terraform Init - id: init - run: terraform init - - - name: Terraform Validate - id: validate - run: terraform validate -no-color - - - name: Terraform Apply - run: terraform apply \ No newline at end of file From a33275f9818643cd763466713ea56966ec6bdc8b Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 03:37:58 -0300 Subject: [PATCH 011/103] testando runner --- .github/workflows/apply-dev.yml | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/apply-dev.yml diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml new file mode 100644 index 0000000..1a63082 --- /dev/null +++ b/.github/workflows/apply-dev.yml @@ -0,0 +1,47 @@ +name: Apply terraform Instance AWS EC2 + +on: + push: + branches: + - main + - master + paths: + - 'terraform/**' + +env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + +jobs: + apply-dev: + name: 'terraform apply dev' + runs-on: ubuntu-latest + env: + TF_WORKING_DIR: 'terraform' + + defaults: + run: + shell: bash + working-directory: ${{ env.TF_WORKING_DIR }} + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Terraform + uses: hashicorp/setup-terraform@v1 + + - name: Terraform fmt + id: fmt + run: terraform fmt -check + + - name: Terraform Init + id: init + run: terraform init + + - name: Terraform Validate + id: validate + run: terraform validate -no-color + + - name: Terraform Apply + run: terraform apply \ No newline at end of file From 54641f23bdd9ae51c64600b151d9caa30b240c45 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 03:55:54 -0300 Subject: [PATCH 012/103] testando --- .github/workflows/apply-prod.yml | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/apply-prod.yml diff --git a/.github/workflows/apply-prod.yml b/.github/workflows/apply-prod.yml new file mode 100644 index 0000000..b643d69 --- /dev/null +++ b/.github/workflows/apply-prod.yml @@ -0,0 +1,46 @@ +name: Apply terraform resources on folder 0003-terraform-gha with prod config + +on: + push: + tags: + - v[12].[0-9]+.[0-9]+ + +env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + +jobs: + apply-prod: + name: 'terraform apply prod' + runs-on: ubuntu-latest + env: + TF_WORKING_DIR: '0003-terraform-gha' + + defaults: + run: + shell: bash + working-directory: ${{ env.TF_WORKING_DIR }} + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Terraform + uses: hashicorp/setup-terraform@v1 + with: + terraform_version: 0.15.5 + + - name: Terraform fmt + id: fmt + run: terraform fmt -check + + - name: Terraform Init + id: init + run: terraform init -backend=true -backend-config="config/prod/backend.hcl" + + - name: Terraform Validate + id: validate + run: terraform validate -no-color + + - name: Terraform Apply + run: terraform apply -auto-approve -var-file="config/prod/terraform.tfvars" \ No newline at end of file From 6d49c14a7b7a50785abc811ee32c8abcd169772b Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 03:58:59 -0300 Subject: [PATCH 013/103] testando --- .github/workflows/apply-prod.yml | 46 -------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 .github/workflows/apply-prod.yml diff --git a/.github/workflows/apply-prod.yml b/.github/workflows/apply-prod.yml deleted file mode 100644 index b643d69..0000000 --- a/.github/workflows/apply-prod.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Apply terraform resources on folder 0003-terraform-gha with prod config - -on: - push: - tags: - - v[12].[0-9]+.[0-9]+ - -env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - -jobs: - apply-prod: - name: 'terraform apply prod' - runs-on: ubuntu-latest - env: - TF_WORKING_DIR: '0003-terraform-gha' - - defaults: - run: - shell: bash - working-directory: ${{ env.TF_WORKING_DIR }} - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup Terraform - uses: hashicorp/setup-terraform@v1 - with: - terraform_version: 0.15.5 - - - name: Terraform fmt - id: fmt - run: terraform fmt -check - - - name: Terraform Init - id: init - run: terraform init -backend=true -backend-config="config/prod/backend.hcl" - - - name: Terraform Validate - id: validate - run: terraform validate -no-color - - - name: Terraform Apply - run: terraform apply -auto-approve -var-file="config/prod/terraform.tfvars" \ No newline at end of file From dfc749c698a38c203e8beb9c8928fa53ca9f39cc Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 03:59:57 -0300 Subject: [PATCH 014/103] removing files actions --- .github/workflows/apply-dev.yml | 47 --------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 .github/workflows/apply-dev.yml diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml deleted file mode 100644 index 1a63082..0000000 --- a/.github/workflows/apply-dev.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Apply terraform Instance AWS EC2 - -on: - push: - branches: - - main - - master - paths: - - 'terraform/**' - -env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - -jobs: - apply-dev: - name: 'terraform apply dev' - runs-on: ubuntu-latest - env: - TF_WORKING_DIR: 'terraform' - - defaults: - run: - shell: bash - working-directory: ${{ env.TF_WORKING_DIR }} - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup Terraform - uses: hashicorp/setup-terraform@v1 - - - name: Terraform fmt - id: fmt - run: terraform fmt -check - - - name: Terraform Init - id: init - run: terraform init - - - name: Terraform Validate - id: validate - run: terraform validate -no-color - - - name: Terraform Apply - run: terraform apply \ No newline at end of file From 6545bbd9668e933a84d93c73a93360f6ec481298 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 04:02:01 -0300 Subject: [PATCH 015/103] sending files actions --- .github/workflows/apply-dev.yml | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/apply-dev.yml diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml new file mode 100644 index 0000000..1a63082 --- /dev/null +++ b/.github/workflows/apply-dev.yml @@ -0,0 +1,47 @@ +name: Apply terraform Instance AWS EC2 + +on: + push: + branches: + - main + - master + paths: + - 'terraform/**' + +env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + +jobs: + apply-dev: + name: 'terraform apply dev' + runs-on: ubuntu-latest + env: + TF_WORKING_DIR: 'terraform' + + defaults: + run: + shell: bash + working-directory: ${{ env.TF_WORKING_DIR }} + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Terraform + uses: hashicorp/setup-terraform@v1 + + - name: Terraform fmt + id: fmt + run: terraform fmt -check + + - name: Terraform Init + id: init + run: terraform init + + - name: Terraform Validate + id: validate + run: terraform validate -no-color + + - name: Terraform Apply + run: terraform apply \ No newline at end of file From 17c98ab3ac5ab6afc99dfc1107ed814b537027f3 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 04:04:02 -0300 Subject: [PATCH 016/103] runner --- .github/workflows/apply-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 1a63082..e578210 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -4,7 +4,7 @@ on: push: branches: - main - - master + - [ "master" ] paths: - 'terraform/**' From ac14ca5b4c42c6db9a4782e48afb2b7d2ad05936 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 04:05:52 -0300 Subject: [PATCH 017/103] testando runner --- .github/workflows/apply-dev.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index e578210..0cfe1de 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -2,9 +2,7 @@ name: Apply terraform Instance AWS EC2 on: push: - branches: - - main - - [ "master" ] + branches: [ "master" ] paths: - 'terraform/**' From 1584f980a14ae7c2e18cf7ba8bb8b8d0bd1e0a9b Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 04:07:17 -0300 Subject: [PATCH 018/103] teste runner --- .github/workflows/apply-dev.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 0cfe1de..34aa311 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -2,7 +2,8 @@ name: Apply terraform Instance AWS EC2 on: push: - branches: [ "master" ] + branches: + [ "master" ] paths: - 'terraform/**' From 8c2e93f4a2c7fdf5a836fe6654bdaf8b4d218698 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 04:07:52 -0300 Subject: [PATCH 019/103] testando runner --- .github/workflows/apply-dev.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 34aa311..0cfe1de 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -2,8 +2,7 @@ name: Apply terraform Instance AWS EC2 on: push: - branches: - [ "master" ] + branches: [ "master" ] paths: - 'terraform/**' From 343ce1597cbfb14ad88a9595ead26462ab6ad27f Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 04:08:38 -0300 Subject: [PATCH 020/103] runner --- .github/workflows/apply-dev.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 0cfe1de..fb2c850 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -2,7 +2,9 @@ name: Apply terraform Instance AWS EC2 on: push: - branches: [ "master" ] + branches: + - master + paths: - 'terraform/**' From 3cec5ad090ec776f9a29b9b79f5b158f45124a33 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 04:09:46 -0300 Subject: [PATCH 021/103] runner failed --- .github/workflows/apply-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index fb2c850..5b87483 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -3,7 +3,7 @@ name: Apply terraform Instance AWS EC2 on: push: branches: - - master + - main paths: - 'terraform/**' From 48dd2cb7d07e174139fb56565b52ec98a9b88c42 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Thu, 9 Nov 2023 04:34:39 -0300 Subject: [PATCH 022/103] Update apply-dev.yml --- .github/workflows/apply-dev.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 5b87483..16ec27a 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -1,9 +1,8 @@ name: Apply terraform Instance AWS EC2 -on: - push: - branches: - - main +on: [push] + # branches: + # - main paths: - 'terraform/**' @@ -44,4 +43,4 @@ jobs: run: terraform validate -no-color - name: Terraform Apply - run: terraform apply \ No newline at end of file + run: terraform apply From 0e0be16f1d72fe6a2b04876918b2acf0538bfa7c Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Thu, 9 Nov 2023 04:36:02 -0300 Subject: [PATCH 023/103] Update apply-dev.yml --- .github/workflows/apply-dev.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 16ec27a..1f215a1 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -3,7 +3,6 @@ name: Apply terraform Instance AWS EC2 on: [push] # branches: # - main - paths: - 'terraform/**' From 7bde7105830df3daae5a20aae91e276c5b36ac35 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Thu, 9 Nov 2023 04:36:37 -0300 Subject: [PATCH 024/103] Update apply-dev.yml --- .github/workflows/apply-dev.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 1f215a1..e59daff 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -1,8 +1,6 @@ name: Apply terraform Instance AWS EC2 on: [push] - # branches: - # - main paths: - 'terraform/**' From 13ef030ca8d30662cea38867e29bfe6b02048a13 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Thu, 9 Nov 2023 04:39:43 -0300 Subject: [PATCH 025/103] Update apply-dev.yml --- .github/workflows/apply-dev.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index e59daff..ea51f6e 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -1,6 +1,8 @@ name: Apply terraform Instance AWS EC2 -on: [push] +on: + push + branches [ '*' ] paths: - 'terraform/**' From 76525e429583047243b423049465310411b13c00 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Thu, 9 Nov 2023 04:41:16 -0300 Subject: [PATCH 026/103] Update apply-dev.yml --- .github/workflows/apply-dev.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index ea51f6e..0aae59f 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -1,7 +1,8 @@ name: Apply terraform Instance AWS EC2 on: - push + workflow_call: + branches [ '*' ] paths: - 'terraform/**' From 8dd41123591de16454327065532146e6707b0349 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Thu, 9 Nov 2023 04:42:11 -0300 Subject: [PATCH 027/103] Update apply-dev.yml --- .github/workflows/apply-dev.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 0aae59f..ef6d4e9 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -2,8 +2,6 @@ name: Apply terraform Instance AWS EC2 on: workflow_call: - - branches [ '*' ] paths: - 'terraform/**' From ea39dd323914d23789f83631e44873b36e337485 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Thu, 9 Nov 2023 04:42:59 -0300 Subject: [PATCH 028/103] Update apply-dev.yml --- .github/workflows/apply-dev.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index ef6d4e9..2446365 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -2,6 +2,7 @@ name: Apply terraform Instance AWS EC2 on: workflow_call: + paths: - 'terraform/**' From b7b4a3ddf97dfca079f3fa4f4c650d635d045d68 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Thu, 9 Nov 2023 04:43:45 -0300 Subject: [PATCH 029/103] Update apply-dev.yml --- .github/workflows/apply-dev.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 2446365..a14c52f 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -1,7 +1,8 @@ name: Apply terraform Instance AWS EC2 on: - workflow_call: + push: + branches [ '*' ] paths: - 'terraform/**' From 70304cac4154839948330ba8c9aa6843820cf0ec Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Thu, 9 Nov 2023 04:44:25 -0300 Subject: [PATCH 030/103] Update apply-dev.yml --- .github/workflows/apply-dev.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index a14c52f..e059cc7 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -4,9 +4,6 @@ on: push: branches [ '*' ] - paths: - - 'terraform/**' - env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} From 233b5f7aaad7938d9bf7468a45ac83da298042d5 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Thu, 9 Nov 2023 04:45:14 -0300 Subject: [PATCH 031/103] Update apply-dev.yml --- .github/workflows/apply-dev.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index e059cc7..6edb10d 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -3,6 +3,8 @@ name: Apply terraform Instance AWS EC2 on: push: branches [ '*' ] + paths: + - 'terraform/**' env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} From 14ad0350d87c5f60df2f8a712de470368968f76c Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Thu, 9 Nov 2023 04:48:48 -0300 Subject: [PATCH 032/103] teste --- .github/workflows/apply-dev.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 6edb10d..cbb82fb 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -1,11 +1,13 @@ -name: Apply terraform Instance AWS EC2 +name: Apply terraform resources on folder 0003-terraform-gha with dev config -on: +on: push: - branches [ '*' ] - paths: - - 'terraform/**' - + branches: + - main + - master + paths: + - 'terraform/**' + env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} @@ -28,6 +30,8 @@ jobs: - name: Setup Terraform uses: hashicorp/setup-terraform@v1 + with: + terraform_version: 0.15.5 - name: Terraform fmt id: fmt @@ -35,11 +39,11 @@ jobs: - name: Terraform Init id: init - run: terraform init + run: terraform init -backend=true -backend-config="config/dev/backend.hcl" - name: Terraform Validate id: validate run: terraform validate -no-color - name: Terraform Apply - run: terraform apply + run: terraform apply -auto-approve -var-file="config/dev/terraform.tfvars" From 463aae73bcb6e43d442cf04b30e770d92a7d0ab0 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Thu, 9 Nov 2023 04:50:27 -0300 Subject: [PATCH 033/103] teste --- .github/workflows/apply-dev.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index cbb82fb..082cab5 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -1,10 +1,6 @@ name: Apply terraform resources on folder 0003-terraform-gha with dev config -on: - push: - branches: - - main - - master +on: [push] paths: - 'terraform/**' From ecc5a583aa2fbc7809c4a34f58c458d23909e031 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Thu, 9 Nov 2023 04:52:32 -0300 Subject: [PATCH 034/103] Update apply-dev.yml --- .github/workflows/apply-dev.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 082cab5..7e267ca 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -1,8 +1,8 @@ name: Apply terraform resources on folder 0003-terraform-gha with dev config -on: [push] - paths: - - 'terraform/**' +on: + push: + branches: [master] env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} From d6528759a2393812067e8b9b37297766610a011b Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 04:54:16 -0300 Subject: [PATCH 035/103] testando runner --- .github/workflows/apply-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 7e267ca..64bfdf7 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -31,7 +31,7 @@ jobs: - name: Terraform fmt id: fmt - run: terraform fmt -check + run: terraform fmt - name: Terraform Init id: init From b9b96677b4702ffd9db0d3883716cb0ca7b0e450 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 04:56:12 -0300 Subject: [PATCH 036/103] testando runner novamente --- .github/workflows/apply-dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 64bfdf7..823f68e 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -35,11 +35,11 @@ jobs: - name: Terraform Init id: init - run: terraform init -backend=true -backend-config="config/dev/backend.hcl" + run: terraform init - name: Terraform Validate id: validate run: terraform validate -no-color - name: Terraform Apply - run: terraform apply -auto-approve -var-file="config/dev/terraform.tfvars" + run: terraform apply -auto-approve From e52cb2f9b744428c43ce61d87b8e25424aab23cf Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 05:00:51 -0300 Subject: [PATCH 037/103] destruindo ec2 --- .github/workflows/apply-dev.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 823f68e..4889c64 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -43,3 +43,6 @@ jobs: - name: Terraform Apply run: terraform apply -auto-approve + + - name: Terraform destruindo tudo + run: terraform destroy -auto-approve From db5acd482107892ac391300d5acabb98753b9329 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 17:43:38 -0300 Subject: [PATCH 038/103] sending destroy file --- .github/workflows/apply-dev.yml | 3 +- .github/workflows/destroy-apply.yml | 84 +++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/destroy-apply.yml diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 4889c64..3bdb91c 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -44,5 +44,4 @@ jobs: - name: Terraform Apply run: terraform apply -auto-approve - - name: Terraform destruindo tudo - run: terraform destroy -auto-approve + diff --git a/.github/workflows/destroy-apply.yml b/.github/workflows/destroy-apply.yml new file mode 100644 index 0000000..e2e0aba --- /dev/null +++ b/.github/workflows/destroy-apply.yml @@ -0,0 +1,84 @@ +name: Destroy terraform resources on the given folder + +on: + workflow_dispatch: + inputs: + dir: + description: 'Directory with resources to be destroyed' + required: true + default: 'terraform' + +env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + +jobs: + destroy-dev: + name: 'terraform destroy dev' + runs-on: ubuntu-latest + env: + TF_WORKING_DIR: ${{ github.event.inputs.dir }} + + defaults: + run: + shell: bash + working-directory: ${{ env.TF_WORKING_DIR }} + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Terraform + uses: hashicorp/setup-terraform@v1 + with: + terraform_version: 0.15.5 + + - name: Terraform fmt + id: fmt + run: terraform fmt -check + + - name: Terraform Init + id: init + run: terraform init + + - name: Terraform Validate + id: validate + run: terraform validate -no-color + + - name: Terraform Destroy + run: terraform destroy + + destroy-prod: + name: 'terraform destroy prod' + runs-on: ubuntu-latest + env: + TF_WORKING_DIR: ${{ github.event.inputs.dir }} + + defaults: + run: + shell: bash + working-directory: ${{ env.TF_WORKING_DIR }} + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Terraform + uses: hashicorp/setup-terraform@v1 + with: + terraform_version: 0.15.5 + + - name: Terraform fmt + id: fmt + run: terraform fmt -check + + - name: Terraform Init + id: init + run: terraform init + + - name: Terraform Validate + id: validate + run: terraform validate -no-color + + - name: Terraform Destroy + run: terraform destroy -auto-approve \ No newline at end of file From 8aba62bad43445587e23b2f004c8d058eb26cc36 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 17:50:03 -0300 Subject: [PATCH 039/103] sending destroy file1 --- .github/workflows/destroy-apply.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/destroy-apply.yml b/.github/workflows/destroy-apply.yml index e2e0aba..8005b27 100644 --- a/.github/workflows/destroy-apply.yml +++ b/.github/workflows/destroy-apply.yml @@ -68,10 +68,6 @@ jobs: with: terraform_version: 0.15.5 - - name: Terraform fmt - id: fmt - run: terraform fmt -check - - name: Terraform Init id: init run: terraform init From 886874f8cb2a13bc891143044f04fe5a68b5cdf1 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 17:53:51 -0300 Subject: [PATCH 040/103] sending destroy file2 --- .github/workflows/destroy-apply.yml | 37 +---------------------------- 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/.github/workflows/destroy-apply.yml b/.github/workflows/destroy-apply.yml index 8005b27..f903ab6 100644 --- a/.github/workflows/destroy-apply.yml +++ b/.github/workflows/destroy-apply.yml @@ -24,41 +24,6 @@ jobs: shell: bash working-directory: ${{ env.TF_WORKING_DIR }} - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup Terraform - uses: hashicorp/setup-terraform@v1 - with: - terraform_version: 0.15.5 - - - name: Terraform fmt - id: fmt - run: terraform fmt -check - - - name: Terraform Init - id: init - run: terraform init - - - name: Terraform Validate - id: validate - run: terraform validate -no-color - - - name: Terraform Destroy - run: terraform destroy - - destroy-prod: - name: 'terraform destroy prod' - runs-on: ubuntu-latest - env: - TF_WORKING_DIR: ${{ github.event.inputs.dir }} - - defaults: - run: - shell: bash - working-directory: ${{ env.TF_WORKING_DIR }} - steps: - name: Checkout uses: actions/checkout@v2 @@ -77,4 +42,4 @@ jobs: run: terraform validate -no-color - name: Terraform Destroy - run: terraform destroy -auto-approve \ No newline at end of file + run: terraform destroy \ No newline at end of file From e62ac2f1e697ede21b4f2ba9630f67722cf2ee75 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Thu, 9 Nov 2023 18:01:26 -0300 Subject: [PATCH 041/103] sending destroy file3 --- .github/workflows/destroy-apply.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/destroy-apply.yml b/.github/workflows/destroy-apply.yml index f903ab6..7896722 100644 --- a/.github/workflows/destroy-apply.yml +++ b/.github/workflows/destroy-apply.yml @@ -42,4 +42,4 @@ jobs: run: terraform validate -no-color - name: Terraform Destroy - run: terraform destroy \ No newline at end of file + run: terraform destroy -auto-approve \ No newline at end of file From 0340a5bc69d2d5ffc1cfef38d8b8250bb06babe5 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Sat, 11 Nov 2023 07:17:23 -0300 Subject: [PATCH 042/103] docker file --- Dockerfile | 15 +++++++++++++++ projeto-fsharp/restore.sh | 1 - 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..95d20c6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +WORKDIR /app + +COPY projeto-fsharp projeto-fsharp +RUN cd projeto-fsharp && ./restore.sh +RUN cd projeto-fsharp && dotnet fake run build.fsx -t "Build" + +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS final +WORKDIR /app + +COPY --from=build /app/projeto-fsharp/src/Server/out . + +EXPOSE 8085 + +ENTRYPOINT ["./Server"] \ No newline at end of file diff --git a/projeto-fsharp/restore.sh b/projeto-fsharp/restore.sh index a944206..9703ace 100755 --- a/projeto-fsharp/restore.sh +++ b/projeto-fsharp/restore.sh @@ -1,5 +1,4 @@ set -ex - dotnet tool restore dotnet paket install dotnet paket restore From ccf8f3259625712b3b464a92a93ba79e4e3f9a1a Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Sat, 11 Nov 2023 08:04:32 -0300 Subject: [PATCH 043/103] registry --- .github/workflows/push-registry-ghcr.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/push-registry-ghcr.yml diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml new file mode 100644 index 0000000..e3c661d --- /dev/null +++ b/.github/workflows/push-registry-ghcr.yml @@ -0,0 +1,15 @@ +name: Docker Image GHCR + +on: + workflow_dispatch + +jobs: + build_and_publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build and push the Image + run: + docker login --username richardneves --password ${{ secrets.GH_PAT }} ghcr.io + docker build . --tag ghcr.io/richardneves/projeto-fsharp:latest + docker push ghcr.io/richardneves:latest \ No newline at end of file From 6de43059ae7d40a372598f9eb11cb3355c6cef69 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Sat, 11 Nov 2023 08:09:05 -0300 Subject: [PATCH 044/103] testando actions --- .github/workflows/push-registry-ghcr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index e3c661d..e9a115a 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -11,5 +11,5 @@ jobs: - name: Build and push the Image run: docker login --username richardneves --password ${{ secrets.GH_PAT }} ghcr.io - docker build . --tag ghcr.io/richardneves/projeto-fsharp:latest + docker build . --tag ghcr.io/projeto-fsharp:latest docker push ghcr.io/richardneves:latest \ No newline at end of file From d2eb08da4db853b7b46d08a46dc24059bc06d71c Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Sat, 11 Nov 2023 08:23:46 -0300 Subject: [PATCH 045/103] test files --- .github/workflows/push-registry-ghcr.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index e9a115a..c5a888b 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -8,8 +8,14 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Build and push the Image - run: - docker login --username richardneves --password ${{ secrets.GH_PAT }} ghcr.io - docker build . --tag ghcr.io/projeto-fsharp:latest - docker push ghcr.io/richardneves:latest \ No newline at end of file + - name: Docker login + uses: docker/login-action@v2.1.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: $ {{secrets.GH_PAT}} + + # run: + # docker login --username richardneves --password ${{ secrets.GH_PAT }} ghcr.io + # docker build . --tag ghcr.io/richardneves/projeto-fsharp:latest + # docker push ghcr.io/richardneves:latest \ No newline at end of file From 72b6677e4915e35ae0e2ebb1e93ff0995245b931 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sat, 11 Nov 2023 08:42:59 -0300 Subject: [PATCH 046/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index c5a888b..bef3c8e 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -9,13 +9,12 @@ jobs: steps: - uses: actions/checkout@v3 - name: Docker login - uses: docker/login-action@v2.1.0 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: $ {{secrets.GH_PAT}} - - # run: - # docker login --username richardneves --password ${{ secrets.GH_PAT }} ghcr.io - # docker build . --tag ghcr.io/richardneves/projeto-fsharp:latest - # docker push ghcr.io/richardneves:latest \ No newline at end of file + # uses: docker/login-action@v2.1.0 + # with: + # registry: ghcr.io + # username: ${{ github.actor }} + # password: $ {{secrets.GH_PAT}} + run: + docker login ghcr.io -u richardneves -p $GH_PAT ghcr.io + docker build . --tag ghcr.io/richardneves/projeto-fsharp:latest + docker push ghcr.io/richardneves:latest From 7845ad1a77d7b09c8ca8e703f49564df1add7da5 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sat, 11 Nov 2023 08:51:08 -0300 Subject: [PATCH 047/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index bef3c8e..3a476db 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -16,5 +16,5 @@ jobs: # password: $ {{secrets.GH_PAT}} run: docker login ghcr.io -u richardneves -p $GH_PAT ghcr.io - docker build . --tag ghcr.io/richardneves/projeto-fsharp:latest - docker push ghcr.io/richardneves:latest + docker build . -t ghcr.io/richardneves/projeto-fsharp:latest + docker push ghcr.io/richardneves/projeto-fsharp:latest From bd6643a59c8f6df387638ccbc48dff070ac513ac Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sat, 11 Nov 2023 08:53:02 -0300 Subject: [PATCH 048/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index 3a476db..1d7ddaf 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -16,5 +16,5 @@ jobs: # password: $ {{secrets.GH_PAT}} run: docker login ghcr.io -u richardneves -p $GH_PAT ghcr.io - docker build . -t ghcr.io/richardneves/projeto-fsharp:latest + docker build . ghcr.io/richardneves/projeto-fsharp:latest docker push ghcr.io/richardneves/projeto-fsharp:latest From 46505b81850ce50ef851d8f942e824c55f77622f Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sat, 11 Nov 2023 08:54:57 -0300 Subject: [PATCH 049/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index 1d7ddaf..ba026ab 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -16,5 +16,4 @@ jobs: # password: $ {{secrets.GH_PAT}} run: docker login ghcr.io -u richardneves -p $GH_PAT ghcr.io - docker build . ghcr.io/richardneves/projeto-fsharp:latest - docker push ghcr.io/richardneves/projeto-fsharp:latest + From 692953ff9298f86b5a61c4e86cea1699face1dbd Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sat, 11 Nov 2023 08:57:30 -0300 Subject: [PATCH 050/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index ba026ab..2f5fa83 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -15,5 +15,7 @@ jobs: # username: ${{ github.actor }} # password: $ {{secrets.GH_PAT}} run: - docker login ghcr.io -u richardneves -p $GH_PAT ghcr.io + docker login ghcr.io -u richardneves --password-stdin ghcr.io + # docker build . --tag ghcr.io/richardneves/projeto-fsharp:latest + # docker push ghcr.io/richardneves/projeto-fsharp:latest From dae01d99e8dfc91f59cc9a59aabf8d8ba5d636cb Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sat, 11 Nov 2023 09:00:32 -0300 Subject: [PATCH 051/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index 2f5fa83..d0b4880 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -15,7 +15,7 @@ jobs: # username: ${{ github.actor }} # password: $ {{secrets.GH_PAT}} run: - docker login ghcr.io -u richardneves --password-stdin ghcr.io + docker login --username richardneves --password ${{secrets.GH_PAT}} ghcr.io # docker build . --tag ghcr.io/richardneves/projeto-fsharp:latest # docker push ghcr.io/richardneves/projeto-fsharp:latest From 3bd4ce8eb24a8fac2ab1895697e22197e126ddc7 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sat, 11 Nov 2023 09:02:21 -0300 Subject: [PATCH 052/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index d0b4880..4b02ea3 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -16,6 +16,6 @@ jobs: # password: $ {{secrets.GH_PAT}} run: docker login --username richardneves --password ${{secrets.GH_PAT}} ghcr.io - # docker build . --tag ghcr.io/richardneves/projeto-fsharp:latest + docker build . --tag ghcr.io/richardneves/projeto-fsharp:latest # docker push ghcr.io/richardneves/projeto-fsharp:latest From ea95ce4112fa2e69ce8af283ad686d042e3d868c Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sat, 11 Nov 2023 09:04:40 -0300 Subject: [PATCH 053/103] Update apply-dev.yml --- .github/workflows/apply-dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 3bdb91c..c8da9bd 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -1,8 +1,8 @@ name: Apply terraform resources on folder 0003-terraform-gha with dev config on: - push: - branches: [master] + # push: + # branches: [master] env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} From 4d84f55a885cec807de752b81b272b37bb0ee452 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sat, 11 Nov 2023 09:05:15 -0300 Subject: [PATCH 054/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index 4b02ea3..769641a 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -16,6 +16,6 @@ jobs: # password: $ {{secrets.GH_PAT}} run: docker login --username richardneves --password ${{secrets.GH_PAT}} ghcr.io - docker build . --tag ghcr.io/richardneves/projeto-fsharp:latest + docker build . -t ghcr.io/richardneves/projeto-fsharp:latest # docker push ghcr.io/richardneves/projeto-fsharp:latest From bb029a0beae6164f701ab577f3c494845a1a5620 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sat, 11 Nov 2023 15:15:13 -0300 Subject: [PATCH 055/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index 769641a..30c40a7 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -16,6 +16,6 @@ jobs: # password: $ {{secrets.GH_PAT}} run: docker login --username richardneves --password ${{secrets.GH_PAT}} ghcr.io - docker build . -t ghcr.io/richardneves/projeto-fsharp:latest + docker build -t ghcr.io/richardneves/projeto-fsharp:latest . # docker push ghcr.io/richardneves/projeto-fsharp:latest From 749b6f628731210aad3ac193d04e70cd73de90d9 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sat, 11 Nov 2023 15:17:46 -0300 Subject: [PATCH 056/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index 30c40a7..e3cacc1 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -16,6 +16,6 @@ jobs: # password: $ {{secrets.GH_PAT}} run: docker login --username richardneves --password ${{secrets.GH_PAT}} ghcr.io - docker build -t ghcr.io/richardneves/projeto-fsharp:latest . + docker build --tag ghcr.io/richardneves/projeto-fsharp:latest . # docker push ghcr.io/richardneves/projeto-fsharp:latest From 102f796e358526f7ec12312eaff64732396d8e12 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sat, 11 Nov 2023 15:24:53 -0300 Subject: [PATCH 057/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index e3cacc1..e664b30 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -16,6 +16,6 @@ jobs: # password: $ {{secrets.GH_PAT}} run: docker login --username richardneves --password ${{secrets.GH_PAT}} ghcr.io - docker build --tag ghcr.io/richardneves/projeto-fsharp:latest . + docker build -t hello_docker . # docker push ghcr.io/richardneves/projeto-fsharp:latest From ecd12fa4e22f88d732375f8c0e9a0f08b721cde9 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sat, 11 Nov 2023 15:29:35 -0300 Subject: [PATCH 058/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index e664b30..2cf1777 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -16,6 +16,6 @@ jobs: # password: $ {{secrets.GH_PAT}} run: docker login --username richardneves --password ${{secrets.GH_PAT}} ghcr.io - docker build -t hello_docker . + docker build --label "hello_docker" . # docker push ghcr.io/richardneves/projeto-fsharp:latest From 8a69864ba51908c26603197c1dc20a49189a5de7 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sat, 11 Nov 2023 15:30:53 -0300 Subject: [PATCH 059/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index 2cf1777..df90a0c 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -16,6 +16,6 @@ jobs: # password: $ {{secrets.GH_PAT}} run: docker login --username richardneves --password ${{secrets.GH_PAT}} ghcr.io - docker build --label "hello_docker" . + docker build --label "hello_docker" # docker push ghcr.io/richardneves/projeto-fsharp:latest From 8269b9a7b4003c41bf6f334cb6e2b45804e6675b Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sat, 11 Nov 2023 15:48:55 -0300 Subject: [PATCH 060/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 27 +++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index df90a0c..4bc8e33 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -8,14 +8,21 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Docker login - # uses: docker/login-action@v2.1.0 - # with: - # registry: ghcr.io - # username: ${{ github.actor }} - # password: $ {{secrets.GH_PAT}} - run: - docker login --username richardneves --password ${{secrets.GH_PAT}} ghcr.io - docker build --label "hello_docker" - # docker push ghcr.io/richardneves/projeto-fsharp:latest + # - name: Docker login + # # uses: docker/login-action@v2.1.0 + # # with: + # # registry: ghcr.io + # # username: ${{ github.actor }} + # # password: $ {{secrets.GH_PAT}} + # run: + # docker login --username richardneves --password ${{secrets.GH_PAT}} ghcr.io + # docker build --label "hello_docker" + # # docker push ghcr.io/richardneves/projeto-fsharp:latest + - name: GitHub Docker Action + uses: matootie/github-docker@v3.1.0 + with: + accessToken: ${{secrets.GH_PAT}} + tag: teste + + From 899151d3b325e94f66bd90310bfdcae415e2e443 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sat, 11 Nov 2023 16:13:25 -0300 Subject: [PATCH 061/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index 4bc8e33..87878e4 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -8,21 +8,14 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - # - name: Docker login - # # uses: docker/login-action@v2.1.0 - # # with: - # # registry: ghcr.io - # # username: ${{ github.actor }} - # # password: $ {{secrets.GH_PAT}} - # run: - # docker login --username richardneves --password ${{secrets.GH_PAT}} ghcr.io - # docker build --label "hello_docker" - # # docker push ghcr.io/richardneves/projeto-fsharp:latest - - name: GitHub Docker Action + - name: GitHub Docker registry uses: matootie/github-docker@v3.1.0 with: accessToken: ${{secrets.GH_PAT}} - tag: teste + tag: latest + tag_with_ref: true + tag_with_sha: true + From d994b9a52b2d15c978dd6477b1f869a1711874d1 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 04:59:31 -0300 Subject: [PATCH 062/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 38 ++++++++++++++++-------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index 87878e4..b4a950a 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -1,21 +1,33 @@ -name: Docker Image GHCR +name: build-and-publish-container-image -on: - workflow_dispatch +on: [workflow_dispatch] jobs: - build_and_publish: + build-and-publish-container-image: runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v3 - - name: GitHub Docker registry - uses: matootie/github-docker@v3.1.0 - with: - accessToken: ${{secrets.GH_PAT}} - tag: latest - tag_with_ref: true - tag_with_sha: true - + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Build and tag Docker image + run: | + short_commit=$(git rev-parse --short HEAD) + cd projeto-fsharp + docker build . -t ghcr.io/richardneves/projeto-fsharp:latest -t ghcr.io/richardneves/projeto-fsharp:${short_commit} + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GH_PAT }} + - name: Push Docker image + run: | + short_commit=$(git rev-parse --short HEAD) + docker push ghcr.io/richardneves/projeto-fsharp:${short_commit} + docker push ghcr.io/richardneves/projeto-fsharp:latest From d42f2975fb050b8a215fe3c3c6ffe00086146b49 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 05:13:00 -0300 Subject: [PATCH 063/103] Create Dockerfile --- projeto-fsharp/Dockerfile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 projeto-fsharp/Dockerfile diff --git a/projeto-fsharp/Dockerfile b/projeto-fsharp/Dockerfile new file mode 100644 index 0000000..8814235 --- /dev/null +++ b/projeto-fsharp/Dockerfile @@ -0,0 +1,15 @@ +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +WORKDIR /app + +COPY . . +RUN ./restore.sh + +RUN dotnet fake run build.fsx -t "Build" + +FROM mcr.microsoft.com/dotnet/sdk:6.0 +LABEL org.opencontainers.image.source="https://github.com/marublaize/Datapi-DevOps-Challenge" +WORKDIR /app + +COPY --from=build /app/src/Server/out . + +EXPOSE 8085 From a58c237537b54809e8315cbcc7d6f8d818274ac7 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 05:15:56 -0300 Subject: [PATCH 064/103] Update Dockerfile --- projeto-fsharp/Dockerfile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/projeto-fsharp/Dockerfile b/projeto-fsharp/Dockerfile index 8814235..77d118c 100644 --- a/projeto-fsharp/Dockerfile +++ b/projeto-fsharp/Dockerfile @@ -1,15 +1,15 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build -WORKDIR /app +# FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +# WORKDIR /app -COPY . . -RUN ./restore.sh +# COPY . . +# RUN ./restore.sh -RUN dotnet fake run build.fsx -t "Build" +# RUN dotnet fake run build.fsx -t "Build" -FROM mcr.microsoft.com/dotnet/sdk:6.0 -LABEL org.opencontainers.image.source="https://github.com/marublaize/Datapi-DevOps-Challenge" -WORKDIR /app +# FROM mcr.microsoft.com/dotnet/sdk:6.0 +# LABEL org.opencontainers.image.source="https://github.com/marublaize/Datapi-DevOps-Challenge" +# WORKDIR /app -COPY --from=build /app/src/Server/out . +# COPY --from=build /app/src/Server/out . -EXPOSE 8085 +# EXPOSE 8085 From f1a3843da770ac401302247fc4a5a1e90e52a95a Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 05:20:35 -0300 Subject: [PATCH 065/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index b4a950a..814bc8d 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -17,7 +17,7 @@ jobs: run: | short_commit=$(git rev-parse --short HEAD) cd projeto-fsharp - docker build . -t ghcr.io/richardneves/projeto-fsharp:latest -t ghcr.io/richardneves/projeto-fsharp:${short_commit} + docker build . -t ghcr.io/richardneves/projeto-fsharp1:latest -t ghcr.io/richardneves/projeto-fsharp1:${short_commit} - name: Login to GitHub Container Registry uses: docker/login-action@v1 @@ -29,5 +29,5 @@ jobs: - name: Push Docker image run: | short_commit=$(git rev-parse --short HEAD) - docker push ghcr.io/richardneves/projeto-fsharp:${short_commit} - docker push ghcr.io/richardneves/projeto-fsharp:latest + docker push ghcr.io/richardneves/projeto-fsharp1:${short_commit} + docker push ghcr.io/richardneves/projeto-fsharp1:latest From 14b2377a7c63ec5bac4888df3153d6ee0f787374 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 05:23:20 -0300 Subject: [PATCH 066/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index 814bc8d..225e854 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -15,9 +15,8 @@ jobs: - name: Build and tag Docker image run: | - short_commit=$(git rev-parse --short HEAD) cd projeto-fsharp - docker build . -t ghcr.io/richardneves/projeto-fsharp1:latest -t ghcr.io/richardneves/projeto-fsharp1:${short_commit} + docker build . -t ghcr.io/richardneves/projeto-fsharp1:latest -t ghcr.io/richardneves/projeto-fsharp1:latest - name: Login to GitHub Container Registry uses: docker/login-action@v1 @@ -28,6 +27,5 @@ jobs: - name: Push Docker image run: | - short_commit=$(git rev-parse --short HEAD) - docker push ghcr.io/richardneves/projeto-fsharp1:${short_commit} + docker push ghcr.io/richardneves/projeto-fsharp1:latest docker push ghcr.io/richardneves/projeto-fsharp1:latest From 3200557a03f001a94542648e3806560d6f18536f Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 05:24:34 -0300 Subject: [PATCH 067/103] Update Dockerfile --- projeto-fsharp/Dockerfile | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/projeto-fsharp/Dockerfile b/projeto-fsharp/Dockerfile index 77d118c..8b13789 100644 --- a/projeto-fsharp/Dockerfile +++ b/projeto-fsharp/Dockerfile @@ -1,15 +1 @@ -# FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build -# WORKDIR /app -# COPY . . -# RUN ./restore.sh - -# RUN dotnet fake run build.fsx -t "Build" - -# FROM mcr.microsoft.com/dotnet/sdk:6.0 -# LABEL org.opencontainers.image.source="https://github.com/marublaize/Datapi-DevOps-Challenge" -# WORKDIR /app - -# COPY --from=build /app/src/Server/out . - -# EXPOSE 8085 From abc79b96462f244a3085f011bfd05091ab80d9fd Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 05:26:03 -0300 Subject: [PATCH 068/103] Delete projeto-fsharp/Dockerfile --- projeto-fsharp/Dockerfile | 1 - 1 file changed, 1 deletion(-) delete mode 100644 projeto-fsharp/Dockerfile diff --git a/projeto-fsharp/Dockerfile b/projeto-fsharp/Dockerfile deleted file mode 100644 index 8b13789..0000000 --- a/projeto-fsharp/Dockerfile +++ /dev/null @@ -1 +0,0 @@ - From 513fd6539cd6edf909622bf1f77087eb6a4eac0f Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 05:28:28 -0300 Subject: [PATCH 069/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 39 ++++++++---------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index 225e854..a6dc5b7 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -1,31 +1,18 @@ -name: build-and-publish-container-image +name: Docker Image GHCR -on: [workflow_dispatch] +on: + workflow_dispatch jobs: - build-and-publish-container-image: + build_and_publish: runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Build and tag Docker image - run: | - cd projeto-fsharp - docker build . -t ghcr.io/richardneves/projeto-fsharp1:latest -t ghcr.io/richardneves/projeto-fsharp1:latest - - - name: Login to GitHub Container Registry - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GH_PAT }} - - - name: Push Docker image - run: | - docker push ghcr.io/richardneves/projeto-fsharp1:latest - docker push ghcr.io/richardneves/projeto-fsharp1:latest + - uses: actions/checkout@v3 + - name: GitHub Docker registry + uses: matootie/github-docker@v3.1.0 + with: + accessToken: ${{secrets.GH_PAT}} + tag: latest + tag_with_ref: true + tag_with_sha: true + From e01da0b6bc7150a9341362a4fc528337050536a6 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 05:32:38 -0300 Subject: [PATCH 070/103] Create Dockerfile 2 --- Dockerfile 2 | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Dockerfile 2 diff --git a/Dockerfile 2 b/Dockerfile 2 new file mode 100644 index 0000000..b4a950a --- /dev/null +++ b/Dockerfile 2 @@ -0,0 +1,33 @@ +name: build-and-publish-container-image + +on: [workflow_dispatch] + +jobs: + build-and-publish-container-image: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build and tag Docker image + run: | + short_commit=$(git rev-parse --short HEAD) + cd projeto-fsharp + docker build . -t ghcr.io/richardneves/projeto-fsharp:latest -t ghcr.io/richardneves/projeto-fsharp:${short_commit} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GH_PAT }} + + - name: Push Docker image + run: | + short_commit=$(git rev-parse --short HEAD) + docker push ghcr.io/richardneves/projeto-fsharp:${short_commit} + docker push ghcr.io/richardneves/projeto-fsharp:latest From a82f45a4672a28e2b530d0234c35e9cab5d95ed5 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 05:33:53 -0300 Subject: [PATCH 071/103] Update Dockerfile 2 --- Dockerfile 2 | 38 +++++++++++--------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/Dockerfile 2 b/Dockerfile 2 index b4a950a..737c8cc 100644 --- a/Dockerfile 2 +++ b/Dockerfile 2 @@ -1,33 +1,17 @@ -name: build-and-publish-container-image +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +WORKDIR /app -on: [workflow_dispatch] +COPY . . +RUN ./restore.sh -jobs: - build-and-publish-container-image: - runs-on: ubuntu-latest +RUN dotnet fake run build.fsx -t "Build" - steps: - - name: Checkout code - uses: actions/checkout@v2 +FROM mcr.microsoft.com/dotnet/sdk:6.0 +LABEL org.opencontainers.image.source="https://github.com/marublaize/Datapi-DevOps-Challenge" +WORKDIR /app - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 +COPY --from=build /app/src/Server/out . - - name: Build and tag Docker image - run: | - short_commit=$(git rev-parse --short HEAD) - cd projeto-fsharp - docker build . -t ghcr.io/richardneves/projeto-fsharp:latest -t ghcr.io/richardneves/projeto-fsharp:${short_commit} +EXPOSE 8085 - - name: Login to GitHub Container Registry - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GH_PAT }} - - - name: Push Docker image - run: | - short_commit=$(git rev-parse --short HEAD) - docker push ghcr.io/richardneves/projeto-fsharp:${short_commit} - docker push ghcr.io/richardneves/projeto-fsharp:latest +ENTRYPOINT ["./Server"] From 67f34fdc52f6a1a04e6a7f6c9e36f09268b0296c Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 05:36:17 -0300 Subject: [PATCH 072/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 37 +++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index a6dc5b7..5e1f960 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -15,4 +15,39 @@ jobs: tag: latest tag_with_ref: true tag_with_sha: true - + +# Dockerfile 2 + +# name: build-and-publish-container-image + +# on: [workflow_dispatch] + +# jobs: +# build-and-publish-container-image: +# runs-on: ubuntu-latest + +# steps: +# - name: Checkout code +# uses: actions/checkout@v2 + +# - name: Set up Docker Buildx +# uses: docker/setup-buildx-action@v1 + +# - name: Build and tag Docker image +# run: | +# short_commit=$(git rev-parse --short HEAD) +# cd projeto-fsharp +# docker build . -t ghcr.io/marublaize/projeto-fsharp:latest -t ghcr.io/marublaize/projeto-fsharp:${short_commit} + +# - name: Login to GitHub Container Registry +# uses: docker/login-action@v1 +# with: +# registry: ghcr.io +# username: ${{ github.actor }} +# password: ${{ secrets.CR_PAT }} + +# - name: Push Docker image +# run: | +# short_commit=$(git rev-parse --short HEAD) +# docker push ghcr.io/marublaize/projeto-fsharp:${short_commit} +# docker push ghcr.io/marublaize/projeto-fsharp:latest From 2f5dc0079d177971736b160f8ec8141aa706fc0b Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 05:36:58 -0300 Subject: [PATCH 073/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index 5e1f960..b95b6b4 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -37,7 +37,7 @@ jobs: # run: | # short_commit=$(git rev-parse --short HEAD) # cd projeto-fsharp -# docker build . -t ghcr.io/marublaize/projeto-fsharp:latest -t ghcr.io/marublaize/projeto-fsharp:${short_commit} +# docker build . -t ghcr.io/richard.neves/projeto-fsharp:latest -t ghcr.io/richardneves/projeto-fsharp:${short_commit} # - name: Login to GitHub Container Registry # uses: docker/login-action@v1 @@ -49,5 +49,5 @@ jobs: # - name: Push Docker image # run: | # short_commit=$(git rev-parse --short HEAD) -# docker push ghcr.io/marublaize/projeto-fsharp:${short_commit} -# docker push ghcr.io/marublaize/projeto-fsharp:latest +# docker push ghcr.io/richardneves/projeto-fsharp:${short_commit} +# docker push ghcr.io/richardneves/projeto-fsharp:latest From 66e574726e7542c93219d042048730364613101a Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 06:37:10 -0300 Subject: [PATCH 074/103] Update Dockerfile 2 --- Dockerfile 2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile 2 b/Dockerfile 2 index 737c8cc..1f086da 100644 --- a/Dockerfile 2 +++ b/Dockerfile 2 @@ -7,7 +7,7 @@ RUN ./restore.sh RUN dotnet fake run build.fsx -t "Build" FROM mcr.microsoft.com/dotnet/sdk:6.0 -LABEL org.opencontainers.image.source="https://github.com/marublaize/Datapi-DevOps-Challenge" +LABEL org.opencontainers.image.source="https://github.com/richardneves/Datapi-DevOps-Challenge" WORKDIR /app COPY --from=build /app/src/Server/out . From 066dd4a642881637374ac6185a3dae866948fd94 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 06:37:27 -0300 Subject: [PATCH 075/103] Update Dockerfile --- Dockerfile | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 95d20c6..c35e24b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,33 @@ +# FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +# WORKDIR /app + +# COPY projeto-fsharp projeto-fsharp +# RUN cd projeto-fsharp && ./restore.sh +# RUN cd projeto-fsharp && dotnet fake run build.fsx -t "Build" + +# FROM mcr.microsoft.com/dotnet/sdk:6.0 AS final +# WORKDIR /app + +# COPY --from=build /app/projeto-fsharp/src/Server/out . + +# EXPOSE 8085 + +# ENTRYPOINT ["./Server"] + FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /app -COPY projeto-fsharp projeto-fsharp -RUN cd projeto-fsharp && ./restore.sh -RUN cd projeto-fsharp && dotnet fake run build.fsx -t "Build" +COPY . . +RUN ./restore.sh + +RUN dotnet fake run build.fsx -t "Build" -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS final +FROM mcr.microsoft.com/dotnet/sdk:6.0 +LABEL org.opencontainers.image.source="https://github.com/richardneves/Datapi-DevOps-Challenge" WORKDIR /app -COPY --from=build /app/projeto-fsharp/src/Server/out . +COPY --from=build /app/src/Server/out . EXPOSE 8085 -ENTRYPOINT ["./Server"] \ No newline at end of file +ENTRYPOINT ["./Server"] From 647d36614e81b0fb8d5a528b8b1344f0c766752b Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 06:43:00 -0300 Subject: [PATCH 076/103] Update Dockerfile --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index c35e24b..c33f0b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,10 +17,10 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /app -COPY . . -RUN ./restore.sh +COPY projeto-fsharp projeto-fsharp +RUN cd projeto-fsharp && ./restore.sh -RUN dotnet fake run build.fsx -t "Build" +RUN cd projeto-fsharp && dotnet fake run build.fsx -t "Build" FROM mcr.microsoft.com/dotnet/sdk:6.0 LABEL org.opencontainers.image.source="https://github.com/richardneves/Datapi-DevOps-Challenge" From ac7912677d60d6e7947276bc57f3959052a76a9d Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 06:45:17 -0300 Subject: [PATCH 077/103] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c33f0b6..3bbb674 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,7 +26,7 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0 LABEL org.opencontainers.image.source="https://github.com/richardneves/Datapi-DevOps-Challenge" WORKDIR /app -COPY --from=build /app/src/Server/out . +COPY --from=build /app/projeto-fsharp/src/Server/out . EXPOSE 8085 From 98286a219f67255e05f7030edc2e85b392061de0 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 15:41:01 -0300 Subject: [PATCH 078/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 92 ++++++++++++------------ 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index b95b6b4..6a12bd9 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -1,53 +1,53 @@ -name: Docker Image GHCR +# name: Docker Image GHCR -on: - workflow_dispatch +# on: +# workflow_dispatch -jobs: - build_and_publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: GitHub Docker registry - uses: matootie/github-docker@v3.1.0 - with: - accessToken: ${{secrets.GH_PAT}} - tag: latest - tag_with_ref: true - tag_with_sha: true +# jobs: +# build_and_publish: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# - name: GitHub Docker registry +# uses: matootie/github-docker@v3.1.0 +# with: +# accessToken: ${{secrets.GH_PAT}} +# tag: latest +# tag_with_ref: true +# tag_with_sha: true -# Dockerfile 2 +# # Dockerfile 2 -# name: build-and-publish-container-image +name: build-and-publish-container-image -# on: [workflow_dispatch] +on: [workflow_dispatch] -# jobs: -# build-and-publish-container-image: -# runs-on: ubuntu-latest +jobs: + build-and-publish-container-image: + runs-on: ubuntu-latest -# steps: -# - name: Checkout code -# uses: actions/checkout@v2 - -# - name: Set up Docker Buildx -# uses: docker/setup-buildx-action@v1 - -# - name: Build and tag Docker image -# run: | -# short_commit=$(git rev-parse --short HEAD) -# cd projeto-fsharp -# docker build . -t ghcr.io/richard.neves/projeto-fsharp:latest -t ghcr.io/richardneves/projeto-fsharp:${short_commit} - -# - name: Login to GitHub Container Registry -# uses: docker/login-action@v1 -# with: -# registry: ghcr.io -# username: ${{ github.actor }} -# password: ${{ secrets.CR_PAT }} - -# - name: Push Docker image -# run: | -# short_commit=$(git rev-parse --short HEAD) -# docker push ghcr.io/richardneves/projeto-fsharp:${short_commit} -# docker push ghcr.io/richardneves/projeto-fsharp:latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build and tag Docker image + run: | + short_commit=$(git rev-parse --short HEAD) + cd projeto-fsharp + docker build . -t ghcr.io/richard.neves/projeto-fsharp:latest -t ghcr.io/richardneves/projeto-fsharp:${short_commit} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.CR_PAT }} + + - name: Push Docker image + run: | + short_commit=$(git rev-parse --short HEAD) + docker push ghcr.io/richardneves/projeto-fsharp:${short_commit} + docker push ghcr.io/richardneves/projeto-fsharp:latest From f0c3f082cac2c69bf93b565bb4191f584d5b7ace Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 15:43:25 -0300 Subject: [PATCH 079/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index 6a12bd9..beed10e 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -35,9 +35,8 @@ jobs: - name: Build and tag Docker image run: | - short_commit=$(git rev-parse --short HEAD) cd projeto-fsharp - docker build . -t ghcr.io/richard.neves/projeto-fsharp:latest -t ghcr.io/richardneves/projeto-fsharp:${short_commit} + docker build . -t ghcr.io/richard.neves/projeto-fsharp:latest -t ghcr.io/richardneves/projeto-fsharp:latest - name: Login to GitHub Container Registry uses: docker/login-action@v1 @@ -48,6 +47,4 @@ jobs: - name: Push Docker image run: | - short_commit=$(git rev-parse --short HEAD) - docker push ghcr.io/richardneves/projeto-fsharp:${short_commit} docker push ghcr.io/richardneves/projeto-fsharp:latest From b2b10ee76a1a5e0de41a4f9bd83242934edab413 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 16:00:14 -0300 Subject: [PATCH 080/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index beed10e..79cd43b 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -36,7 +36,7 @@ jobs: - name: Build and tag Docker image run: | cd projeto-fsharp - docker build . -t ghcr.io/richard.neves/projeto-fsharp:latest -t ghcr.io/richardneves/projeto-fsharp:latest + docker build ./. -t ghcr.io/richard.neves/projeto-fsharp:latest -t ghcr.io/richardneves/projeto-fsharp:latest - name: Login to GitHub Container Registry uses: docker/login-action@v1 From d37ec455459939a154376a1e8a0e5dbaf4ccac1f Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Sun, 12 Nov 2023 18:31:24 -0300 Subject: [PATCH 081/103] alterando dockerfile --- Dockerfile | 33 ----------------------- Dockerfile 2 => projeto-fsharp/Dockerfile | 10 +++---- 2 files changed, 5 insertions(+), 38 deletions(-) delete mode 100644 Dockerfile rename Dockerfile 2 => projeto-fsharp/Dockerfile (52%) diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 3bbb674..0000000 --- a/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -# FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build -# WORKDIR /app - -# COPY projeto-fsharp projeto-fsharp -# RUN cd projeto-fsharp && ./restore.sh -# RUN cd projeto-fsharp && dotnet fake run build.fsx -t "Build" - -# FROM mcr.microsoft.com/dotnet/sdk:6.0 AS final -# WORKDIR /app - -# COPY --from=build /app/projeto-fsharp/src/Server/out . - -# EXPOSE 8085 - -# ENTRYPOINT ["./Server"] - -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build -WORKDIR /app - -COPY projeto-fsharp projeto-fsharp -RUN cd projeto-fsharp && ./restore.sh - -RUN cd projeto-fsharp && dotnet fake run build.fsx -t "Build" - -FROM mcr.microsoft.com/dotnet/sdk:6.0 -LABEL org.opencontainers.image.source="https://github.com/richardneves/Datapi-DevOps-Challenge" -WORKDIR /app - -COPY --from=build /app/projeto-fsharp/src/Server/out . - -EXPOSE 8085 - -ENTRYPOINT ["./Server"] diff --git a/Dockerfile 2 b/projeto-fsharp/Dockerfile similarity index 52% rename from Dockerfile 2 rename to projeto-fsharp/Dockerfile index 1f086da..9653b2c 100644 --- a/Dockerfile 2 +++ b/projeto-fsharp/Dockerfile @@ -1,17 +1,17 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /app -COPY . . -RUN ./restore.sh +COPY . projeto-fsharp +RUN cd projeto-fsharp && ./restore.sh -RUN dotnet fake run build.fsx -t "Build" +RUN cd projeto-fsharp && dotnet fake run build.fsx -t "Build" FROM mcr.microsoft.com/dotnet/sdk:6.0 LABEL org.opencontainers.image.source="https://github.com/richardneves/Datapi-DevOps-Challenge" WORKDIR /app -COPY --from=build /app/src/Server/out . +COPY --from=build /app/projeto-fsharp/src/Server/out . EXPOSE 8085 -ENTRYPOINT ["./Server"] +ENTRYPOINT ["./Server"] \ No newline at end of file From 12ed4cbc1ac57f33ee46a9a3acc1f2cd0daa36c5 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Sun, 12 Nov 2023 18:33:59 -0300 Subject: [PATCH 082/103] alterando workflow --- .github/workflows/push-registry-ghcr.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index 79cd43b..3697d0a 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -35,8 +35,9 @@ jobs: - name: Build and tag Docker image run: | + short_commit=$(git rev-parse --short HEAD) cd projeto-fsharp - docker build ./. -t ghcr.io/richard.neves/projeto-fsharp:latest -t ghcr.io/richardneves/projeto-fsharp:latest + docker build . -t ghcr.io/marublaize/projeto-fsharp:latest -t ghcr.io/marublaize/projeto-fsharp:${short_commit} - name: Login to GitHub Container Registry uses: docker/login-action@v1 @@ -47,4 +48,6 @@ jobs: - name: Push Docker image run: | - docker push ghcr.io/richardneves/projeto-fsharp:latest + short_commit=$(git rev-parse --short HEAD) + docker push ghcr.io/marublaize/projeto-fsharp:${short_commit} + docker push ghcr.io/marublaize/projeto-fsharp:latest \ No newline at end of file From 3c85ce8abefca032edc9038be541817b2367f952 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 18:42:03 -0300 Subject: [PATCH 083/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index 3697d0a..a1c42ba 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -37,7 +37,7 @@ jobs: run: | short_commit=$(git rev-parse --short HEAD) cd projeto-fsharp - docker build . -t ghcr.io/marublaize/projeto-fsharp:latest -t ghcr.io/marublaize/projeto-fsharp:${short_commit} + docker build . -t ghcr.io/richardneves/projeto-fsharp:latest -t ghcr.io/richardneves/projeto-fsharp:${short_commit} - name: Login to GitHub Container Registry uses: docker/login-action@v1 @@ -50,4 +50,4 @@ jobs: run: | short_commit=$(git rev-parse --short HEAD) docker push ghcr.io/marublaize/projeto-fsharp:${short_commit} - docker push ghcr.io/marublaize/projeto-fsharp:latest \ No newline at end of file + docker push ghcr.io/marublaize/projeto-fsharp:latest From 1c010d96aafbf4447545864b7ce6e19067abc3a1 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 18:44:37 -0300 Subject: [PATCH 084/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index a1c42ba..02b6e02 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -44,7 +44,7 @@ jobs: with: registry: ghcr.io username: ${{ github.actor }} - password: ${{ secrets.CR_PAT }} + password: ${{ secrets.GH_PAT }} - name: Push Docker image run: | From cca5bfa685b5d1c93bf9c87a3c329083470aaed1 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 18:46:24 -0300 Subject: [PATCH 085/103] Update push-registry-ghcr.yml --- .github/workflows/push-registry-ghcr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push-registry-ghcr.yml b/.github/workflows/push-registry-ghcr.yml index 02b6e02..bcb3633 100644 --- a/.github/workflows/push-registry-ghcr.yml +++ b/.github/workflows/push-registry-ghcr.yml @@ -49,5 +49,5 @@ jobs: - name: Push Docker image run: | short_commit=$(git rev-parse --short HEAD) - docker push ghcr.io/marublaize/projeto-fsharp:${short_commit} - docker push ghcr.io/marublaize/projeto-fsharp:latest + docker push ghcr.io/richardneves/projeto-fsharp:${short_commit} + docker push ghcr.io/richardneves/projeto-fsharp:latest From d85258aa00c5b68cde6c2bfafa7beb43500fc079 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Sun, 12 Nov 2023 19:07:27 -0300 Subject: [PATCH 086/103] Update apply-dev.yml --- .github/workflows/apply-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index c8da9bd..0ebfd04 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -1,6 +1,6 @@ name: Apply terraform resources on folder 0003-terraform-gha with dev config -on: +on: [workflow_dispatch] # push: # branches: [master] From 4c7368a112a81697f63b299e7fcc5997d749cf2c Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Sun, 12 Nov 2023 19:24:54 -0300 Subject: [PATCH 087/103] alterando terraform --- terraform/.terraform.lock.hcl | 19 ++++++++ terraform/backend.tf | 8 ++++ terraform/main.tf | 89 +++++++++++++++++++++++++++++++++-- terraform/sg.tf | 77 ++++++++++++++++++++++++++++++ terraform/terraformando.sh | 56 ++++++++++++++++++++++ terraform/version.tf | 6 --- 6 files changed, 246 insertions(+), 9 deletions(-) create mode 100644 terraform/backend.tf create mode 100644 terraform/sg.tf create mode 100644 terraform/terraformando.sh diff --git a/terraform/.terraform.lock.hcl b/terraform/.terraform.lock.hcl index 54261ee..52db185 100644 --- a/terraform/.terraform.lock.hcl +++ b/terraform/.terraform.lock.hcl @@ -23,3 +23,22 @@ provider "registry.terraform.io/hashicorp/aws" { "zh:fc26f82eb289f1476a7486130e2c7e22416c40f77218a7b63c80d59a7ce0de3a", ] } + +provider "registry.terraform.io/hashicorp/kubernetes" { + version = "2.23.0" + hashes = [ + "h1:xyFc77aYkPoU4Xt1i5t0B1IaS8TbTtp9aCSuQKDayII=", + "zh:10488a12525ed674359585f83e3ee5e74818b5c98e033798351678b21b2f7d89", + "zh:1102ba5ca1a595f880e67102bbf999cc8b60203272a078a5b1e896d173f3f34b", + "zh:1347cf958ed3f3f80b3c7b3e23ddda3d6c6573a81847a8ee92b7df231c238bf6", + "zh:2cb18e9f5156bc1b1ee6bc580a709f7c2737d142722948f4a6c3c8efe757fa8d", + "zh:5506aa6f28dcca2a265ccf8e34478b5ec2cb43b867fe6d93b0158f01590fdadd", + "zh:6217a20686b631b1dcb448ee4bc795747ebc61b56fbe97a1ad51f375ebb0d996", + "zh:8accf916c00579c22806cb771e8909b349ffb7eb29d9c5468d0a3f3166c7a84a", + "zh:9379b0b54a0fa030b19c7b9356708ec8489e194c3b5e978df2d31368563308e5", + "zh:aa99c580890691036c2931841e88e7ee80d59ae52289c8c2c28ea0ac23e31520", + "zh:c57376d169875990ac68664d227fb69cd0037b92d0eba6921d757c3fd1879080", + "zh:e6068e3f94f6943b5586557b73f109debe19d1a75ca9273a681d22d1ce066579", + "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", + ] +} diff --git a/terraform/backend.tf b/terraform/backend.tf new file mode 100644 index 0000000..93775cd --- /dev/null +++ b/terraform/backend.tf @@ -0,0 +1,8 @@ +terraform { + backend "s3" { + bucket = "richardneves-tfstate" + key = "dev/tfstate-challenge" + region = "us-east-1" + encrypt = true + } +} \ No newline at end of file diff --git a/terraform/main.tf b/terraform/main.tf index c34c319..aa23f29 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -7,11 +7,94 @@ data "aws_ami" "ubuntu" { resource "aws_instance" "web" { ami = data.aws_ami.ubuntu.id instance_type = var.instance_type - - + security_groups = ["acesso_geral"] + user_data = file("terraformando.sh") tags = { Name = "${var.environment}: App" Env = var.environment Type = var.instance_type } -} \ No newline at end of file +} + +# provider "kubernetes" { +# config_path = "~/.kube/config" +# } + +# resource "kubernetes_deployment" "minha_aplicacao" { +# metadata { +# name = "minha-aplicacao" +# labels = { +# app = "minha-aplicacao" +# } +# } + +# spec { +# replicas = 3 + +# selector { +# match_labels = { +# app = "minha-aplicacao" +# } +# } + +# template { +# metadata { +# labels = { +# app = "minha-aplicacao" +# } +# } + +# spec { +# container { +# image = "SEU_REGISTRY/minha-aplicacao:latest" +# name = "minha-aplicacao" +# port { +# container_port = 80 +# } +# } +# } +# } +# } +# } + +# resource "kubernetes_service" "minha_aplicacao_service" { +# metadata { +# name = "minha-aplicacao-service" +# } + +# spec { +# selector = { +# app = "minha-aplicacao" +# } + +# port { +# protocol = "TCP" +# port = 80 +# target_port = 80 +# } +# } +# } + +# resource "kubernetes_ingress" "minha_aplicacao_ingress" { +# metadata { +# name = "minha-aplicacao-ingress" +# } + +# spec { +# rule { +# host = "meu-dominio.com" + +# http { +# path { +# path_type = "Prefix" +# path = "/" +# } + +# backend { +# service_name = kubernetes_service.minha_aplicacao_service.metadata[0].name +# service_port = kubernetes_service.minha_aplicacao_service.spec[0].port[0].port +# } +# } +# } +# } +# } \ No newline at end of file diff --git a/terraform/sg.tf b/terraform/sg.tf new file mode 100644 index 0000000..0952630 --- /dev/null +++ b/terraform/sg.tf @@ -0,0 +1,77 @@ +resource "aws_security_group" "acesso_geral" { + name = "acesso_geral" + // vpc_id = "vpc-0c1cb11038b243da9" + // security_group = [ "acesso_geral" ] + description = "grupo de dev" + + ingress { + cidr_blocks = ["0.0.0.0/0"] + ipv6_cidr_blocks = ["::/0"] + from_port = 22 + to_port = 22 + protocol = "tcp" + } + + egress { + cidr_blocks = ["0.0.0.0/0"] + ipv6_cidr_blocks = ["::/0"] + from_port = 22 + to_port = 22 + protocol = "tcp" + } + + ingress { + cidr_blocks = ["0.0.0.0/0"] + ipv6_cidr_blocks = ["::/0"] + from_port = 8080 + to_port = 8080 + protocol = "tcp" + } + + egress { + cidr_blocks = ["0.0.0.0/0"] + ipv6_cidr_blocks = ["::/0"] + from_port = 8080 + to_port = 8080 + protocol = "tcp" + } + + + ingress { + cidr_blocks = ["0.0.0.0/0"] + ipv6_cidr_blocks = ["::/0"] + from_port = 443 + to_port = 443 + protocol = "tcp" + } + + egress { + cidr_blocks = ["0.0.0.0/0"] + ipv6_cidr_blocks = ["::/0"] + from_port = 443 + to_port = 443 + protocol = "tcp" + } + + + ingress { + cidr_blocks = ["0.0.0.0/0"] + ipv6_cidr_blocks = ["::/0"] + from_port = 80 + to_port = 80 + protocol = "tcp" + } + + egress { + cidr_blocks = ["0.0.0.0/0"] + ipv6_cidr_blocks = ["::/0"] + from_port = 80 + to_port = 80 + protocol = "tcp" + } + + tags = { + Name = "Wordpress_Mysql" + } + +} diff --git a/terraform/terraformando.sh b/terraform/terraformando.sh new file mode 100644 index 0000000..cfbf9cc --- /dev/null +++ b/terraform/terraformando.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +# Atualizando pacotes do Amazon Linux +sudo yum install amazon-linux-extras install epel -y + +# Atualizando repositorio contendo Docker +sudo amazon-linux-extras install docker -y + +# Instalando Docker +sudo yum install docker -y + +# Iniciando serviço do Docker +sudo service docker start + +# Adicionando usuário ao grupo do Docker +sudo usermod -a -G docker ec2-user + +# Baixando e Instalando Docker Compose +sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose + +# Alterando Dono da pasta +sudo chown ec2-user /usr + +# Fornecendo permissão dentro da pasta para execução do Docker Compose +sudo chmod +x /usr/local/bin/docker-compose + +# Criando arquivo YAML com conteudo Multi Stage do Docker Compose +cat << eof > docker-compose.yaml +version: "3" +services: + wordpress: + container_name: my_wordpress + image: wordpress + ports: + - "8080:80" + links: + - mysql + environment: + WORDPRESS_DB_HOST: mysql + WORDPRESS_DB_USER: root + WORDPRESS_DB_PASSWORD: "12345" + WORDPRESS_DB_NAME: wordpress + mysql: + container_name: my_mysql + image: "mysql:5.7" + volumes: + - ./.mysql:/var/lib/mysql + environment: + MYSQL_DATABASE: wordpress + MYSQL_ROOT_PASSWORD: "12345" +eof + +# Subindo os containers do Docker Compose +docker-compose up -d + +# sudo docker run -d -p 8600:8080 pengbai/docker-supermario diff --git a/terraform/version.tf b/terraform/version.tf index 057952d..9d5cbcc 100644 --- a/terraform/version.tf +++ b/terraform/version.tf @@ -21,10 +21,4 @@ terraform { version = ">= 3.44.0" } } - - backend "s3" { - bucket = "richardneves-tfstate" - key = "dev/tfstate-challenge" - region = "us-east-1" -} } From 1346a8e25afb68706ae73dff617dd84d4654e7fc Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Sun, 12 Nov 2023 20:07:47 -0300 Subject: [PATCH 088/103] teste eks --- terraform/main.tf | 107 ++++++++++++++++++------------------- terraform/provider.tf | 3 ++ terraform/terraformando.sh | 55 ++----------------- 3 files changed, 60 insertions(+), 105 deletions(-) create mode 100644 terraform/provider.tf diff --git a/terraform/main.tf b/terraform/main.tf index aa23f29..c737bd5 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -5,75 +5,72 @@ data "aws_ami" "ubuntu" { } resource "aws_instance" "web" { - ami = data.aws_ami.ubuntu.id - instance_type = var.instance_type + ami = data.aws_ami.ubuntu.id + instance_type = var.instance_type security_groups = ["acesso_geral"] user_data = file("terraformando.sh") tags = { - Name = "${var.environment}: App" - Env = var.environment - Type = var.instance_type + Name = "${var.environment}: App" + Env = var.environment + Type = var.instance_type } } -# provider "kubernetes" { -# config_path = "~/.kube/config" -# } +resource "kubernetes_deployment" "projeto-fsharp" { + metadata { + name = "projeto-fsharp" + labels = { + app = "projeto-fsharp" + } + } -# resource "kubernetes_deployment" "minha_aplicacao" { -# metadata { -# name = "minha-aplicacao" -# labels = { -# app = "minha-aplicacao" -# } -# } + spec { + replicas = 1 -# spec { -# replicas = 3 + selector { + match_labels = { + app = "projeto-fsharp" + } + } -# selector { -# match_labels = { -# app = "minha-aplicacao" -# } -# } + template { + metadata { + labels = { + app = "projeto-fsharp" + } + } -# template { -# metadata { -# labels = { -# app = "minha-aplicacao" -# } -# } + spec { + container { + image = "ghcr.io/richardneves/datapi-devops-challenge/datapi-devops-challenge:latest" + name = "projeto-fsharp" + port { + container_port = 8085 + } + } + } + } + } +} -# spec { -# container { -# image = "SEU_REGISTRY/minha-aplicacao:latest" -# name = "minha-aplicacao" -# port { -# container_port = 80 -# } -# } -# } -# } -# } -# } -# resource "kubernetes_service" "minha_aplicacao_service" { -# metadata { -# name = "minha-aplicacao-service" -# } +resource "kubernetes_service" "projeto-fsharp" { + metadata { + name = "projeto-fsharp" + } -# spec { -# selector = { -# app = "minha-aplicacao" -# } + spec { + selector = { + app = "projeto-fsharp" + } -# port { -# protocol = "TCP" -# port = 80 -# target_port = 80 -# } -# } -# } + port { + protocol = "TCP" + port = 8085 + target_port = 8085 + } + } +} # resource "kubernetes_ingress" "minha_aplicacao_ingress" { # metadata { diff --git a/terraform/provider.tf b/terraform/provider.tf new file mode 100644 index 0000000..c4b7768 --- /dev/null +++ b/terraform/provider.tf @@ -0,0 +1,3 @@ +provider "kubernetes" { + config_path = "~/.kube/config" +} diff --git a/terraform/terraformando.sh b/terraform/terraformando.sh index cfbf9cc..5018c6d 100644 --- a/terraform/terraformando.sh +++ b/terraform/terraformando.sh @@ -1,56 +1,11 @@ #!/bin/bash -# Atualizando pacotes do Amazon Linux -sudo yum install amazon-linux-extras install epel -y +sudo apt-get update -y -# Atualizando repositorio contendo Docker -sudo amazon-linux-extras install docker -y +sudo apt-get upgrade -y -# Instalando Docker -sudo yum install docker -y +sudo curl -sfL https://get.k3s.io | sh - -# Iniciando serviço do Docker -sudo service docker start +sudo chmod 644 /etc/rancher/k3s/k3s.yaml -# Adicionando usuário ao grupo do Docker -sudo usermod -a -G docker ec2-user - -# Baixando e Instalando Docker Compose -sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose - -# Alterando Dono da pasta -sudo chown ec2-user /usr - -# Fornecendo permissão dentro da pasta para execução do Docker Compose -sudo chmod +x /usr/local/bin/docker-compose - -# Criando arquivo YAML com conteudo Multi Stage do Docker Compose -cat << eof > docker-compose.yaml -version: "3" -services: - wordpress: - container_name: my_wordpress - image: wordpress - ports: - - "8080:80" - links: - - mysql - environment: - WORDPRESS_DB_HOST: mysql - WORDPRESS_DB_USER: root - WORDPRESS_DB_PASSWORD: "12345" - WORDPRESS_DB_NAME: wordpress - mysql: - container_name: my_mysql - image: "mysql:5.7" - volumes: - - ./.mysql:/var/lib/mysql - environment: - MYSQL_DATABASE: wordpress - MYSQL_ROOT_PASSWORD: "12345" -eof - -# Subindo os containers do Docker Compose -docker-compose up -d - -# sudo docker run -d -p 8600:8080 pengbai/docker-supermario +sudo export KUBECONFIG=/etc/rancher/k3s/k3s.yaml \ No newline at end of file From 9a9bf0a5bb5297a9134b00780c403bfdef1b977c Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Sun, 12 Nov 2023 20:08:40 -0300 Subject: [PATCH 089/103] teste eks1 --- .github/workflows/apply-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 0ebfd04..ad9361b 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -1,4 +1,4 @@ -name: Apply terraform resources on folder 0003-terraform-gha with dev config +name: Apply terraform resources dev on: [workflow_dispatch] # push: From f20351fdf9e95144604c8e62337da918eae7147c Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Sun, 12 Nov 2023 20:15:33 -0300 Subject: [PATCH 090/103] teste k3s1 --- terraform/provider.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/provider.tf b/terraform/provider.tf index c4b7768..1c2da13 100644 --- a/terraform/provider.tf +++ b/terraform/provider.tf @@ -1,3 +1,3 @@ provider "kubernetes" { - config_path = "~/.kube/config" + config_path = "/etc/rancher/k3s/k3s.yaml" } From 983b3c82487355e6ed77d564f776365ebfb2f970 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Sun, 12 Nov 2023 21:02:56 -0300 Subject: [PATCH 091/103] teste k3s3 --- terraform/main.tf | 1 + terraform/provider.tf | 2 ++ 2 files changed, 3 insertions(+) diff --git a/terraform/main.tf b/terraform/main.tf index c737bd5..7f80dbe 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -19,6 +19,7 @@ resource "aws_instance" "web" { resource "kubernetes_deployment" "projeto-fsharp" { metadata { name = "projeto-fsharp" + namespace = "default" labels = { app = "projeto-fsharp" } diff --git a/terraform/provider.tf b/terraform/provider.tf index 1c2da13..9cbccda 100644 --- a/terraform/provider.tf +++ b/terraform/provider.tf @@ -1,3 +1,5 @@ provider "kubernetes" { + load_config_file = false config_path = "/etc/rancher/k3s/k3s.yaml" + } From 79fdd1ed066e43198418579f4a47a69c5f6ae91b Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Sun, 12 Nov 2023 21:15:07 -0300 Subject: [PATCH 092/103] teste k3s4 --- terraform/provider.tf | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/terraform/provider.tf b/terraform/provider.tf index 9cbccda..bc26b41 100644 --- a/terraform/provider.tf +++ b/terraform/provider.tf @@ -1,5 +1,4 @@ provider "kubernetes" { - load_config_file = false config_path = "/etc/rancher/k3s/k3s.yaml" - -} + config_context_cluster = "default" +} \ No newline at end of file From e18984bbcc423c7b243490bd37e5442370829563 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Sun, 12 Nov 2023 21:21:07 -0300 Subject: [PATCH 093/103] teste k3s4 --- terraform/main.tf | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/terraform/main.tf b/terraform/main.tf index 7f80dbe..1c0b39b 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -17,6 +17,10 @@ resource "aws_instance" "web" { } resource "kubernetes_deployment" "projeto-fsharp" { + depends_on = [ + aws_instance.web + ] + metadata { name = "projeto-fsharp" namespace = "default" @@ -56,6 +60,9 @@ resource "kubernetes_deployment" "projeto-fsharp" { resource "kubernetes_service" "projeto-fsharp" { + depends_on = [ + aws_instance.web + ] metadata { name = "projeto-fsharp" } From d8d6907551fb6312b431a674b8a4b58c5976d7cc Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Sun, 12 Nov 2023 21:39:58 -0300 Subject: [PATCH 094/103] teste k3s5 --- terraform/main.tf | 2 +- terraform/terraformando.sh | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index 1c0b39b..541df73 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -23,7 +23,7 @@ resource "kubernetes_deployment" "projeto-fsharp" { metadata { name = "projeto-fsharp" - namespace = "default" + namespace = "projeto-fsharp" labels = { app = "projeto-fsharp" } diff --git a/terraform/terraformando.sh b/terraform/terraformando.sh index 5018c6d..353bf82 100644 --- a/terraform/terraformando.sh +++ b/terraform/terraformando.sh @@ -8,4 +8,8 @@ sudo curl -sfL https://get.k3s.io | sh - sudo chmod 644 /etc/rancher/k3s/k3s.yaml -sudo export KUBECONFIG=/etc/rancher/k3s/k3s.yaml \ No newline at end of file +sudo export KUBECONFIG=/etc/rancher/k3s/k3s.yaml + +export KUBECONFIG=/etc/rancher/k3s/k3s.yaml +kubectl get pods --all-namespaces +helm ls --all-namespaces \ No newline at end of file From 01acee4588c669127695c4bc94a7c0ec3134fdff Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Sun, 12 Nov 2023 21:47:29 -0300 Subject: [PATCH 095/103] teste k3s6 --- terraform/main.tf | 146 +++++++++++++++++++++++----------------------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index 541df73..bb5aa49 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -16,90 +16,90 @@ resource "aws_instance" "web" { } } -resource "kubernetes_deployment" "projeto-fsharp" { - depends_on = [ - aws_instance.web - ] +# resource "kubernetes_deployment" "projeto-fsharp" { +# depends_on = [ +# aws_instance.web +# ] - metadata { - name = "projeto-fsharp" - namespace = "projeto-fsharp" - labels = { - app = "projeto-fsharp" - } - } - - spec { - replicas = 1 - - selector { - match_labels = { - app = "projeto-fsharp" - } - } - - template { - metadata { - labels = { - app = "projeto-fsharp" - } - } +# metadata { +# name = "projeto-fsharp" +# namespace = "projeto-fsharp" +# labels = { +# app = "projeto-fsharp" +# } +# } - spec { - container { - image = "ghcr.io/richardneves/datapi-devops-challenge/datapi-devops-challenge:latest" - name = "projeto-fsharp" - port { - container_port = 8085 - } - } - } - } - } -} +# spec { +# replicas = 1 +# selector { +# match_labels = { +# app = "projeto-fsharp" +# } +# } -resource "kubernetes_service" "projeto-fsharp" { - depends_on = [ - aws_instance.web - ] - metadata { - name = "projeto-fsharp" - } +# template { +# metadata { +# labels = { +# app = "projeto-fsharp" +# } +# } - spec { - selector = { - app = "projeto-fsharp" - } +# spec { +# container { +# image = "ghcr.io/richardneves/datapi-devops-challenge/datapi-devops-challenge:latest" +# name = "projeto-fsharp" +# port { +# container_port = 8085 +# } +# } +# } +# } +# } +# } - port { - protocol = "TCP" - port = 8085 - target_port = 8085 - } - } -} -# resource "kubernetes_ingress" "minha_aplicacao_ingress" { +# resource "kubernetes_service" "projeto-fsharp" { +# depends_on = [ +# aws_instance.web +# ] # metadata { -# name = "minha-aplicacao-ingress" +# name = "projeto-fsharp" # } # spec { -# rule { -# host = "meu-dominio.com" - -# http { -# path { -# path_type = "Prefix" -# path = "/" -# } +# selector = { +# app = "projeto-fsharp" +# } -# backend { -# service_name = kubernetes_service.minha_aplicacao_service.metadata[0].name -# service_port = kubernetes_service.minha_aplicacao_service.spec[0].port[0].port -# } -# } +# port { +# protocol = "TCP" +# port = 8085 +# target_port = 8085 # } # } -# } \ No newline at end of file +# } + +# # resource "kubernetes_ingress" "minha_aplicacao_ingress" { +# # metadata { +# # name = "minha-aplicacao-ingress" +# # } + +# # spec { +# # rule { +# # host = "meu-dominio.com" + +# # http { +# # path { +# # path_type = "Prefix" +# # path = "/" +# # } + +# # backend { +# # service_name = kubernetes_service.minha_aplicacao_service.metadata[0].name +# # service_port = kubernetes_service.minha_aplicacao_service.spec[0].port[0].port +# # } +# # } +# # } +# # } +# # } \ No newline at end of file From c3a94c427886861bdbfe59097dea4f39e086a0f8 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Sun, 12 Nov 2023 21:55:47 -0300 Subject: [PATCH 096/103] teste1 --- terraform/main.tf | 146 +++++++++++++++++++++++----------------------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index bb5aa49..541df73 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -16,90 +16,90 @@ resource "aws_instance" "web" { } } -# resource "kubernetes_deployment" "projeto-fsharp" { -# depends_on = [ -# aws_instance.web -# ] +resource "kubernetes_deployment" "projeto-fsharp" { + depends_on = [ + aws_instance.web + ] -# metadata { -# name = "projeto-fsharp" -# namespace = "projeto-fsharp" -# labels = { -# app = "projeto-fsharp" -# } -# } + metadata { + name = "projeto-fsharp" + namespace = "projeto-fsharp" + labels = { + app = "projeto-fsharp" + } + } -# spec { -# replicas = 1 + spec { + replicas = 1 -# selector { -# match_labels = { -# app = "projeto-fsharp" -# } -# } + selector { + match_labels = { + app = "projeto-fsharp" + } + } -# template { -# metadata { -# labels = { -# app = "projeto-fsharp" -# } -# } + template { + metadata { + labels = { + app = "projeto-fsharp" + } + } -# spec { -# container { -# image = "ghcr.io/richardneves/datapi-devops-challenge/datapi-devops-challenge:latest" -# name = "projeto-fsharp" -# port { -# container_port = 8085 -# } -# } -# } -# } -# } -# } + spec { + container { + image = "ghcr.io/richardneves/datapi-devops-challenge/datapi-devops-challenge:latest" + name = "projeto-fsharp" + port { + container_port = 8085 + } + } + } + } + } +} -# resource "kubernetes_service" "projeto-fsharp" { -# depends_on = [ -# aws_instance.web -# ] +resource "kubernetes_service" "projeto-fsharp" { + depends_on = [ + aws_instance.web + ] + metadata { + name = "projeto-fsharp" + } + + spec { + selector = { + app = "projeto-fsharp" + } + + port { + protocol = "TCP" + port = 8085 + target_port = 8085 + } + } +} + +# resource "kubernetes_ingress" "minha_aplicacao_ingress" { # metadata { -# name = "projeto-fsharp" +# name = "minha-aplicacao-ingress" # } # spec { -# selector = { -# app = "projeto-fsharp" -# } +# rule { +# host = "meu-dominio.com" -# port { -# protocol = "TCP" -# port = 8085 -# target_port = 8085 +# http { +# path { +# path_type = "Prefix" +# path = "/" +# } + +# backend { +# service_name = kubernetes_service.minha_aplicacao_service.metadata[0].name +# service_port = kubernetes_service.minha_aplicacao_service.spec[0].port[0].port +# } +# } # } # } -# } - -# # resource "kubernetes_ingress" "minha_aplicacao_ingress" { -# # metadata { -# # name = "minha-aplicacao-ingress" -# # } - -# # spec { -# # rule { -# # host = "meu-dominio.com" - -# # http { -# # path { -# # path_type = "Prefix" -# # path = "/" -# # } - -# # backend { -# # service_name = kubernetes_service.minha_aplicacao_service.metadata[0].name -# # service_port = kubernetes_service.minha_aplicacao_service.spec[0].port[0].port -# # } -# # } -# # } -# # } -# # } \ No newline at end of file +# } \ No newline at end of file From 3fbff85274ff36f74a7aba4b0e08543c886c0834 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Mon, 13 Nov 2023 03:22:54 -0300 Subject: [PATCH 097/103] teste k3s --- terraform/.terraform.lock.hcl | 51 +++++++---- terraform/main.tf | 162 +++++++++++++++++++--------------- terraform/terraformando.sh | 56 +++++++++++- 3 files changed, 182 insertions(+), 87 deletions(-) diff --git a/terraform/.terraform.lock.hcl b/terraform/.terraform.lock.hcl index 52db185..09aa56f 100644 --- a/terraform/.terraform.lock.hcl +++ b/terraform/.terraform.lock.hcl @@ -2,25 +2,25 @@ # Manual edits may be lost in future updates. provider "registry.terraform.io/hashicorp/aws" { - version = "5.24.0" + version = "5.25.0" constraints = ">= 3.44.0" hashes = [ - "h1:5kF6+4jUPI73O/uDvm/8/NiKRhiaOqMTqdo5l8uAygo=", - "zh:164b4ac71c9fc6b991021dd6e829591b0c1a0ebfb5831da0a7eb4f10f92c76a7", - "zh:22e85772a1767498796f160b54a156db8173c4e238469dad8328a65093e033e1", - "zh:2655853a6e716a551190bed0ad083e2bdc8a6e9d21e9724bea3c4a97c5985bd8", - "zh:292bf6c084e23b0189d633600cde08eb61ff916e7083f9288c44daec6e566513", - "zh:2ff0f1c78a17cf11010a8beba338b9f72f3148fc37d349faa6278e523877886d", - "zh:643d3a464826b10d746cafea97739a69462c5982ac2dd31001cb798af3548a2e", - "zh:6fcaf09ebc03bc7aeb7340494dc3a75983875d309a93bf1f421774a10c65e994", - "zh:77a2f9b3f89c0a9d6c72be0724d1635cb9cbc69058e60e4bc78fe4091cc2f9a4", - "zh:7a9258d51b2b4437e8dda188a522ceff0df128cb1840713b0453f5d4fe35b452", - "zh:9231fbc0d27e7bdd214f55f05ad85af9d44a0b36a06a4e2747d7c634b2f443bb", + "h1:u1MptxxzcfkA4N0AXGdkyKzjRZK+ssnNmldl5kCNwSM=", + "zh:163244f73f13b013d9a6a267731df5971d03a3cdcdefb6d280dcbb39e482d76b", + "zh:179debe1fcfff552589c949e068ff7cae5f4be6b00b48f20933029795210f4c1", + "zh:1c66da7cd54614c57d3f7fa0f5f2b51864358250d360cdb6c403f4248ab15fd4", + "zh:360cdc430c4e79a7b9b791832460e9caccafd9dd1d9bb9a95293aaebce5d506c", + "zh:40eb5dd1e678528fb881b448624c68f10f1878bfbbf4160c829bb2255f8ae159", + "zh:76a30a8a5cc9132202929c4ec5dd4f1ac4089af73a0d417a965cd23801e69526", + "zh:7fbd7796e787635640ba5b489b6b1cd9294156e7f222f70f0b9672d0302bbf67", + "zh:8408832a7540e758397e55dba2134b7428b7318d515f7226dd548231bc61e3df", + "zh:97db8d60e240701b7010eff29e3d44360856b7f3e72a217d1a57d6315bbb8e08", "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", - "zh:a805f3caefb98d007958f900e1f55e6fbd0849df3d99cafd96a0c5898170c153", - "zh:aa034c4cefacae133027ec3ebd80b43856fe67b9617a8c854e2a95a637d99023", - "zh:ef0f5bb925e77f1f32210458a372523edc73c70a4cce1c25e39f4498f5b50aa7", - "zh:fc26f82eb289f1476a7486130e2c7e22416c40f77218a7b63c80d59a7ce0de3a", + "zh:9f9c7b9203ac445b65ca8f3cfa176d9e86dc5572ce925490d7fabb04ebf4f829", + "zh:ca5c18799ab858a1addcbfb10cf227e013eb12c110b7d750c969fc8711ff578b", + "zh:cdd503da9f461ad5bc119cb3003be85b3752457b552f41ed20315e1239e3084a", + "zh:f8aaad1544823803dfd03e22ed260e706524baf5509cb1c4cf2be9d982c0fa6c", + "zh:ff283a7aaf509b3a9ba17a2efbc2faccbc69d84e913b23f2434dd5102becac3c", ] } @@ -42,3 +42,22 @@ provider "registry.terraform.io/hashicorp/kubernetes" { "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", ] } + +provider "registry.terraform.io/hashicorp/null" { + version = "3.2.1" + hashes = [ + "h1:FbGfc+muBsC17Ohy5g806iuI1hQc4SIexpYCrQHQd8w=", + "zh:58ed64389620cc7b82f01332e27723856422820cfd302e304b5f6c3436fb9840", + "zh:62a5cc82c3b2ddef7ef3a6f2fedb7b9b3deff4ab7b414938b08e51d6e8be87cb", + "zh:63cff4de03af983175a7e37e52d4bd89d990be256b16b5c7f919aff5ad485aa5", + "zh:74cb22c6700e48486b7cabefa10b33b801dfcab56f1a6ac9b6624531f3d36ea3", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:79e553aff77f1cfa9012a2218b8238dd672ea5e1b2924775ac9ac24d2a75c238", + "zh:a1e06ddda0b5ac48f7e7c7d59e1ab5a4073bbcf876c73c0299e4610ed53859dc", + "zh:c37a97090f1a82222925d45d84483b2aa702ef7ab66532af6cbcfb567818b970", + "zh:e4453fbebf90c53ca3323a92e7ca0f9961427d2f0ce0d2b65523cc04d5d999c2", + "zh:e80a746921946d8b6761e77305b752ad188da60688cfd2059322875d363be5f5", + "zh:fbdb892d9822ed0e4cb60f2fedbdbb556e4da0d88d3b942ae963ed6ff091e48f", + "zh:fca01a623d90d0cad0843102f9b8b9fe0d3ff8244593bd817f126582b52dd694", + ] +} diff --git a/terraform/main.tf b/terraform/main.tf index 541df73..b987a45 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -16,90 +16,112 @@ resource "aws_instance" "web" { } } -resource "kubernetes_deployment" "projeto-fsharp" { - depends_on = [ - aws_instance.web - ] - - metadata { - name = "projeto-fsharp" - namespace = "projeto-fsharp" - labels = { - app = "projeto-fsharp" - } - } - spec { - replicas = 1 - - selector { - match_labels = { - app = "projeto-fsharp" - } - } - - template { - metadata { - labels = { - app = "projeto-fsharp" - } - } - - spec { - container { - image = "ghcr.io/richardneves/datapi-devops-challenge/datapi-devops-challenge:latest" - name = "projeto-fsharp" - port { - container_port = 8085 - } - } - } - } - } -} +# resource "null_resource" "teste-namespace" { +# provisioner "local-exec" { +# command = "sudo ./deploy.sh" +# } +# } +# resource "kubernetes_namespace" "create-namespace" { +# metadata { +# annotations = { +# name = "example-annotation" +# } -resource "kubernetes_service" "projeto-fsharp" { - depends_on = [ - aws_instance.web - ] - metadata { - name = "projeto-fsharp" - } +# labels = { +# mylabel = "label-value" +# } + +# name = "teste" +# } +# } - spec { - selector = { - app = "projeto-fsharp" - } - port { - protocol = "TCP" - port = 8085 - target_port = 8085 - } - } -} -# resource "kubernetes_ingress" "minha_aplicacao_ingress" { +# resource "kubernetes_deployment" "deployment-projeto-fsharp" { +# depends_on = [ +# aws_instance.web +# ] + # metadata { -# name = "minha-aplicacao-ingress" +# name = "projeto-fsharp" +# labels = { +# app = "projeto-fsharp" +# } # } # spec { -# rule { -# host = "meu-dominio.com" +# replicas = 1 -# http { -# path { -# path_type = "Prefix" -# path = "/" +# selector { +# match_labels = { +# app = "projeto-fsharp" +# } +# } + +# template { +# metadata { +# labels = { +# app = "projeto-fsharp" # } +# } -# backend { -# service_name = kubernetes_service.minha_aplicacao_service.metadata[0].name -# service_port = kubernetes_service.minha_aplicacao_service.spec[0].port[0].port +# spec { +# container { +# image = "ghcr.io/richardneves/datapi-devops-challenge/datapi-devops-challenge:latest" +# name = "projeto-fsharp" +# port { +# container_port = 8085 +# } # } # } # } # } -# } \ No newline at end of file +# } + + +# resource "kubernetes_service" "service-projeto-fsharp" { +# depends_on = [ +# aws_instance.web +# ] +# metadata { +# name = "projeto-fsharp" +# } + +# spec { +# selector = { +# app = "projeto-fsharp" +# } + +# port { +# protocol = "TCP" +# port = 8085 +# target_port = 8085 +# } +# } +# } + +# # resource "kubernetes_ingress" "minha_aplicacao_ingress" { +# # metadata { +# # name = "minha-aplicacao-ingress" +# # } + +# # spec { +# # rule { +# # host = "meu-dominio.com" + +# # http { +# # path { +# # path_type = "Prefix" +# # path = "/" +# # } + +# # backend { +# # service_name = kubernetes_service.minha_aplicacao_service.metadata[0].name +# # service_port = kubernetes_service.minha_aplicacao_service.spec[0].port[0].port +# # } +# # } +# # } +# # } +# # } \ No newline at end of file diff --git a/terraform/terraformando.sh b/terraform/terraformando.sh index 353bf82..bdfc102 100644 --- a/terraform/terraformando.sh +++ b/terraform/terraformando.sh @@ -12,4 +12,58 @@ sudo export KUBECONFIG=/etc/rancher/k3s/k3s.yaml export KUBECONFIG=/etc/rancher/k3s/k3s.yaml kubectl get pods --all-namespaces -helm ls --all-namespaces \ No newline at end of file +helm ls --all-namespaces + +cat << eof > deployment.yaml +apiVersion: v1 +kind: Namespace +metadata: + name: projeto-fsharp + +--- +apiVersion: v1 +kind: Service +metadata: + name: projeto-fsharp + namespace: projeto-fsharp +spec: + type: NodePort + ports: + - port: 8085 + targetPort: 8085 + nodePort: 30085 + selector: + app: projeto-fsharp + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: projeto-fsharp + namespace: projeto-fsharp +spec: + replicas: 1 + selector: + matchLabels: + app: projeto-fsharp + template: + metadata: + labels: + app: projeto-fsharp + spec: + containers: + - name: projeto-fsharp + image: ghcr.io/richardneves/datapi-devops-challenge/datapi-devops-challenge:latest + ports: + - containerPort: 8085 + resources: + requests: + memory: "256Mi" + cpu: "0.25" + limits: + memory: "512Mi" + cpu: "0.5" + imagePullPolicy: Always +eof + +k3s kubectl apply -f deployment.yaml \ No newline at end of file From e328f41076564d6b1f0515171408df9eb9816d76 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Mon, 13 Nov 2023 04:05:52 -0300 Subject: [PATCH 098/103] teste k3s2 --- README.md | 37 ++++++------- terraform/devAuto.tfvars | 7 +++ terraform/main.tf | 112 +-------------------------------------- terraform/provider.tf | 4 -- terraform/sg.tf | 4 +- terraform/variables.tf | 8 +-- terraform/version.tf | 2 - 7 files changed, 29 insertions(+), 145 deletions(-) create mode 100644 terraform/devAuto.tfvars delete mode 100644 terraform/provider.tf diff --git a/README.md b/README.md index 9e2060e..0e81a48 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,25 @@ # Datapi DevOps Challenge -Para melhor entendermos o seu nível técnico, nós preparamos este desafio como parte do nosso processo de contratação. Por isso, tenha em mente que não é necessário cumprir com todos os pontos mencionados, nem cumpri-los em uma ordem específica. +Documentação do projeto -O importante é entregar o que você conseguir fazer, com a devida documentação. +# Instanciação de Maquina Virtual EC2 AWS: -# Desafios +Foi escolhida a cloud AWS para realização do projeto e Deploy por questão de familiaridade. Porém não afeta no funcionamento do projeto. -Segue abaixo uma lista de desafios abrangendo várias áreas de responsabilidade para um DevOps no time do Datapi. Nossa sugestão é tentar seguir cada item na ordem apresentada, porém você está livre para atuar nos pontos que quiser e tiver mais familiaridade. +Onde é utilizado pelo arquivo apply-dev.yml para deploy na AWS. Utilizando Steps e jobs basicos para entrega da maquina EC2 na AWS -- Instanciar uma VM numa cloud provider. Recomendação: Microsoft Azure. - - Criar a configuração dessa VM usando uma ferramenta de IaC (Infrastructure as Code). Recomendação: Terraform. - - Criar um job de CI (Continuous Integration) para aplicar a configuração da ferramenta de provisionamento. Recomendação: GitHub Actions. -- Adicionar um Dockerfile à aplicação disponibilizada na pasta `projeto-fsharp/` para containerizar o mesmo. Note que foi utilizada a linguagem F# (.NET) para escrever a aplicação. Para facilitar o entendimento do projeto, adicionamos um README.md com instruções de teste e uso do mesmo localmente. Você deverá ser capaz de traduzir essas instruções para a criação do Dockerfile. - - Criar um job de CI para enviar a imagem gerada para um Docker Registry. Recomendação: GitHub Container Registry. -- Criar os manifestos YAML para hospedar a aplicação usando Kubernetes. Nesse ponto os testes podem ser realizados apenas localmente, porém devem ser apresentados os arquivos YAML criados. - * Utilizar IaC para configurar o Kubernetes. Recomendação: Terraform. - * Configurar a hospedagem a partir do registry gerado na tarefa anterior. - * Caso possua mais familiaridade, sinta-se motivado a customizar mais as configurações (secrets, ingress, etc.). -- Adicionar um README ao projeto detalhando o processo e justificando as decisões tomadas. Recomendação: Markdown. Todos os refinamentos adicionados nos tópicos mencionados anteriormente, e demais ideias que possam melhorar o projeto serão considerados na avaliação da solução. +# Dockerfile: -Faça um fork e envie um PR com a sua solução, o tempo de entrega é de no máximo 4 dias e será contabilizado a partir da data do fork. +Foi realizado a construção do Docker file MultiStage onde em primeiro momento é possível baixar a imagem da Microsoft com a versão 6.0 do SDK para o bom teste e funcionamento do projeto, realizar copia dos arquivos e pastas principais para aplicação do restore.sh e criação do build. +Na segunda etapa de build é possível realizar a copia do build e armazenar em uma pasta especifica onde será utiliza o resultado do build a exposição da porta e utilização do arquivo ./Server em ENTRYPOINT inicialização em tempo de execução do container. -## Será avaliado: +O DockerFile é utilizado pelo arquivo de esteira na pasta .github/workflows push-registry-ghcr.yml onde existe um job basico de conexão, build e push da imagem para o registry do github onde é possível localizar em packages do repositorio. -- % do que foi entregue em relação ao que foi pedido. -- Qualidade dos aquivos Terraform. -- Boas práticas de infra e uso do Kubernetes. -- Corretude das tarefas. -- Uso eficiente em relação ao custo de máquina. +# Arquivos Terraform + +Arquivos básicos onde fazem a construção da EC2 na AWS e em paralelo também fazem a criação do K3S dentro da EC2 da AWS que é uma opção escolhida ao kubernetes pela praticidade em sua configuração. E é realizado o deploy da aplicação via manifesto com shell script. + + +# Destroy terraform + +Existe um arquivo onde é executado manualmente de destroy-apply.yml onde é possível destruir toda configuração realizado pelo terraform. \ No newline at end of file diff --git a/terraform/devAuto.tfvars b/terraform/devAuto.tfvars new file mode 100644 index 0000000..493ce1d --- /dev/null +++ b/terraform/devAuto.tfvars @@ -0,0 +1,7 @@ +instance_type = "t2.micro" + +environment = "dev" + +aws_profile = "default" + +aws_region = "us-east-1" \ No newline at end of file diff --git a/terraform/main.tf b/terraform/main.tf index b987a45..35fc209 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -14,114 +14,4 @@ resource "aws_instance" "web" { Env = var.environment Type = var.instance_type } -} - - -# resource "null_resource" "teste-namespace" { -# provisioner "local-exec" { -# command = "sudo ./deploy.sh" -# } -# } - -# resource "kubernetes_namespace" "create-namespace" { -# metadata { -# annotations = { -# name = "example-annotation" -# } - -# labels = { -# mylabel = "label-value" -# } - -# name = "teste" -# } -# } - - - -# resource "kubernetes_deployment" "deployment-projeto-fsharp" { -# depends_on = [ -# aws_instance.web -# ] - -# metadata { -# name = "projeto-fsharp" -# labels = { -# app = "projeto-fsharp" -# } -# } - -# spec { -# replicas = 1 - -# selector { -# match_labels = { -# app = "projeto-fsharp" -# } -# } - -# template { -# metadata { -# labels = { -# app = "projeto-fsharp" -# } -# } - -# spec { -# container { -# image = "ghcr.io/richardneves/datapi-devops-challenge/datapi-devops-challenge:latest" -# name = "projeto-fsharp" -# port { -# container_port = 8085 -# } -# } -# } -# } -# } -# } - - -# resource "kubernetes_service" "service-projeto-fsharp" { -# depends_on = [ -# aws_instance.web -# ] -# metadata { -# name = "projeto-fsharp" -# } - -# spec { -# selector = { -# app = "projeto-fsharp" -# } - -# port { -# protocol = "TCP" -# port = 8085 -# target_port = 8085 -# } -# } -# } - -# # resource "kubernetes_ingress" "minha_aplicacao_ingress" { -# # metadata { -# # name = "minha-aplicacao-ingress" -# # } - -# # spec { -# # rule { -# # host = "meu-dominio.com" - -# # http { -# # path { -# # path_type = "Prefix" -# # path = "/" -# # } - -# # backend { -# # service_name = kubernetes_service.minha_aplicacao_service.metadata[0].name -# # service_port = kubernetes_service.minha_aplicacao_service.spec[0].port[0].port -# # } -# # } -# # } -# # } -# # } \ No newline at end of file +} \ No newline at end of file diff --git a/terraform/provider.tf b/terraform/provider.tf deleted file mode 100644 index bc26b41..0000000 --- a/terraform/provider.tf +++ /dev/null @@ -1,4 +0,0 @@ -provider "kubernetes" { - config_path = "/etc/rancher/k3s/k3s.yaml" - config_context_cluster = "default" -} \ No newline at end of file diff --git a/terraform/sg.tf b/terraform/sg.tf index 0952630..ab9a255 100644 --- a/terraform/sg.tf +++ b/terraform/sg.tf @@ -1,7 +1,5 @@ resource "aws_security_group" "acesso_geral" { name = "acesso_geral" - // vpc_id = "vpc-0c1cb11038b243da9" - // security_group = [ "acesso_geral" ] description = "grupo de dev" ingress { @@ -71,7 +69,7 @@ resource "aws_security_group" "acesso_geral" { } tags = { - Name = "Wordpress_Mysql" + Name = "my-app" } } diff --git a/terraform/variables.tf b/terraform/variables.tf index 47fe922..f67e62a 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -1,23 +1,23 @@ variable "aws_region" { type = string description = "The AWS region to deploy to" - default = "us-east-1" + default = "" } variable "aws_profile" { type = string description = "The AWS profile to use to execute the commands" - default = "default" + default = "" } variable "environment" { type = string description = "The environment to deploy to" - default = "dev" + default = "" } variable "instance_type" { type = string description = "The instance power" - default = "t2.micro" + default = "" } diff --git a/terraform/version.tf b/terraform/version.tf index 9d5cbcc..9d90598 100644 --- a/terraform/version.tf +++ b/terraform/version.tf @@ -13,8 +13,6 @@ provider "aws" { terraform { -# required_version = "1.5.3" - required_providers { aws = { source = "hashicorp/aws" From 068c24cc08adc8513d95084630d35e10c715b44e Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Mon, 13 Nov 2023 04:10:19 -0300 Subject: [PATCH 099/103] Update apply-dev.yml --- .github/workflows/apply-dev.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index ad9361b..6a40ec2 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -1,8 +1,6 @@ name: Apply terraform resources dev on: [workflow_dispatch] - # push: - # branches: [master] env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} From b24337243a890f71b78d756cc1e3cefa3b997682 Mon Sep 17 00:00:00 2001 From: richardneves <57494222+richardneves@users.noreply.github.com> Date: Mon, 13 Nov 2023 04:11:01 -0300 Subject: [PATCH 100/103] Update apply-dev.yml --- .github/workflows/apply-dev.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index 6a40ec2..fb19d93 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -1,7 +1,8 @@ name: Apply terraform resources dev on: [workflow_dispatch] - + # push: + # branches: [master] env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} From 4cc12f1db1f8e955d4a341ef54641fdc25c05a28 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Mon, 13 Nov 2023 04:11:35 -0300 Subject: [PATCH 101/103] Teste k3s --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 0e81a48..c6e57f7 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,6 @@ O DockerFile é utilizado pelo arquivo de esteira na pasta .github/workflows pus Arquivos básicos onde fazem a construção da EC2 na AWS e em paralelo também fazem a criação do K3S dentro da EC2 da AWS que é uma opção escolhida ao kubernetes pela praticidade em sua configuração. E é realizado o deploy da aplicação via manifesto com shell script. - # Destroy terraform -Existe um arquivo onde é executado manualmente de destroy-apply.yml onde é possível destruir toda configuração realizado pelo terraform. \ No newline at end of file +Existe o arquivo terraform destroy-apply.yml onde é executado manualmente o "destroy" da aplicação criada pelo terraform. \ No newline at end of file From c2060a7937e48dd6a68bfbc6434ebfa3e44e952b Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Mon, 13 Nov 2023 04:12:06 -0300 Subject: [PATCH 102/103] teste k3s 4 --- .github/workflows/apply-dev.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/apply-dev.yml b/.github/workflows/apply-dev.yml index fb19d93..6a40ec2 100644 --- a/.github/workflows/apply-dev.yml +++ b/.github/workflows/apply-dev.yml @@ -1,8 +1,7 @@ name: Apply terraform resources dev on: [workflow_dispatch] - # push: - # branches: [master] + env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} From 58124fb1ecb3ec8728dfb0e71b3dfa9c2d1a1853 Mon Sep 17 00:00:00 2001 From: Richard Neves Date: Mon, 13 Nov 2023 04:26:28 -0300 Subject: [PATCH 103/103] teste k3s 5 --- terraform/devAuto.tfvars | 7 ------- terraform/variables.tf | 10 ++++++---- 2 files changed, 6 insertions(+), 11 deletions(-) delete mode 100644 terraform/devAuto.tfvars diff --git a/terraform/devAuto.tfvars b/terraform/devAuto.tfvars deleted file mode 100644 index 493ce1d..0000000 --- a/terraform/devAuto.tfvars +++ /dev/null @@ -1,7 +0,0 @@ -instance_type = "t2.micro" - -environment = "dev" - -aws_profile = "default" - -aws_region = "us-east-1" \ No newline at end of file diff --git a/terraform/variables.tf b/terraform/variables.tf index f67e62a..6326825 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -1,23 +1,25 @@ variable "aws_region" { type = string description = "The AWS region to deploy to" - default = "" + default = "us-east-1" } variable "aws_profile" { type = string description = "The AWS profile to use to execute the commands" - default = "" + default = "default" + } variable "environment" { type = string description = "The environment to deploy to" - default = "" + default = "dev" + } variable "instance_type" { type = string description = "The instance power" - default = "" + default = "t2.micro" }