From a84d6b66cdd3396ead742313c0cdd4ac0a672b49 Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Mon, 9 Feb 2026 14:16:38 +0100 Subject: [PATCH] feat: bootstrap backend with docker and healthcheck --- .env | 3 +++ backend/Dockerfile | 10 ++++++++++ backend/app/main.py | 7 +++++++ backend/requirements.txt | 5 +++++ docker-compose.yml | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 59 insertions(+) create mode 100644 .env create mode 100644 backend/Dockerfile create mode 100644 backend/app/main.py create mode 100644 backend/requirements.txt create mode 100644 docker-compose.yml diff --git a/.env b/.env new file mode 100644 index 0000000..c60c381 --- /dev/null +++ b/.env @@ -0,0 +1,3 @@ +POSTGRES_USER=postgres +POSTGRES_PASSWORD=postgres +POSTGRES_DB=card_game_db diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..52f2acb --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,10 @@ +FROM python:3.11-slim + +WORKDIR /app + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/backend/app/main.py b/backend/app/main.py new file mode 100644 index 0000000..2f309e7 --- /dev/null +++ b/backend/app/main.py @@ -0,0 +1,7 @@ +from fastapi import FastAPI + +app = FastAPI(title="Card Game Backend") + +@app.get("/health") +def health_check(): + return {"status": "ok"} diff --git a/backend/requirements.txt b/backend/requirements.txt new file mode 100644 index 0000000..3c2e4dd --- /dev/null +++ b/backend/requirements.txt @@ -0,0 +1,5 @@ +fastapi +uvicorn +sqlalchemy +psycopg2-binary +asyncpg diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c989350 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,34 @@ +version: '3.8' + +services: + backend: + build: ./backend + ports: + - "8000:8000" + environment: + - DB_HOST=postgres + - DB_USER=${POSTGRES_USER} + - DB_PASS=${POSTGRES_PASSWORD} + - DB_NAME=${POSTGRES_DB} + depends_on: + - postgres + networks: + - card-game-network + + postgres: + image: postgres:15-alpine + environment: + - POSTGRES_USER=${POSTGRES_USER} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} + - POSTGRES_DB=${POSTGRES_DB} + volumes: + - postgres_data:/var/lib/postgresql/data + networks: + - card-game-network + +networks: + card-game-network: + driver: bridge + +volumes: + postgres_data: