From 51ac6ca045c3f9f7b9941130f741e7a97b836f0a Mon Sep 17 00:00:00 2001 From: ruslan Date: Fri, 6 Mar 2026 12:39:02 +0100 Subject: [PATCH] Docker-Compose with App and DB Service --- docker-compose.yaml | 13 +++++++++---- src/app/main.py | 7 +------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 8369adc..f1a24ef 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -8,9 +8,16 @@ services: DATABASE_URL: "postgresql://user:password@db:5432/urlshort" depends_on: - db + networks: backend + networks: + backend: + driver: Bridge + +volumes: + db_data: db: - image: postgres:16 + image: postgres:alpine container_name: url_db restart: always environment: @@ -19,6 +26,4 @@ services: POSTGRES_DB: urlshort volumes: - db_data:/var/lib/postgresql/data - -volumes: - db_data: + networks: backend diff --git a/src/app/main.py b/src/app/main.py index e337130..89785e6 100644 --- a/src/app/main.py +++ b/src/app/main.py @@ -5,9 +5,4 @@ app = FastAPI() @app.get("/health/{Status}") def get_health(Status: int, q: str = "ok"): - return {"Health": Status, "Status": q} - - -@app.get("/items/{item_id}") -def read_item(item_id: int, q: str | None = None): - return {"item_id": item_id, "q": q} \ No newline at end of file + return {"Health": Status, "Status": q} \ No newline at end of file