version: "3.8"

services:
  postgres:
    image: postgres:16-alpine
    container_name: notify-postgres
    restart: unless-stopped
    environment:
      POSTGRES_USER: notify
      POSTGRES_PASSWORD: notify_secret
      POSTGRES_DB: notify
    volumes:
      - postgres_data:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U notify -d notify"]
      interval: 5s
      timeout: 5s
      retries: 5

  backend:
    build:
      context: ./backend_rust
      dockerfile: Dockerfile
    container_name: notify-backend
    restart: unless-stopped
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      DATABASE_URL: postgresql://notify:notify_secret@postgres:5432/notify
      JWT_SECRET: ${JWT_SECRET:-change_me_in_production}
    ports:
      - "4000:4000"
    volumes:
      - uploads_data:/app/uploads

  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
    container_name: notify-frontend
    restart: unless-stopped
    depends_on:
      - backend
    environment:
      NEXT_PUBLIC_API_URL: http://backend:4000
    ports:
      - "3000:3000"

volumes:
  postgres_data:
  uploads_data:
