Directus is the content management system used for the website, as well as a few other services. It is ran in a separate Docker container.
The services requiring it use git submodules, this directly importing the directus-config repository into their own.
Important
If you are running directus as part of another service, the shell script will be located in the directus submodule, or as aliases in the npm run ---. The command to boot the instance will also be different, see this document.
First, copy the .env.example file to .env and, if needed, update the SMTP_IT_PASSWORD and MAIL_SENDER_SECRET variables with their actual values (see the vaultwarden). Then, use docker compose up to boot up a local instance. Then, you can import the data schema using sh load.sh and populate it using sample data with sh populate.sh. You only need to do this once, or if you have deleted Directus' data volume.
You can access the admin panel at http://localhost/directus (username: clic@epfl.ch, password: 1234). There, you can update the data, or modify the schema (see below).
To fully reset your local instance, first stop it using docker compose down. Then, identify the database volume that you are using with docker volume ls, it will have the name <project>_directus-data (e.g. clicketing_directus-data). Now, start again the instance (docker compose up).
If you wish to change the schema or update/add flows, you can do it on your local instance admin panel, then export it using sh save.sh. It will create a snapshot.yaml file in the same folder as well as a flows.sql. After merging these changes into the main branch, the directus stack on the server should be restarted (see the wiki).
You may also want to update the sample data: the files are automatically saved in uploads/, and you can generate a dump of Directus' database using sh save-data.sh, which will write into new-dump.sql. Then, copy the relevant insertions in the dump.sql (take care of the order, to avoid constraint error during populate).
If you wish to integrate Directus into a new project, you need to:
-
Add the submodule:
git submodule add https://github.com/clicepfl/directus-config.git directus -
Add the following scripts to the
package.json:{ "scripts": { "prepare": "git submodule update --init", "load-directus": "sh directus/load.sh", "save-directus": "sh directus/save.sh", "save-directus-data": "sh directus/save-data.sh", "populate-directus": "sh directus/populate.sh" } } -
Include the local instance in the developpment Docker Compose file:
include: - path: directus/docker-compose.yaml
-
Create a symbolic link for the types declarations (from your
src/folder):ln -sr <relative-path-of-directus-submodule>/types types