services:
  db:
    image: mariadb:11
    container_name: tempmail-db
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: rootpassword
      MYSQL_DATABASE: tempmail
      MYSQL_USER: tempmail
      MYSQL_PASSWORD: secret
    ports:
      - "3306:3306"
    volumes:
      - db_data:/var/lib/mysql
      - ./database/schema.sql:/docker-entrypoint-initdb.d/01-schema.sql
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      interval: 10s
      timeout: 5s
      retries: 5

  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    container_name: tempmail-backend
    restart: unless-stopped
    depends_on:
      db:
        condition: service_healthy
    environment:
      APP_NAME: TempMail
      APP_ENV: production
      APP_DEBUG: "false"
      APP_URL: http://localhost:8080
      APP_KEY: base64:YOUR_APP_KEY_HERE
      DB_CONNECTION: mysql
      DB_HOST: db
      DB_PORT: 3306
      DB_DATABASE: tempmail
      DB_USERNAME: tempmail
      DB_PASSWORD: secret
      JWT_SECRET: change-this-to-a-random-secret-key
      ADMIN_USERNAME: admin
      ADMIN_PASSWORD: admin123
    ports:
      - "8080:8080"

  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
    container_name: tempmail-frontend
    restart: unless-stopped
    depends_on:
      - backend
    ports:
      - "3000:80"

volumes:
  db_data:
