This is a project template which uses FastAPI, PostgreSQL database and async SQLModel as ORM. This sample was designed to create a Benchmark of Fastapi and Rust when they get data from a database. You can check the results in the channel of Vagelis Prokopiou.
Create an .env file on root folder and copy the content from .env.example. Feel free to change it according to your own configuration.
Using docker compose command
docker compose -f docker-compose-dev.yml up --build
Using Makefile command
make run-dev-build
Using docker compose command
docker compose -f docker-compose-dev.yml up
Using Makefile command
make run-dev
This starts the server at http://localhost using nginx as reverse proxy. If you want a direct connection bypassing the proxy, you can use this url http://localhost:8000.
This creates sample users on database.
Using docker compose command
docker compose -f docker-compose-dev.yml exec fastapi_server python app/initial_data.py
Using Makefile command
make init-db
You can connect to the Database using pgAdmin4 and use the credentials from .env file. Database port on local machine has been configured to 5454 on docker-compose-dev.yml file
(Optional) If you prefer you can run pgAdmin4 on a docker container using the following commands, they should executed on different terminals:
Starts pgadmin
make run-pgadmin
Load server configuration (It is required just the first time)
make load-server-pgadmin
This starts pgamin in http://localhost:15432.
Using docker compose command
docker compose up
Using Makefile command
make run-prod
- This project is licensed under the terms of the MIT license