From 0b3790e7e2251e4215fd063cd1a757d67c956bfb Mon Sep 17 00:00:00 2001 From: "Julien Richard [RMT - JS] Wild Code School" <33219171+jujuck@users.noreply.github.com> Date: Thu, 23 Nov 2023 15:51:48 +0100 Subject: [PATCH 1/7] Update deploy-traefik.yml --- .github/workflows/deploy-traefik.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/deploy-traefik.yml b/.github/workflows/deploy-traefik.yml index 8d221c5b..67feaf9f 100644 --- a/.github/workflows/deploy-traefik.yml +++ b/.github/workflows/deploy-traefik.yml @@ -29,7 +29,6 @@ jobs: deploy: needs: check-secrets - if: needs.check-secrets.outputs.defined == 'true' runs-on: ubuntu-latest steps: - name: Deploy to VPS @@ -38,4 +37,4 @@ jobs: username: ${{ secrets.SSH_USER }} host: ${{ secrets.SSH_HOST }} password: ${{ secrets.SSH_PASSWORD }} - script: cd && cd traefik/deploy && bash ./js-project.sh ${{ github.actor }} ${{ github.event.repository.name }} ${{ vars.PROJECT_NAME }} '${{ toJSON(vars) }}' + script: cd && cd traefik/deploy && bash ./js-project.sh {{ github.event.repository.owner.name }} ${{ github.event.repository.name }} ${{ vars.PROJECT_NAME }} '${{ toJSON(vars) }}' From 27a62dcdf54cf9725b284bfce509bd5bf4b35956 Mon Sep 17 00:00:00 2001 From: "Julien Richard [RMT - JS] Wild Code School" <33219171+jujuck@users.noreply.github.com> Date: Thu, 23 Nov 2023 15:52:12 +0100 Subject: [PATCH 2/7] Update package.json --- backend/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/package.json b/backend/package.json index b8059cb1..292e378f 100644 --- a/backend/package.json +++ b/backend/package.json @@ -3,7 +3,7 @@ "dev": "nodemon index.js", "db:migrate": "node migrate.js", "db:seed": "node seed.js", - "build": "node migrate.js && node seed.js", + "build": "node migrate.js", "start": "node index.js", "test": "jest" }, From 09602bf21e484920edc289392af8dd0a4288343f Mon Sep 17 00:00:00 2001 From: "Julien Richard [RMT - JS] Wild Code School" <33219171+jujuck@users.noreply.github.com> Date: Thu, 23 Nov 2023 15:52:33 +0100 Subject: [PATCH 3/7] Update docker-compose.prod.yml --- docker-compose.prod.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 836dc2d1..afce357c 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -19,6 +19,7 @@ services: DB_USER: ${USER_NAME} DB_PASSWORD: ${USER_PASSWORD} DB_NAME: ${DB_NAME} + VITE_BACKEND_URL: "" networks: - proxy labels: @@ -30,4 +31,4 @@ services: networks: proxy: - external: true \ No newline at end of file + external: true From 40b287eb6aa01676d982afbff9d70f0c1d55f160 Mon Sep 17 00:00:00 2001 From: "Julien Richard [RMT - JS] Wild Code School" <33219171+jujuck@users.noreply.github.com> Date: Thu, 23 Nov 2023 15:52:45 +0100 Subject: [PATCH 4/7] Update docker-entry.sh --- docker-entry.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-entry.sh b/docker-entry.sh index 3db6188d..2cf68af0 100644 --- a/docker-entry.sh +++ b/docker-entry.sh @@ -1,5 +1,5 @@ #!/usr/bin/env sh sleep 5 -npm build -npm start +npm run build +npm run start From b20a48185217fb339fea28830c6df273949dd44f Mon Sep 17 00:00:00 2001 From: "Julien Richard [RMT - JS] Wild Code School" <33219171+jujuck@users.noreply.github.com> Date: Thu, 23 Nov 2023 16:07:34 +0100 Subject: [PATCH 5/7] Update README.md --- README.md | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e4e597d3..b1971516 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ git config --global core.autocrlf false - _Prettier_ : "Quality of code" tool as well, focuses on the styleguide - _ Airbnb Standard_ : One of the most known "standards", even though it's not officially linked to ES/JS -### Deployment with Traefik +## Deployment with Traefik > ⚠️ Prerequisites : You must have installed and configured Traefik on your VPS beforehand. > https://github.com/WildCodeSchool/vps-traefik-starter-kit/ @@ -54,9 +54,22 @@ For deployment, you have to go to `secrets` → app `actions` on the github repo And a public variable from the tab `/settings/variables/actions` -- PROJECT_NAME : the name of the project used to create the subdomain for frontend. +- PROJECT_NAME : the name of the project used to create the subdomain. + Warning, underscore are not allowed. They can cause trouble with the let's encrypt certificate +Use this same tab to add the other environment variables required for the project if any. + +Only the backend will be accessible. The root path "/" will redirect to the dist folder on your frontend. In order to allow that, please uncomment the line as explain on `backend/src/app.js` (Line 102). +Because the backend will deserve the front, the global variable VITE_BACKEND_URL is fill with a blank string. +Your url will be ` https://${PROJECT-NAME}.${subdomain}.wilders.dev/`. + +### About the database +The database is automaticaly deploy with the name of your repo. On the build of the projet (`docker-entry.sh`), the script `npm run migrate` is executed. If you want to seed automaticaly your database with the `seed.js` file, please replace the command *build* on you `backend/package.json` by `node migrate.js && node seed.js` + +### About picture +Warning, don't use any public folder on your frontend. This folder won't be accessible online. In place, use the one on your backend folder + +### About Logs +If you want to access the logs of your online projet (to follow the deployement or to watch any bug error), connect to your VPS (ssh user@host). +Then, go on your specific project and run  `docker compose logs -t -f`. -The backend subdomain will be automatically created with the suffix -backend. -The global variable VITE_BACKEND_URL will be automatically created and pre-filled on the basis of this information. -Use this same tab to add the other environment variables required for the project if any. From 6d54ffb033ef6e84159785f9dabea956495c4c34 Mon Sep 17 00:00:00 2001 From: Romain Guillemot Date: Thu, 23 Nov 2023 18:01:33 +0100 Subject: [PATCH 6/7] Update README.md --- README.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b1971516..a6eafd26 100644 --- a/README.md +++ b/README.md @@ -58,18 +58,21 @@ And a public variable from the tab `/settings/variables/actions` Warning, underscore are not allowed. They can cause trouble with the let's encrypt certificate Use this same tab to add the other environment variables required for the project if any. -Only the backend will be accessible. The root path "/" will redirect to the dist folder on your frontend. In order to allow that, please uncomment the line as explain on `backend/src/app.js` (Line 102). -Because the backend will deserve the front, the global variable VITE_BACKEND_URL is fill with a blank string. +Only the backend will be accessible. The root path "/" will redirect to the dist folder on your frontend. In order to allow that, please uncomment the corresponding lines as explain on `backend/src/app.js` (Line 102). +Because the backend will serve the front, the global variable VITE_BACKEND_URL will be an empty string. + Your url will be ` https://${PROJECT-NAME}.${subdomain}.wilders.dev/`. ### About the database -The database is automaticaly deploy with the name of your repo. On the build of the projet (`docker-entry.sh`), the script `npm run migrate` is executed. If you want to seed automaticaly your database with the `seed.js` file, please replace the command *build* on you `backend/package.json` by `node migrate.js && node seed.js` -### About picture -Warning, don't use any public folder on your frontend. This folder won't be accessible online. In place, use the one on your backend folder +The database is automaticaly deployed with the name of your repo. During the build of the projet (`docker-entry.sh`), the `npm build` command is executed. By default, this will run `node migrate.js && node seed.js` in the backend, creating and seeding the database. If you don't want to seed automaticaly your database with the `seed.js` file, please replace the command *build* on you `backend/package.json` by `node migrate.js`. + +### About public assets (pictures, fonts...) + +Warning, don't use any public folder on your frontend. This folder won't be accessible online. In place, use the one on your backend folder. Prefer [static assets](https://vitejs.dev/guide/assets) when possible. ### About Logs -If you want to access the logs of your online projet (to follow the deployement or to watch any bug error), connect to your VPS (ssh user@host). -Then, go on your specific project and run  `docker compose logs -t -f`. +If you want to access the logs of your online projet (to follow the deployement or to watch any bug error), connect to your VPS (`ssh user@host`). +Then, go on your specific project and run `docker compose logs -t -f`. From af9d8ccc017124aee209d2723ff38a8a63ea4c29 Mon Sep 17 00:00:00 2001 From: Romain Guillemot Date: Thu, 23 Nov 2023 18:02:23 +0100 Subject: [PATCH 7/7] Update package.json --- backend/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/package.json b/backend/package.json index 292e378f..b8059cb1 100644 --- a/backend/package.json +++ b/backend/package.json @@ -3,7 +3,7 @@ "dev": "nodemon index.js", "db:migrate": "node migrate.js", "db:seed": "node seed.js", - "build": "node migrate.js", + "build": "node migrate.js && node seed.js", "start": "node index.js", "test": "jest" },