Docker-Compose with App and DB Service

This commit is contained in:
2026-03-06 12:39:02 +01:00
parent bed9cc862e
commit 51ac6ca045
2 changed files with 10 additions and 10 deletions

View File

@@ -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

View File

@@ -6,8 +6,3 @@ 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}