version: '3.8'

services:
  newsflow:
    build: .
    ports:
      - "5000:5000"
    environment:
      - NODE_ENV=production
      - DATABASE_URL=mysql://newsflow_user:your_password@mysql:3306/newsflow
      - MYSQL_HOST=mysql
      - MYSQL_USER=newsflow_user
      - MYSQL_PASSWORD=your_password
      - MYSQL_DATABASE=newsflow
      - OPENAI_API_KEY=${OPENAI_API_KEY}
      - SESSION_SECRET=${SESSION_SECRET}
      - REPL_ID=${REPL_ID}
      - REPLIT_DOMAINS=${REPLIT_DOMAINS}
      - ISSUER_URL=${ISSUER_URL}
    depends_on:
      mysql:
        condition: service_healthy
    restart: unless-stopped

  mysql:
    image: mysql:8.0
    environment:
      - MYSQL_ROOT_PASSWORD=root_password
      - MYSQL_DATABASE=newsflow
      - MYSQL_USER=newsflow_user
      - MYSQL_PASSWORD=your_password
    volumes:
      - mysql_data:/var/lib/mysql
      - ./init.sql:/docker-entrypoint-initdb.d/init.sql
    ports:
      - "3306:3306"
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      timeout: 20s
      retries: 10
    restart: unless-stopped

volumes:
  mysql_data: