version: '3.8'

services:
  # Apache + PHP サービス
  web:
    image: php:8.2-apache
    container_name: face_auth_web
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./:/var/www/html
      - /etc/letsencrypt:/etc/letsencrypt:ro
      - ./docker-config/apache/default-ssl.conf:/etc/apache2/sites-available/default-ssl.conf:ro
    environment:
      - DB_HOST=mysql
      - DB_NAME=xs5058_face
      - DB_USER=xs5058_wp1
      - DB_PASS=f6ycmqs1rd
    depends_on:
      - mysql
    networks:
      - face_auth_network
    restart: unless-stopped
    command: >
      bash -c "
      docker-php-ext-install pdo pdo_mysql mysqli &&
      a2enmod rewrite ssl headers &&
      a2ensite default-ssl &&
      apache2-foreground
      "

  # MySQL データベース
  mysql:
    image: mysql:8.0
    container_name: face_auth_mysql
    ports:
      - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: root_password_change_me
      MYSQL_DATABASE: xs5058_face
      MYSQL_USER: xs5058_wp1
      MYSQL_PASSWORD: f6ycmqs1rd
    volumes:
      - mysql_data:/var/lib/mysql
      - ./docker-config/mysql/init.sql:/docker-entrypoint-initdb.d/init.sql
    networks:
      - face_auth_network
    restart: unless-stopped

  # phpMyAdmin
  phpmyadmin:
    image: phpmyadmin:latest
    container_name: face_auth_phpmyadmin
    ports:
      - "8080:80"
    environment:
      PMA_HOST: mysql
      PMA_PORT: 3306
      PMA_USER: xs5058_wp1
      PMA_PASSWORD: f6ycmqs1rd
    depends_on:
      - mysql
    networks:
      - face_auth_network
    restart: unless-stopped

  # Python サービス（将来の拡張用）
  python:
    image: python:3.11-slim
    container_name: face_auth_python
    working_dir: /app
    volumes:
      - ./docker-config/python:/app
    command: tail -f /dev/null  # コンテナを起動状態に保つ
    networks:
      - face_auth_network
    restart: unless-stopped

  # Node.js サービス（将来の拡張用）
  nodejs:
    image: node:20-alpine
    container_name: face_auth_nodejs
    working_dir: /app
    volumes:
      - ./docker-config/nodejs:/app
    command: tail -f /dev/null  # コンテナを起動状態に保つ
    ports:
      - "3000:3000"
    networks:
      - face_auth_network
    restart: unless-stopped

networks:
  face_auth_network:
    driver: bridge

volumes:
  mysql_data:
