This project relies on enriching static pages served from the rust backend with an vue app for the editor component. To do so, we use webpack to build a production ready version of the vue app, which our backend then picks up as a template.
-
Create a
.envfile at the repository root. Have a look at.env.exampleto see how this file might look like You can generate a suitable secret key withopenssl rand -base64 32. -
To start the backend in the background run
docker compose up -dIf you want to rebuild the docker images add --build
- You can stop the backend with
docker compose downAs an alternative to using Docker Compose you can setup your development environment as follows.
-
Create a new PostgreSQL database
-
Update
Rocket.tomlwith your database URL
[global.databases.hci_bildung]
url = "<your URL here>"- The database will be initialized by the Diesel migrations, which run automatically when the backend starts. If you want to use the Diesel CLI, you have to set
DATABASE_URLin your.envfile.
- For production builds: Set a secret key for encrypted cookies. This can be done in
Rocket.tomlor using the environment variableROCKET_SECRET_KEY
[release]
secret_key="<your secret key here>"You can generate a suitable key with openssl rand -base64 32.
- Further configuration can be done via
Rocket.tomlor environment variables as described in the Rocket docs
- Navigate to the
vuedirectory
cd vue- Install node dependencies
npm install- Build vue app
npm run buildThis should produce the directory vue_dist at the root of the repository.
The directory contains the file sheet.html.tera, which our backend loads as template, and the directory vue containing the assets.
After starting the backend, the vue directory is available at /vue enabling the vue app to load its assets correctly.
- Navigate back to the repository root, so if you previously built the frontend do
cd ..- Launch the backend with
cargo run
The backend serves additional assets from the assets directoy at /assets.
All commands in this section have to be executed from the vue directory.
For more convenient development of the vue app run
npm run serveThis will start a development server with hot-reloads for the vue app only.
To lint and fix files run
npm run lint