groceries/docker-compose.yml
2025-05-26 21:55:49 +02:00

73 lines
1.7 KiB
YAML

version: '3.8'
services:
# PostgreSQL Database
db:
image: postgres:15-alpine
container_name: groceries_db
environment:
POSTGRES_DB: product_tracker
POSTGRES_USER: product_user
POSTGRES_PASSWORD: ${DB_PASSWORD:-secure_password_123}
volumes:
- postgres_data:/var/lib/postgresql/data
- ./init-db.sql:/docker-entrypoint-initdb.d/init-db.sql:ro
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U product_user -d product_tracker"]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
# FastAPI Backend
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: groceries_backend
environment:
DATABASE_URL: postgresql://product_user:${DB_PASSWORD:-secure_password_123}@db:5432/product_tracker
SECRET_KEY: ${SECRET_KEY:-your-super-secret-key-change-this-in-production}
ALGORITHM: HS256
ACCESS_TOKEN_EXPIRE_MINUTES: 30
DEBUG: ${DEBUG:-False}
ports:
- "8000:8000"
depends_on:
db:
condition: service_healthy
volumes:
- ./backend:/app
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/docs"]
interval: 30s
timeout: 10s
retries: 3
# React Frontend
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: groceries_frontend
ports:
- "80:80"
depends_on:
- backend
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:80"]
interval: 30s
timeout: 10s
retries: 3
volumes:
postgres_data:
driver: local
networks:
default:
name: groceries_network