This task involves deploying a FastAPI application using Docker. You will clone the application repository, set it up, and run it in a Docker container. Finally, you will verify the application's functionality and database connectivity.
-
Clone the Repository
git clone https://github.com/GoIT-Python-Web/FullStack-Web-Development-hw2 cd FullStack-Web-Development-hw2
-
Create a Dockerfile
- Create a
Dockerfile
with instructions to build the Docker image for the application.
- Create a
-
Write docker-compose.yaml
- Create a
docker-compose.yaml
file with the configuration for the application and PostgreSQL.
- Create a
-
Modify Database Connection
- Update the
SQLALCHEMY_DATABASE_URL
inconf/db.py
:SQLALCHEMY_DATABASE_URL = f"postgresql+psycopg2://postgres:567234@<postgres_service_name>:5432/hw02"
- Update the
-
Build and Run the Environment
docker-compose up
-
Verify Application Functionality
- Open your browser and check the application.
- Click the "Check DB" button to confirm database connectivity.