version: '3.8'

services:
  php:
    build:
      context: .
      dockerfile: Dockerfile.prod
    container_name: saasinfo_php_prod
    working_dir: /var/www/html
    volumes:
      - ./public/uploads:/var/www/html/public/uploads
      - ./var:/var/www/html/var
    depends_on:
      - db
    environment:
      - APP_ENV=prod
      - APP_DEBUG=false
    networks:
      - saasinfo_network_prod
    restart: unless-stopped

  nginx:
    image: nginx:alpine
    container_name: saasinfo_nginx_prod
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./public:/var/www/html/public:ro
      - ./docker/nginx/nginx.prod.conf:/etc/nginx/conf.d/default.conf:ro
      - ./docker/nginx/ssl:/etc/nginx/ssl:ro
    depends_on:
      - php
    networks:
      - saasinfo_network_prod
    restart: unless-stopped

  db:
    image: mysql:8.0
    container_name: saasinfo_mysql_prod
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MYSQL_USER: ${MYSQL_USER}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
    volumes:
      - db_data_prod:/var/lib/mysql
    networks:
      - saasinfo_network_prod
    restart: unless-stopped
    command: --default-authentication-plugin=mysql_native_password

volumes:
  db_data_prod:

networks:
  saasinfo_network_prod:
    driver: bridge

