🌐 🎨
Verden This software is part of a project for the Web Programming course at UNICT.
Configuration to set up before starting:
- Create a PostgreSQL database.
- Generate a good secret string for JWT.
- [ Optional ] Create a Sentry project
Variables with values as example:
JWT_SECRET=foobar
DATABASE_URL=postgres://user:password@localhost:5432/verden
PAGE_LIMIT=20
SAVE_FILE_BASE_PATH="./uploads"
UPLOADS_ENDPOINT="/uploads"
RUST_LOG=verden=debug,tower_http=debug
ALLOWED_HOST=localhost:3000
SENTRY_DSN=.... # Optional
Deploy
This is a guide for a good deploy on a Dokku server, which deploys Verden on port 9090.
Dockerfile defines a DATABASE_URL
argument by default cause sqlx
dependence
but, if you define the environment variabile, it will use the one you defined on
dokku config
.
- Log into the server and create a new app
dokku apps:create verden-api
- Create the database and link it to the app.
DATABASE_URL
automatically setdokku postgres:create verden-api # Database has got the same app name dokku postgres:link verden-api verden-api
- Create a storage where uploads will be located
mkdir -p /var/lib/dokku/data/storage/verden-api/uploads/ dokku storage:mount verden-api /var/lib/dokku/data/storage/verden-api/uploads:/storage/uploads
- Set config vars
dokku config:set verden-api JWT_SECRET=foobar dokku config:set verden-api PAGE_LIMIT=20 dokku config:set verden-api SAVE_FILE_BASE_PATH=/storage/uploads dokku config:set verden-api UPLOADS_ENDPOINT=/uploads dokku config:set verden-api RUST_LOG=verden=debug,tower_http=debug dokku config:set verdena-pi ALLOWED_HOST=0.0.0.0:9090 dokku config:set verdena-pi SENTRY_DSN=https://example@example.ingest.sentry.io/42
- Fix ports for HTTP
dokku proxy:ports-add verden-api http:80:9090 dokku proxy:ports-remove verden-api http:9090:9090
- Add a remote and push this code
git remote add dokku dokku_user@your_server:verden-api git push dokku main
- Install Let's Encrypt
sudo dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git dokku config:set --no-restart verden-api DOKKU_LETSENCRYPT_EMAIL=your_email dokku letsencrypt:enable verden-api
- Log in the app and run migrate
dokku enter verden-api sqlx migrate run
- Enjoy Verden at
https://verden-api.<your-server>