Docker-Compose with App and DB Service
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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}
|
||||
Reference in New Issue
Block a user