From 0622a84d26b3a3dcfe5b8c19134261f009f559ff Mon Sep 17 00:00:00 2001 From: tharvik Date: Tue, 7 May 2024 17:09:03 +0200 Subject: [PATCH] docs/deployement: initial --- docs/DEPLOYEMENT.md | 28 +++++++++++++++++++++++ server/README.md | 54 --------------------------------------------- 2 files changed, 28 insertions(+), 54 deletions(-) create mode 100644 docs/DEPLOYEMENT.md diff --git a/docs/DEPLOYEMENT.md b/docs/DEPLOYEMENT.md new file mode 100644 index 000000000..3fd4cd869 --- /dev/null +++ b/docs/DEPLOYEMENT.md @@ -0,0 +1,28 @@ +# Deployment + +We are maintaining two services, the [webapp](https://discolab.ai/) and the [server](https://disco-zbkj3i466a-oa.a.run.app/). +Both are automatically deployed when pushing to the main branch via [a workflow of our CI](../.github/workflows/publish-deploy.yml). + +## webapp + +It is first built using a classic `npm -ws run build`. +Then is gets deployed to GitHub Pages, +with a [custom domain](https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site). + +## server + +First, a [container image]() is built +using the repo's [Dockerfile](https://docs.docker.com/reference/dockerfile/). +It gets pushed to [GitHub Packages](https://docs.github.com/en/packages). + +It is then deployed to [Google Cloud via Cloud Run](https://cloud.google.com/run). + +### Google Cloud specifics + +The GitHub Action runner is authenticated via a +[Direct Workload Identity Federation](https://github.com/google-github-actions/auth?tab=readme-ov-file#preferred-direct-workload-identity-federation) +to gives it the rights of a [service account](https://cloud.google.com/iam/docs/service-account-overview) +which can administrate the deployment of the images. + +The image itself is proxied via a [remote Artifact Registry](https://cloud.google.com/artifact-registry/docs/repositories/remote-overview) +as Google doesn't allow to directly get it from GitHub Packages. diff --git a/server/README.md b/server/README.md index 03080ee97..09ff7d0d5 100644 --- a/server/README.md +++ b/server/README.md @@ -97,57 +97,3 @@ npm -w server test > [!WARNING] > If you are running a VPN, docker might not properly work, e.g. `http://localhost:8080/` will result in `page not found`. - -### Deploying to the Cloud - -#### Google App Engine - -Google App Engine (GAE) creates an HTTPS certificate automatically, making this the easiest way to deploy the helper server in the Google Cloud Platform. - -Since we need to install some required dependencies we deploy using Docker, we do this by choosing: - -```yml -runtime: custom -``` - -in the `app.yaml` file. - -Deployment files: - -- `app.yaml` - GAE app config file. -- `Dockerfile` - Docker [commands](https://docs.docker.com/engine/reference/builder/) we specify. -- `.dockerignore` - Files to ignore while building the image, e.g. `node_modules/`. - -To change the GAE app configuration, you can modify the file `app.yaml`. - -> [!WARNING] -> Make sure you allocate enough memory! - -Note that the size of the container can be quite large (e.g 600mb), if the alloted memory is too small then there might be 503 [errors](https://groups.google.com/g/google-appengine/c/BawYguWHq7Q) when deploying that hard tricky to debug. - -To deploy the app on GAE, you can run the following command, where disco-313515 is the current PROJECT-ID: - -```sh -gcloud app deploy --project=deai-313515 app.yaml --version prod -``` - -:exclamation: Important! -| :exclamation: This is very important | -|-----------------------------------------| -When deploying check that in the google cloud console -> app engine -> versions, that no new instance is created as this will increase the cloud costs. -This should not happen in principle due to the "--version dev" flag, it is however a good idea to check this the first time you run this command. - -Some useful resources: - -- [Docker sample app](https://docs.docker.com/get-started/02_our_app/) -- [Dockerfile reference](https://docs.docker.com/engine/reference/builder/#from) -- [GAE sample app](https://cloud.google.com/appengine/docs/standard/nodejs/building-app/deploying-web-service) - -#### Docker - -In the docker container we specify the environment and what dependencies to install. Perhaps most importantly, once this is this done, we specify: - -1. npm run build -2. npm run start - -The first line compiles the ts code into js, and the second one then runs the compiled code.