Skip to content

Commit

Permalink
Merge pull request #108 from WildCodeSchool/debug/deploywithtreafik
Browse files Browse the repository at this point in the history
Debug/deploywithtreafik
  • Loading branch information
rocambille authored Nov 23, 2023
2 parents 465cbe5 + af9d8cc commit 008078c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/deploy-traefik.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) }}'
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -54,9 +54,25 @@ 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.

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.
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 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`.

Use this same tab to add the other environment variables required for the project if any.
3 changes: 2 additions & 1 deletion docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ services:
DB_USER: ${USER_NAME}
DB_PASSWORD: ${USER_PASSWORD}
DB_NAME: ${DB_NAME}
VITE_BACKEND_URL: ""
networks:
- proxy
labels:
Expand All @@ -30,4 +31,4 @@ services:

networks:
proxy:
external: true
external: true
4 changes: 2 additions & 2 deletions docker-entry.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env sh

sleep 5
npm build
npm start
npm run build
npm run start

0 comments on commit 008078c

Please sign in to comment.