From c1f0fcb204262fa29dc30aaff835d3066a9e454f Mon Sep 17 00:00:00 2001 From: Sofiia Trokhymchuk Date: Thu, 29 Aug 2024 20:14:20 +0300 Subject: [PATCH 01/10] OV-86: + base cd config --- .github/workflows/cd.yml | 37 +++++++++++++++++++++++++++++++++++++ package.json | 5 ++++- prepare-build.sh | 5 +++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/cd.yml create mode 100644 prepare-build.sh diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 000000000..7b731df2b --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,37 @@ +name: Continuous Delivery + +env: + AWS_REGION: us-north-1 + EBS_APP_NAME: bsa-2024-outreachvids + ENVIRONMENT: next + +on: + push: + branches: + - task/OV-86-add-deployment + workflow_dispatch: + +jobs: + cd: + runs-on: ubuntu-latest + + steps: + - name: Checkout Source Code + uses: actions/checkout@v3 + with: + node-version: .nvmrc + + - name: Zipping + run: | + zip -r build.zip . -x .github + - name: Deploy to EB + uses: einaregilsson/beanstalk-deploy@v21 + with: + use_existing_version_if_available: true + aws_access_key: ${{ secrets.AWS_ACCESS_KEY }} + aws_secret_key: ${{ secrets.AWS_SECRET_KEY }} + region: ${{ env.AWS_REGION }} + application_name: ${{ env.EBS_APP_NAME }} + environment_name: ${{ env.ENVIRONMENT }} + version_label: ${{ github.sha }} + deployment_package: ./build.zip diff --git a/package.json b/package.json index 07b2f7e62..2659e89f9 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "build:shared": "npm run build -w shared", "build:frontend": "npm run build -w frontend", "build:backend": "npm run build -w backend", + "build": "npm run build:shared && npm run build:backend && npm run build:frontend && sh ./prepare-build.sh", "lint:editor": "editorconfig-checker", "lint:fs": "ls-lint", "lint:type": "npm run lint:type --workspaces --if-present", @@ -25,7 +26,9 @@ "lint:format": "prettier --check \"**/*.{ts,tsx,json,md,scss,html,yml}\"", "lint": "npm run lint:editor && npm run lint:fs && npm run lint:format && npm run lint:type && npm run lint:js && npm run lint:css", "lint:fix": "npm run lint:fix -w frontend && npm run lint:fix -w backend", - "format": "prettier --write \"**/*.{ts,tsx,json,md,css,html,yml}\"" + "format": "prettier --write \"**/*.{ts,tsx,json,md,css,html,yml}\"", + "prestart": "npm install --include=dev && npm run build", + "start": "cd ./build/backend && npm run start" }, "devDependencies": { "@commitlint/cli": "19.4.0", diff --git a/prepare-build.sh b/prepare-build.sh new file mode 100644 index 000000000..384432fa0 --- /dev/null +++ b/prepare-build.sh @@ -0,0 +1,5 @@ +#!/bin/bash +mkdir -p ./build/backend; mv ./backend/build/* ./build/backend +mkdir ./build/backend/public; mv ./frontend/build/* ./build/backend/public +cp ./backend/package.json ./build/backend +cp package.json package-lock.json ./build From ca1031b9cb79894a57658c136a65e7bb0c2dbb80 Mon Sep 17 00:00:00 2001 From: Sofiia Trokhymchuk Date: Fri, 30 Aug 2024 11:21:15 +0300 Subject: [PATCH 02/10] OV-86: * fix region --- .github/workflows/cd.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 7b731df2b..ec33ac055 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,7 +1,7 @@ name: Continuous Delivery env: - AWS_REGION: us-north-1 + AWS_REGION: eu-north-1 EBS_APP_NAME: bsa-2024-outreachvids ENVIRONMENT: next @@ -35,3 +35,4 @@ jobs: environment_name: ${{ env.ENVIRONMENT }} version_label: ${{ github.sha }} deployment_package: ./build.zip + wait_for_environment_recovery: 300 From 67dc747b5802a4bc706bc710db57fcfc70401b1b Mon Sep 17 00:00:00 2001 From: Sofiia Trokhymchuk Date: Fri, 30 Aug 2024 11:32:27 +0300 Subject: [PATCH 03/10] OV-86: * install node.js step --- .github/workflows/cd.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index ec33ac055..ae36b548a 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -17,13 +17,17 @@ jobs: steps: - name: Checkout Source Code - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + - name: Install NodeJS + uses: actions/setup-node@v4 with: - node-version: .nvmrc + node-version-file: .nvmrc - - name: Zipping + - name: Zipping Deployment Package run: | zip -r build.zip . -x .github + - name: Deploy to EB uses: einaregilsson/beanstalk-deploy@v21 with: From b13c2e87eebe59ea660993f35416c10edb77f383 Mon Sep 17 00:00:00 2001 From: Sofiia Trokhymchuk Date: Fri, 30 Aug 2024 13:05:24 +0300 Subject: [PATCH 04/10] OV-86: - postinstall script --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 2659e89f9..8f94ced1a 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,6 @@ "frontend" ], "scripts": { - "postinstall": "npm run build:shared", "build:shared": "npm run build -w shared", "build:frontend": "npm run build -w frontend", "build:backend": "npm run build -w backend", From f8ab308d62c372e98e234b94b9156d001edfdb09 Mon Sep 17 00:00:00 2001 From: Sofiia Trokhymchuk Date: Fri, 30 Aug 2024 17:40:23 +0300 Subject: [PATCH 05/10] OV-86: * tsconfig.json --- backend/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/tsconfig.json b/backend/tsconfig.json index 10167079e..414e46c76 100644 --- a/backend/tsconfig.json +++ b/backend/tsconfig.json @@ -6,6 +6,7 @@ "baseUrl": ".", "paths": { "~/*": ["./src/*"] - } + }, + "outDir": "build" } } From 891d7ceb8d276a74e5e1e2ca4cae67429db1699a Mon Sep 17 00:00:00 2001 From: Sofiia Trokhymchuk Date: Fri, 30 Aug 2024 17:46:03 +0300 Subject: [PATCH 06/10] OV-86: * push branch --- .github/workflows/cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index ae36b548a..0168faf58 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -8,7 +8,7 @@ env: on: push: branches: - - task/OV-86-add-deployment + - next workflow_dispatch: jobs: From 5c3f796a1de147d70d1762288466e2be60111ca1 Mon Sep 17 00:00:00 2001 From: Sofiia Trokhymchuk Date: Fri, 30 Aug 2024 18:09:17 +0300 Subject: [PATCH 07/10] OV-86: + ssl config --- .github/workflows/cd.yml | 2 +- backend/src/common/database/base-database.package.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 0168faf58..ae36b548a 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -8,7 +8,7 @@ env: on: push: branches: - - next + - task/OV-86-add-deployment workflow_dispatch: jobs: diff --git a/backend/src/common/database/base-database.package.ts b/backend/src/common/database/base-database.package.ts index dabeafca9..ab87d8d9d 100644 --- a/backend/src/common/database/base-database.package.ts +++ b/backend/src/common/database/base-database.package.ts @@ -32,9 +32,17 @@ class BaseDatabase implements Database { } private get initialConfig(): TKnex.Config { + const sslConfig = + this.appConfig.ENV.APP.ENVIRONMENT === AppEnvironment.DEVELOPMENT + ? null + : { ssl: { rejectUnauthorized: false } }; + return { client: this.appConfig.ENV.DB.DIALECT, - connection: this.appConfig.ENV.DB.CONNECTION_STRING, + connection: { + connectionString: this.appConfig.ENV.DB.CONNECTION_STRING, + ...(!!sslConfig && sslConfig), + }, pool: { min: this.appConfig.ENV.DB.POOL_MIN, max: this.appConfig.ENV.DB.POOL_MAX, From 07ce00769b8fa8f7bfb86aebd7a86464eac88fc2 Mon Sep 17 00:00:00 2001 From: Sofiia Trokhymchuk Date: Fri, 30 Aug 2024 18:47:44 +0300 Subject: [PATCH 08/10] OV-86: + start migrate script --- package-lock.json | 1 - package.json | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8dcddd8bc..e9ae669cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,6 @@ "packages": { "": { "name": "project", - "hasInstallScript": true, "workspaces": [ "shared", "backend", diff --git a/package.json b/package.json index 8f94ced1a..708ab1c25 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,8 @@ "lint": "npm run lint:editor && npm run lint:fs && npm run lint:format && npm run lint:type && npm run lint:js && npm run lint:css", "lint:fix": "npm run lint:fix -w frontend && npm run lint:fix -w backend", "format": "prettier --write \"**/*.{ts,tsx,json,md,css,html,yml}\"", - "prestart": "npm install --include=dev && npm run build", + "migrate": "npm run migrate:dev -w backend", + "prestart": "npm install --include=dev && npm run migrate && npm run build", "start": "cd ./build/backend && npm run start" }, "devDependencies": { From f23318b2153602de569f4d1114afc742228d05c8 Mon Sep 17 00:00:00 2001 From: Sofiia Trokhymchuk Date: Fri, 30 Aug 2024 19:11:13 +0300 Subject: [PATCH 09/10] OV-86: * prestart --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 708ab1c25..bffdc2a17 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "lint:fix": "npm run lint:fix -w frontend && npm run lint:fix -w backend", "format": "prettier --write \"**/*.{ts,tsx,json,md,css,html,yml}\"", "migrate": "npm run migrate:dev -w backend", - "prestart": "npm install --include=dev && npm run migrate && npm run build", + "prestart": "npm install --include=dev && npm run build && npm run migrate", "start": "cd ./build/backend && npm run start" }, "devDependencies": { From dfc07f920bba9957ff4dbfa1091b73f53cd8a2ff Mon Sep 17 00:00:00 2001 From: Sofiia Trokhymchuk Date: Mon, 2 Sep 2024 12:13:45 +0300 Subject: [PATCH 10/10] OV-86: * update destination branch --- .github/workflows/cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index ae36b548a..0168faf58 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -8,7 +8,7 @@ env: on: push: branches: - - task/OV-86-add-deployment + - next workflow_dispatch: jobs: