Boilerplate code for quick docker implementation of REST API with JWT Authentication using FastAPI, PostgreSQL and PgAdmin.
Report Bug
To get a local copy up and running follow these simple steps.
Install Docker and docker-compose
- Docker - Click here for installation steps for Ubuntu.
- docker-compose - Click here to Install by selecting Linux tab in the page.
- Create a copy of
api/.env
file fromapi/.env.template
and update all the parameters.
- Clone the repo
git clone https://github.com/reddimohan/FastAPI-RestAPI-PostgreSQL-PgAdmin-Authentication-docker.git
- Install Docker and docker-compose - links provided above
- Go to project folder and Build the docker images
docker-compose build
- Bring up the docker-compose to access the API
docker-compose up -d # It brings up the all services in the docker-compose.yaml including postgres and pgadmin
- You can access the Rest Service and PgAdmin GUI using below ports
docker ps # It gives the list of running containers with their ports
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2ab9e521b530 fastapi-restapi-postgresql-pgadmin-authentication-docker_server "uvicorn main:app --…" 5 minutes ago Up 5 minutes 0.0.0.0:9000->8000/tcp api_service
57ecb3d87421 dpage/pgadmin4 "/entrypoint.sh" 5 minutes ago Up 5 minutes 443/tcp, 0.0.0.0:5050->80/tcp pgadmin
ab8487f8a0a7 postgres:12 "docker-entrypoint.s…" 5 minutes ago Up 5 minutes 0.0.0.0:5499->5432/tcp postgres_db
- API - http://0.0.0.0:9000/docs
- PgAdmin - http://0.0.0.0:5050
docker-compose up -d # It brings up the all services in the docker-compose.yaml including postgres
# Locate docker-compose.yaml file and go to that directory
docker-compose down
docker-compose run pgdb bash # to bring up the terminal
psql --host=pgdb --username=<username> --dbname=<password>
You can find the host
username
password
from the .env
file which should be configured in first place
# Postgres
POSTGRES_USER=<username>
POSTGRES_PASSWORD=<password>
POSTGRES_DB=<db_name>
See the open issues for a list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
Project Link: https://github.com/reddimohan/FastAPI-RestAPI-PostgreSQL-PgAdmin-Authentication-docker