This repository contains a FastAPI application Dockerized for easy deployment and management. Follow the steps below to set it up:
- Docker and Docker Compose installed on your machine.
-
Clone the Repository:
git clone https://github.com/yourusername/your-repo.git
-
Navigate to the Project Directory:
cd your-repo -
Create a Virtual Environment:
python3 -m venv venv
-
Activate the Virtual Environment:
source venv/bin/activate -
Install Dependencies:
pip install -r requirements.txt
-
Build Docker Image:
docker-compose build
-
Start Docker Containers:
docker-compose up -d
This command will start the Docker containers in detached mode.
-
Access the FastAPI Application:
Once the containers are up and running, you can access the FastAPI application at http://localhost:8000.
-
Access PgAdmin:
You can also access PgAdmin on your browser at http://localhost:5050. Use the following credentials to log in:
- Username: admin@gmail.com
- Password: admin
Once you are logged in to PgAdmin, follow these steps to register the server:
- Click on the "Add New Server" icon or go to the "Servers" menu and select "Create" > "Server".
- In the "General" tab, enter a name for the server (e.g., "FastAPI PostgreSQL Server").
- In the "Connection" tab:
- Host name/address: Enter
fastapi-db, which is the container name defined in thedocker-compose.ymlfile. - Port: Keep the default port
5432. - Username: Enter
postgres. - Password: Enter
admin, as specified in the.envfile.
- Host name/address: Enter
- Click "Save" to register the server.
Now you should be able to access and manage the PostgreSQL server from PgAdmin.
-
Modify the
docker-compose.ymlfile and.envfile as needed for your specific environment. -
Make sure ports
8000,5050, and any other necessary ports are available and not being used by other services on your machine. -
Remember to deactivate the virtual environment once you're done working with the application:
deactivate
For more information on FastAPI, Docker, and PgAdmin, refer to their respective documentation: