docs/multidomain.md
# Wellms Single or Multi Domain API Mode.
Wellms API is working in two modes, either
- single domain or catch all domains to one service
- multiple domains to each service (different database, buckets, settings etc)
Multi-domain is controlled by environmental variables and usage of [gecche/laravel-multidomain](https://github.com/gecche/laravel-multidomain)
Please not that this API is based on Laravel but it's configured by environmental variables.
Please don't create or edit any `.env` files but use environmental variables only with `LARAVEL_` prefix, see [docker-compose.yml](../docker-compose.yml) and [docs/enviromental-variables.md](enviromental-variables.md) for reference.
As we want this app to be **stateless and easy to scale** so all configuration is stored either in database or in environmental variables, not inside `.env` or `storage` folder.
Configuration and files are stored only in
- environmental variables
- database
- s3 compatible buckets, eg s3, minIO etc.
## How it works. Example
There is no better documentation than example, aka "specification by example".
### Single domain API.
Launch Wellms api as usual with, eg `docker compose up -d` with `docker-compose.yml` package from [this repository](https://github.com/EscolaLMS/API) - now single domain wellms is working, as you can check under http://api.localhost
This tutorial assumes that all `*.localhost`, `*.admin.localhost` and `*.app.localhost` addressed are forwarded to `127.0.0.1`, if this doesn't work on your machine you need to manually add each record for each domain in your `/etc/hosts` file.
### Single domain
Launch application with default setting by cloning [API repository](https://github.com/EscolaLMS/API).
First install dependencies
```bash
docker compose run escola_lms_app composer install --ignore-platform-reqs --no-scripts
```
then run the application
```bash
docker compose up -d
```
in case of any unexpected error try to restart whole stack
```bash
docker compose stop
docker compose up -d
```
Url [http://api.localhost/api/name](http://api.localhost/api/name) should return "Application Name: Wellms" and URL [http://api.localhost/api/courses](http://api.localhost/api/courses) JSON with courses, yet empty list by default.
Lets test it with Admin panel
Go to url [http://api.admin.localhost/](http://api.admin.localhost/) use credentials `admin@escolasoft.com` and password `secret` (this refers to env variables `INITIAL_USER_EMAIL` and `INITIAL_USER_PASSWORD`)
Go to URL [http://api.app.localhost/#/](http://api.app.localhost/#/) to see demo of your data.
There isn't much content but if you want to generate some run command
```bash
docker compose run escola_lms_app php artisan db:seed --class=FullDatabaseSeeder
```
This command generate lots of testing content but it takes few minutes to finish.
That's it!! You can attach you first front to this headless LMS.
### Debugging
- check all docker logs, specially Caddy, and php.
To debug you can also use tools:
- [adminer](https://www.adminer.org/) to check whats in the database [http://localhost:8078/](http://localhost:8078/). Use credentials from env vars to login, by default those are Database Type: Postgres, Server: postgres, username: default, password: secret, database: default
- [MailHog](https://github.com/mailhog/MailHog) to simulate email sending. [http://localhost:8025/](http://localhost:8025/)
- [MinIO](https://min.io/) to check your Object Store CDN http://minio.localhost/ Use credentials from env vars to login, by default those are username: admin, password: minio_secretpassword
### Multidomain. `multidomain` helper tool.
Enter docker bash with `make bash` now do
```bash
make bash
cd multidomain-tool
composer install
```
Then you need to get to know some variables
- `AWS_ROOT_ACCESS_KEY_ID` refers to root username to MinIO, default `admin`
- `AWS_ROOT_SECRET_ACCESS_KEY` refers to root password to MinIO, default `minio_secretpassword`
- `AWS_ENDPOINT` refers to internal minio ui accessible from docker image, default `http://minio:9000`
- `AWS_API_ENDPOINT` refers to internal minio api accessible from docker image, default `http://minio:9001`
- `AWS_URL_PREFIX` refers to external minio storage address, default `http://storage.localhost` (reversed proxy by Caddy)
- `DB_ROOT_HOST` default `postgres`
- `DB_ROOT_PORT` default `5432`
- `DB_ROOT_USERNAME` default `default`
- `DB_ROOT_PASSWORD` default `secret`
once you know those you can run multidomain helper
```bash
AWS_ROOT_ACCESS_KEY_ID=admin \
AWS_ROOT_SECRET_ACCESS_KEY=minio_secretpassword \
AWS_ENDPOINT=http://minio:9000 \
AWS_API_ENDPOINT=http://minio:9001 \
AWS_URL_PREFIX=http://storage.localhost \
DB_ROOT_HOST=postgres \
DB_ROOT_PORT=5432 \
DB_ROOT_USERNAME=default \
DB_ROOT_PASSWORD=secret \
./multidomain add api$RANDOM.localhost,api$RANDOM.localhost,api$RANDOM.localhost
```
where `api$RANDOM.localhost` will generate a random `api[0 - 32767].localhost address`, so command above is going to generate enviromental variables for 3 random domains.
or you can skin the randomness and use 1,2,3
```bash
AWS_ROOT_ACCESS_KEY_ID=admin \
AWS_ROOT_SECRET_ACCESS_KEY=minio_secretpassword \
AWS_ENDPOINT=http://minio:9000 \
AWS_API_ENDPOINT=http://minio:9001 \
AWS_URL_PREFIX=http://storage.localhost \
DB_ROOT_HOST=postgres \
DB_ROOT_PORT=5432 \
DB_ROOT_USERNAME=default \
DB_ROOT_PASSWORD=secret \
./multidomain add api1.localhost,api2.localhost,api3.localhost
```
The result will be something like
```bash
#...more lines for code...
Use those values for adding new domain
Pass them into Docker Container Enviroment Variables
-------------
API17005_LOCALHOST_INITIAL_USER_PASSWORD=9324c2719ed6bc4f
API17005_LOCALHOST_AWS_ACCESS_KEY_ID=api17005localhost
#... long list of variables ...
#... long list of variables ...
#... long list of variables ...
MULTI_DOMAINS=api17005.localhost,api16576.localhost,api22800.localhost
If you forgot to copy those above, don't worry they are saved to /var/www/html/multidomain-tool/build/api17005.localhost,api16576.localhost,api22800.localhost.env
```
New lets add those values into docker yaml setup, create a file `docker-compose.saas.yml`
```yaml
services:
escola_lms_app:
command: "./init.sh"
environment:
- API17005_LOCALHOST_AWS_ACCESS_KEY_ID=api17005localhost
- API17005_LOCALHOST_AWS_SECRET_ACCESS_KEY=4c58fa42cab44240
- API17005_LOCALHOST_AWS_BUCKET=api17005localhost
- API17005_LOCALHOST_AWS_URL=http://storage.localhost/api17005localhost
- API17005_LOCALHOST_DB_DATABASE="api17005_localhost"
- API17005_LOCALHOST_DB_USERNAME="api17005_localhost"
- API17005_LOCALHOST_DB_PASSWORD=9324c2719ed6bc4f
- API17005_LOCALHOST_JWT_PUBLIC_KEY_BASE64=LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0NCk1JSUNJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBZzhBTUlJQ0NnS0NBZ0VBdzkzaG4vQWNkZkhVZURjSlhielcNCnhHR1dxc1dMU2dWL0lhYUVwODdzdzFsT0h2QnZ2RTVhMUxNYjVJSmQ4VnV6bjFEREc1cVJFRmlpTHpSV09valoNCkhscGtqeit0T1BpVjltU044OTlWU1lLZmVz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0KLS0tLS1FTkQgUFJJVkFURSBLRVktLS0tLQ==
- API16576_LOCALHOST_AWS_ACCESS_KEY_ID=api16576localhost
- API16576_LOCALHOST_AWS_SECRET_ACCESS_KEY=2a45e8263e3d4906
- API16576_LOCALHOST_AWS_BUCKET=api16576localhost
- API16576_LOCALHOST_AWS_URL=http://storage.localhost/api16576localhost
- API16576_LOCALHOST_DB_DATABASE="api16576_localhost"
- API16576_LOCALHOST_DB_USERNAME="api16576_localhost"
- API16576_LOCALHOST_DB_PASSWORD=5d654cd64fe1de1d
- API16576_LOCALHOST_JWT_PUBLIC_KEY_BASE64=LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0NCk1JSUNJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBZzhBTUlJQ0NnS0NBZ0VBc1lZTmozd0R3MU5CY2tRazIzL3YNCnAyOUY5RTN2WnU4U0EySnBQWGdRYnA4OG56eDJZdXQyMnkzZmFqcHRmNUhMc1NtU215MCtsRy81NjBDQTBJTUENCkU4ZkQyTDZac1l5ekw2cjdMTHM0RWVXVW1JdERkTFQ3WVRwcVIzaDFZSFQyTWZyOHlEOVBaRy80cXRSZ1VZK1cNCnJHdnNnbzNrWC9oeHhLaWEzZ1hOOStmREJYS1pvamdTUkJKUjh6Skc1SGZjMTAwKzNxL2xyYnZxckx1VWhmWnINCklsTEtlWmViQXozaVV6d3pjZTNEZFZ3NVdFN0dMaWpYNW5nV1k4NGUwNVZQQ05QR2VDS3gxc0x1RGpyRFNBUkENCnE4QmFCWkRxTjZkOTNkMjA2bDR5bXJDYy9WS1BvaGFTeVc4TVJvQklnN2FFQXZNSnhxSGFRbG9uWjZaeElseVENCkR1UmIwR0NzMWJSVSs2dyt2ek9Tb1FkNHp6N2ZsRW5Lc0JsYmM1YmRiQ2xNRHEvaUlueFc5NTFKMWUzVlNINzYNCklFZG5vb0pjcERRbzJML1kwWWU4Mm16cDdURVRMTmtFSERKZEt5bFVLYnJ5N0NJeFZxVXRjcms4Q0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heU0ySzNJUmhwcTNSNWo2blJ4TUJwMEZIVzZIR2l2YU1XR0hoR21YQUp6QlVES3drL2xPM2hmDQpLdDBDZ2dFQUJLT3J4aytIYlRzY2RKNFptZVpMa0VBNURlaGptS2NnYUhPWEhTcERYNFlMMDRvTXRvUWpiMVNtDQpCZERUSjdqK05zaURuQWpDNzdpWFdZL1BwSC9McU5WQm5ycHZqZ1NpTThNWEs5ZkZoa1hDTCtNT0RRSTkxT2htDQpMQ1FKS21VT09PRW5CWGZIRjM3cVNjZkwzNitiV1lmYk1lTWhhbWJrZXNNTnhCS1VYTGl5UXBWOXJ2RjdTZlQ2DQpnUm44SHZ5Tmo2amRnM1hvMmNwUkZVUzhMeHR2SmlNWjg1RGYydGtaZXEwL3NaZVNRUTBLRXU0UjBOQTNFU3NLDQpxdlN5dlBFaVhMWmJmZEUzOWliZHdEQ296OUlUUTlRdnlzZys2RlZVYUorZks5a2hTMW5pZmdEOWdEcEM0aW42DQoxK2VQL0s1ZXY1ZERFVG1XdlVSZ3FQT1ZmaUprOXc9PQ0KLS0tLS1FTkQgUFJJVkFURSBLRVktLS0tLQ==
- API22800_LOCALHOST_AWS_ACCESS_KEY_ID=api22800localhost
- API22800_LOCALHOST_AWS_SECRET_ACCESS_KEY=f870d2d611b5f818
- API22800_LOCALHOST_AWS_BUCKET=api22800localhost
- API22800_LOCALHOST_AWS_URL=http://storage.localhost/api22800localhost
- API22800_LOCALHOST_DB_DATABASE="api22800_localhost"
- API22800_LOCALHOST_DB_USERNAME="api22800_localhost"
- API22800_LOCALHOST_DB_PASSWORD=ebb3c69a8d76d593
- API22800_LOCALHOST_JWT_PUBLIC_KEY_BASE64=LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0NCk1JSUNJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBZzhBTUlJQ0NnS0NBZ0VBNVE1QnFSMXlZaC9TT1diZGNFbHYNCjhXR1lwMXU2VFZQVUQwbzNoQW9CcjdEZ3hXanNCYkg2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GpjMXZpQ1FwdCtHZnFORGppUkhabEVYM0pxRUdMelBVdHkzUVRTDQpWODZ4K29KZEZQSHpNQ1g2eHZTM1BiYXJvSHVNWGc9PQ0KLS0tLS1FTkQgUFJJVkFURSBLRVktLS0tLQ==
- API22800_LOCALHOST_INITIAL_USER_PASSWORD=9324c2719ed6bc4f
- API16576_LOCALHOST_INITIAL_USER_PASSWORD=9324c2719ed6bc4f
- API17005_LOCALHOST_INITIAL_USER_PASSWORD=9324c2719ed6bc4f
- MULTI_DOMAINS=api17005.localhost,api16576.localhost,api22800.localhost
```
Now run the following command
```bash
docker compose -f docker-compose.yml -f docker-compose.saas.yml up -d
```
It takes few second for first run to use those variable effectively.
Each of the links for generated domain should work now and return same response "Application Name: Wellms"
- http://api17005.localhost/api/name
- http://api16576.localhost/api/name
- http://api22800.localhost/api/name
Now we want to see if our variables are actually working
Add the following variables to `docker-compose.saas.yml`
```yaml
- API17005_LOCALHOST_APP_NAME="App one"
- API16576_LOCALHOST_APP_NAME="App two"
- API22800_LOCALHOST_APP_NAME="App three"
```
Run `docker compose -f docker-compose.yml -f docker-compose.saas.yml up -d` again and wait until server is responding.
Now Each of the links for generated domain should work now and return different response "Application Name: App one", "Application Name: App two", etc
- http://api17005.localhost/api/name
- http://api16576.localhost/api/name
- http://api22800.localhost/api/name
### Admin panel
Lets add admin panel config for those new api endpoints.
Assuming we'll be using those domains for admin panel
- http://api17005.admin.localhost
- http://api16576.admin.localhost
- http://api22800.admin.localhost
we want to make sure that each admin panel is attached to correct api endpoint. Again we need to pass some environment variables, this time we'll create them manually
```yaml
- MULTI_DOMAINS=api17005.admin.localhost,api16576.admin.localhost,api22800.admin.localhost
- API16576_ADMIN_LOCALHOST_REACT_APP_API_URL=http://api16576.localhost
- API17005_ADMIN_LOCALHOST_REACT_APP_API_URL=http://api17005.localhost
- API22800_ADMIN_LOCALHOST_REACT_APP_API_URL=http://api22800.localhost
```
so first you need to pass list of domains, comma separated `MULTI_DOMAINS=api1104.admin.localhost,api6999.admin.localhost,api7438.admin.localhost` then you need to pass encrypted `REACT_APP_API_URL` variable, different for each domain.
Domain is translated `api17005.localhost` into key `API17005_ADMIN_LOCALHOST`. Formula is simple Uppercase + replace `.` or `-` with `_` then add additional `_` and name of variable to be passed.
```php
$domain_key = str_replace(['.', '-'], '_', strtoupper($domain));
```
Passing REACT_APP_API_URL=http://api17005.localhost to admin panel at domain http://api17005.admin.localhost would be passed as env `API17005_ADMIN_LOCALHOST_REACT_APP_API_URL=http://api17005.localhost`
add this code to `docker-compose.saas.yml`
```yaml
escola_lms_admin:
environment:
- MULTI_DOMAINS=api17005.admin.localhost,api16576.admin.localhost,api22800.admin.localhost
- API16576_ADMIN_LOCALHOST_REACT_APP_API_URL=http://api16576.localhost
- API17005_ADMIN_LOCALHOST_REACT_APP_API_URL=http://api17005.localhost
- API22800_ADMIN_LOCALHOST_REACT_APP_API_URL=http://api22800.localhost
```
run `docker compose -f docker-compose.yml -f docker-compose.saas.yml up -d` again and wait until server is responding.
Open [http://api17005.admin.localhost/#/user/login](http://api17005.admin.localhost/#/user/login) use credentials `admin@escolasoft.com` and password set in env `API17005_LOCALHOST_INITIAL_USER_PASSWORD`
Thats it - you can now add as many domains as you want, each have a separate configuration settings, bucket and database.
### Frontend
Most of advantages od headless comes with attaching API to your front. We have created a [React demo](https://github.com/EscolaLMS/Front) to showcase Wellms possibilities. It's deployed to docker images as well, using it it's very similar to Admin panel.
Add this code to `docker-compose.saas.yml`
```yaml
escola_lms_front:
environment:
- MULTI_DOMAINS=api17005.app.localhost,api16576.app.localhost,api22800.app.localhost
- API16576_APP_LOCALHOST_VITE_APP_API_URL=http://api16576.localhost
- API17005_APP_LOCALHOST_VITE_APP_API_URL=http://api17005.localhost
- API22800_APP_LOCALHOST_VITE_APP_API_URL=http://api22800.localhost
```
Now you have fully working react frontend at links below.
Assuming we'll be using those domains for each front, check all of you fronts attached to specific endpoint.
- http://api17005.app.localhost
- http://api16576.app.localhost
- http://api22800.app.localhost