version: '3.8' services: db: image: postgres:15-alpine environment: POSTGRES_DB: memory_tracker POSTGRES_USER: memory_tracker_user POSTGRES_PASSWORD: memory_tracker_password volumes: - postgres_data:/var/lib/postgresql/data ports: - "5432:5432" healthcheck: test: ["CMD-SHELL", "pg_isready -U memory_tracker_user -d memory_tracker"] interval: 10s timeout: 5s retries: 5 restart: unless-stopped backend: build: context: ./backend dockerfile: Dockerfile env_file: - .env environment: DATABASE_URL: postgresql+asyncpg://memory_tracker_user:memory_tracker_password@db:5432/memory_tracker ports: - "8000:8000" depends_on: db: condition: service_healthy volumes: # Mount the scripts directory to run initialization - ./backend/scripts:/app/scripts:ro healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8000/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s restart: unless-stopped frontend: build: context: ./frontend dockerfile: Dockerfile args: NEXT_PUBLIC_API_BASE: http://localhost:8000 environment: NEXT_PUBLIC_API_BASE: http://localhost:8000 ports: - "3000:3000" depends_on: backend: condition: service_healthy healthcheck: test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/"] interval: 30s timeout: 10s retries: 3 start_period: 40s restart: unless-stopped # Service to initialize the database with default binaries db-init: build: context: ./backend dockerfile: Dockerfile env_file: - .env environment: DATABASE_URL: postgresql+asyncpg://memory_tracker_user:memory_tracker_password@db:5432/memory_tracker depends_on: backend: condition: service_healthy command: > sh -c " echo 'Waiting for backend to be ready...' && sleep 10 && echo 'Populating database with default binaries...' && python scripts/populate_binaries.py && echo 'Database initialization complete!' " restart: "no" volumes: postgres_data: networks: default: name: memory_tracker_network