feat: bootstrap backend with docker and healthcheck

This commit is contained in:
2026-02-09 14:16:38 +01:00
commit a84d6b66cd
5 changed files with 59 additions and 0 deletions

3
.env Normal file
View File

@@ -0,0 +1,3 @@
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=card_game_db

10
backend/Dockerfile Normal file
View File

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

7
backend/app/main.py Normal file
View File

@@ -0,0 +1,7 @@
from fastapi import FastAPI
app = FastAPI(title="Card Game Backend")
@app.get("/health")
def health_check():
return {"status": "ok"}

5
backend/requirements.txt Normal file
View File

@@ -0,0 +1,5 @@
fastapi
uvicorn
sqlalchemy
psycopg2-binary
asyncpg

34
docker-compose.yml Normal file
View File

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