- Make sure Docker is installed and running
- Make sure sqlx cli is installed
- Create a
.env
file. This file will store environment variables. Specifically,DATABASE_URL
andPOSTGRES_PASSWORD
. It should look like this:DATABASE_URL=postgres://postgres:postgrespw@localhost:5432 POSTGRES_PASSWORD=postgrespw
NOTE:
When deploying the API, make sure to change the default PostgreSQL password. - Update
docker-compose.yml
and changeletsgetrusty
to your own Docker Hub username.
- Run an instance of PostgreSQL. This can be done via Docker:
docker pull postgres docker run --name example-db -e POSTGRES_PASSWORD=postgrespw -p 5432:5432 -d postgres
- Run SQL migrations:
sqlx migrate run
- Start server:
cargo run
- Test routes. I like to use Postman.
- Run API via Docker Compose:
docker-compose up
- Test routes. I like to use Postman.