https://github.com/lesiaukr/goit-pythonweb-hw-02
Master's degree | Advanced Python Programming| HW | DOCKER fundamentals
https://github.com/lesiaukr/goit-pythonweb-hw-02
docker-compose fastapi-app goit-pythonweb-hw-02 postgresql python
Last synced: 8 months ago
JSON representation
Master's degree | Advanced Python Programming| HW | DOCKER fundamentals
- Host: GitHub
- URL: https://github.com/lesiaukr/goit-pythonweb-hw-02
- Owner: LesiaUKR
- Created: 2024-12-12T19:04:20.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-01-03T19:27:58.000Z (9 months ago)
- Last Synced: 2025-01-03T20:28:39.087Z (9 months ago)
- Topics: docker-compose, fastapi-app, goit-pythonweb-hw-02, postgresql, python
- Language: Python
- Homepage:
- Size: 413 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Task 2
Clone a FastAPI application, configure and run it in a Docker container, and check the application's functionality and database connection.
### Step-by-Step Instructions
1. Clone the repository at https://github.com/GoIT-Python-Web/Computer-Systems-hw02 using git clone and navigate to the cloned directory.
2. Create a Dockerfile with instructions to build the Docker image for the application.
3. Write a docker-compose.yaml file with the configuration for the application and PostgreSQL.
4. Use Docker Compose to build the environment and the docker-compose up command to launch the environment.
đź’ˇ Hint: Modify the SQLALCHEMY_DATABASE_URL connection string found in conf/db.py. Instead of localhost, insert the PostgreSQL service name from your docker-compose.yaml.
#### Example:
```python
SQLALCHEMY_DATABASE_URL = f"postgresql+psycopg2://postgres:567234@localhost:5432/hw02"
```When using Docker Compose, each service (container) has its own network, and they usually can’t communicate via localhost. Instead, use the service name as the hostname.
5. Verify the application’s functionality and the database’s availability.
đź’ˇ Hint:After running the container with the application, the browser view should appear as follows:

If correctly configured in docker-compose.yaml, pressing the “Check DB” button should display the following:
If you see a red error box instead of “Welcome to FastAPI!”, it means docker-compose.yaml is incorrectly configured.
### Acceptance Criteria
- The repository is cloned, and a Dockerfile for building the application’s Docker image is created.
- A docker-compose.yaml file is written with configuration for the application and PostgreSQL.
- Docker Compose and the docker-compose up command are used to build and run the environment.
- The application is functional, and the database is accessible, as confirmed by pressing the “Check DB” button.----
# TASK RESULTS



