- Dockerfile 100%
|
Samuel Roland
2c6151df55
vps: delete infra after migration to samuelroland/vps
This is the new repos for maintenance https://codeberg.org/samuelroland/vps |
||
|---|---|---|
| docker | proxy: update Caddy from 2.8 to 2.11 | |
| env | env: add restart unless-stopped for lxup-website | |
| imgs | readme: add WIP infra overview diagram | |
| schemas | docs: save infra-overview schemas with dev env | |
| .gitignore | docs: save infra-overview schemas with dev env | |
| README.md | docker: refactor common deps into base.Dockerfile, add website Dockerfile.dev | |
infra - Docker infrastructure for development and production
Docker infrastructure overview schema
Incomplete but useful diagram of the infrastructure
Development infra
Here are the minimal steps to install a fully working development environment, that let you play with Delibay locally and start coding. It is working with a delibay.local domain that you configure to point locally. It is only using host ports 80 and 443. Each service is hosted on a given subdomain. The frontend is at app.delibay.local.
- Clone all Git repositories under a
devfolder and create a state folder underdev/stategit clone https://codeberg.org/delibay/infra.git cd infra mkdir dev dev/state && cd dev git clone https://codeberg.org/delibay/frontend.git git clone https://codeberg.org/delibay/backend.git git clone https://codeberg.org/delibay/delibay.org.git git clone https://codeberg.org/delibay/project.git cd .. - Build all docker images, juste once
docker build --network host . -f docker/base.Dockerfile -t delibay-dev/base # base development image cd infra/env docker compose -f dev.yml build - Define these host names in your
/etc/hostsorC:\Windows\System32\hostsas administrator. These allows to resolve these domains as the local environment, even if the domain doesn't really exist.127.0.0.1 delibay.local 127.0.0.1 backend.delibay.local 127.0.0.1 app.delibay.local 127.0.0.1 git.delibay.local 127.0.0.1 mail.delibay.local - Setup forgejo servers with admin account on https://git.kaizen.local.
docker compose -f dev.yml up - Backend and frontend will automatically start some scripts to install dependencies and start development servers.
Users and Credentials
When the backend container starts, it initialized the database with a few elements, to avoid making them manually.
- All users have the password
pwdfor ease of development - One organisation named
DeliSchoolhas been created and the following users have joined it- 2 teachers:
teacher1@delibay.organdteacher2@delibay.org - 10 students:
student1@delibay.org,student2@delibay.org, ...student10@delibay.org.
- 2 teachers:
How to use the infra ?
Make sure you visit all domains before using them to have clicked "Trust this self-signed certificate".
- Visit https://delibay.local to view the
delibay.orgwebsite, showing content from theprojectrepository cloned atdev/project. - Visit https://backend.delibay.local to see the backend running based on the
backendrepository cloned atdev/backend. - Visit https://app.delibay.local to view the frontend, showing content from the
frontendrepository cloned atdev/frontend. - Visit https://git.delibay.local to access a local Git server using Forgejo. You can setup a root account and user account if you want to deploy courses only locally.
- Visit https://mail.delibay.local to access a fake mail server called maildev.
Quick wins
Once you opened all these domains and everything is working, here are a few steps to show how technically easy it is to contribute.
Changing some documentation pages
- Open the documentation pages on https://delibay.local, choose one page at left in the list.
- Open
dev/projectand search for the associated Markdown file. Hint: It has the same name as the route. - Open this file and add a creative paragraph somewhere.
- Make sure to hit save and reload the page in your browser. The change should be visible !
Deploying a public course from GitHub
- Login as a teacher: take email
teacher1@delibay.org, passwordpwdand backend URLbackend.delibay.local. - You should be logged in and but there is no course. This is expected !
- Choose a course from the list or pick other you know
- https://github.com/HEIG-VD-Delibay/PRG1_Recueil_Exercices
- More to come... TODO
- Open its URL and take the SSH link.
- Click on
Deploy courseand use the SSH link - The course should be deployed and it should be listed under the Courses list.
- You can open it and try a few exos to make sure it works.
Production infra
Install the VPS
Generate and manage secrets in .env
Generate a BETABACKEND_APP_KEY
https://dev.to/gregorip02/how-generate-a-laravel-appkey-with-openssl-4cpe
echo "base64:$(openssl rand -base64 32)"
TODO: check the security of the randomness and check the length choice
Manage server rules
TODO
Post start scripts
TODO: Start the infrastructure in background docker compose up -d. The Laravel apps should finish their setup themself at this moment (run database migrations, run key generation, and finally setup in up mode (php artisan up)).
Generate backups
TODO
Handle updates
TODO
Handle demo servers and refresh
TODO
Containers docs
Here is a few information about the Dockerfile we wrote for each deployed repository.
- frontend (deployed on app.delibay.org)
- backend (deployed on several subdomains)
- website (deployed on delibay.org)