Skip to content

reddimohan/FastAPI-RestAPI-PostgreSQL-PgAdmin-Authentication-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn


FastAPI + PostgreSQL + PgAdmin + JWT Authentication + Docker-Compose

Boilerplate code for quick docker implementation of REST API with JWT Authentication using FastAPI, PostgreSQL and PgAdmin.

Report Bug

Table of Contents

About The Project

https://reddimohan.github.io

Built With

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites - Ubuntu

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 from api/.env.template and update all the parameters.

Installation

  1. Clone the repo
git clone https://github.com/reddimohan/FastAPI-RestAPI-PostgreSQL-PgAdmin-Authentication-docker.git
  1. Install Docker and docker-compose - links provided above
  2. Go to project folder and Build the docker images
docker-compose build
  1. 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
  1. 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

Now API and PgAdmin can be accessed from 9000 and 5050, mentioned below

Docker Commands for debugging

Bring up the all containers
docker-compose up -d # It brings up the all services in the docker-compose.yaml including postgres
Bring down the all containers which stops API service, postgresql and pgadmin
# Locate docker-compose.yaml file and go to that directory
docker-compose down
Login to postgres container
docker-compose run pgdb bash # to bring up the terminal
Connect to database database in console after Login to postgres container
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>

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

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.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Mohan - LinkedIn - Twitter

Project Link: https://github.com/reddimohan/FastAPI-RestAPI-PostgreSQL-PgAdmin-Authentication-docker

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published