From 5cc6fe7ed2116f65c6ab0aa1ce822ea475b7b340 Mon Sep 17 00:00:00 2001 From: Mehmet Ali Bekooglu Date: Mon, 3 Jul 2023 01:17:37 +0200 Subject: [PATCH 1/3] feat: Extended README.md --- README.md | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/README.md b/README.md index 7c44afc..adb71cd 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,10 @@ an application from the beginning to the end. - [PWA](#pwa) - [Deploy on Vercel](#deploy-on-vercel) - [Architecture and Strategies](#architecture-and-strategies) +- [Testing](#testing) +- [Docker](#docker) +- [Terraform](#terraform) +- [Github Actions](#github-actions) - [Project History and Status](#project-history-and-status) - [Improvements for next project](#improvements-for-next-project) - [Authors](#authors) @@ -182,6 +186,88 @@ In this application, unit tests are used to test individual code sections that e Some tests for liking mumbles and for loading and creating a mumble have already been created. So we would also test the other services. It would also be important for us to ensure that the application can deal with a missing access token and any error from the API. (However, error handling has not yet been implemented in the application.) +## Docker + +The application can be run on a docker. Before docker can be used [install Docker Engine](https://docs.docker.com/engine/install/). To build a docker image locally, you need to ensure a local [.nmprc](#authenticating-github-registry) and [.env](#create-environment-variables) file. Additionally copy the `.npmrc` file to your user directory. After execute following code: + +```console +docker build . -t app-helloworld --build-arg NEXT_PUBLIC_QWACKER_API_URL=https://qwacker-api-http-prod-4cxdci3drq-oa.a.run.app/ --secret id=npmrc_secret,src=$HOME/.npmrc +``` + +When the build was successfully, you can run the image with following command: + +```console +docker run -p 3000:3000 --env-file ./.env --rm --name app-helloworld app-helloworld +``` + +You can also run the image on the docker compose, like following: + +```console +docker-compose --env-file ./.env up +``` + +If you want to upload your docker image manually to the [google cloud](https://cloud.google.com/?hl=de), push the following code: + +```console +docker push europe-west6-docker.pkg.dev/expanded-symbol-389711/helloworld/app-helloworld +``` +## Terraform + +Before using terraform, you need to [install terraform](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli) on your system. In this project terraform deploys the application on [google cloud](https://cloud.google.com/?hl=de), see the terraform configuration on this project under the `/terraform` folder. + +First you need to login with your account to google cloud, to get access. + +```console +gcloud auth login +gcloud auth application-default login +``` + +After the login there are permission you need to have. Most of the time these permissions are enough + +```console +gcloud projects add-iam-policy-binding expanded-symbol-389711 / +--member='serviceAccount:tf-deploy-helloworld@expanded-symbol-389711.iam.gserviceaccount.com' / +--role='roles/resourcemanager.projectIamAdmin' +``` + +```console +gcloud projects add-iam-policy-binding expanded-symbol-389711 / +--member='serviceAccount:tf-deploy-helloworld@expanded-symbol-389711.iam.gserviceaccount.com' / +--role='roles/iam.serviceAccountUser' +``` + +```console +gcloud projects add-iam-policy-binding expanded-symbol-389711 / +--member='serviceAccount:tf-deploy-helloworld@expanded-symbol-389711.iam.gserviceaccount.com' / +--role='roles/iam.serviceAccountTokenCreator' +``` + +To deploy with terraform manually, the following commands have to be executed in order + +### Terraform commands + +You need to initializes a working directory containing terraform configuration files. This command is executed once after writing a new Terraform configuration or cloning an existing one. + +```console +terraform init +``` + +To create an execution plan, that shows you the changes that terraform plans to make to your infrastructure. + +```console +terraform plan +``` + +The last command executes the actions proposed in a terraform plan. + +```console +terraform apply --auto-approve +``` + +## Github Actions + +The project starts after every pull request and merge into main a pineapple, that makes some quality checks and after that is successful, the unit and e2e tests are ran. Only for the merge to main, a docker image is build and pushed to google cloud with terraform. + ## Project History and Status Our projects follow the conventions of the [Semantic Versioning 2.0.0](https://semver.org/). The tickets are tracked with [Trello](https://trello.com/b/f3ETlXfM/app). From aa7cbda312d0b89d765478752166e54f622db908 Mon Sep 17 00:00:00 2001 From: Mehmet Ali Bekooglu Date: Mon, 3 Jul 2023 06:37:38 +0200 Subject: [PATCH 2/3] feat: Refactored README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index adb71cd..703ee23 100644 --- a/README.md +++ b/README.md @@ -266,7 +266,7 @@ terraform apply --auto-approve ## Github Actions -The project starts after every pull request and merge into main a pineapple, that makes some quality checks and after that is successful, the unit and e2e tests are ran. Only for the merge to main, a docker image is build and pushed to google cloud with terraform. +The project starts after every pull request and after every merge into main a workflow. On both workflow's, it starts first the quality checks for eslint, prettier and dependency cruiser. When the checks are finished successful the next pipeline with unit and e2e test are executed. Further the main merge triggers the docker image and the push to google cloud with terraform. The strategy for the github actions uses the reusable workflow technique. ## Project History and Status From 84f6d3d7f70c5d99bd8812884c873b3fa1a04424 Mon Sep 17 00:00:00 2001 From: Mehmet Ali Bekooglu Date: Mon, 3 Jul 2023 06:39:55 +0200 Subject: [PATCH 3/3] feat: Refactored README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 703ee23..6a7f020 100644 --- a/README.md +++ b/README.md @@ -279,6 +279,7 @@ Our projects follow the conventions of the [Semantic Versioning 2.0.0](https://s - Add reload button for new mumbles - Add unit and integration tests - Refactor some componenets in storybook +- Add further vital checks as github actions workflow for the application ## Authors