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"
|
DATABASE_URL: "postgresql://user:password@db:5432/urlshort"
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
|
networks: backend
|
||||||
|
networks:
|
||||||
|
backend:
|
||||||
|
driver: Bridge
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
db_data:
|
||||||
|
|
||||||
db:
|
db:
|
||||||
image: postgres:16
|
image: postgres:alpine
|
||||||
container_name: url_db
|
container_name: url_db
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
@@ -19,6 +26,4 @@ services:
|
|||||||
POSTGRES_DB: urlshort
|
POSTGRES_DB: urlshort
|
||||||
volumes:
|
volumes:
|
||||||
- db_data:/var/lib/postgresql/data
|
- db_data:/var/lib/postgresql/data
|
||||||
|
networks: backend
|
||||||
volumes:
|
|
||||||
db_data:
|
|
||||||
|
|||||||
@@ -5,9 +5,4 @@ app = FastAPI()
|
|||||||
|
|
||||||
@app.get("/health/{Status}")
|
@app.get("/health/{Status}")
|
||||||
def get_health(Status: int, q: str = "ok"):
|
def get_health(Status: int, q: str = "ok"):
|
||||||
return {"Health": Status, "Status": q}
|
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