services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./:/var/www/html3
      - ./docker/apache/custom.conf:/etc/apache2/conf-available/custom.conf
      - ./docker/apache/tracer.conf:/etc/apache2/sites-available/tracer.conf
      - ./docker/apache/vhost.conf:/etc/apache2/sites-available/vhost.conf
      - ./docker/apache/vtrahost.conf:/etc/apache2/sites-available/vtrahost.conf
      - ./docker/php/php.ini:/usr/local/etc/php/php.ini
      - ./pdflib-ext:/host-pdflib
      - ./setup-pdflib.sh:/usr/local/bin/setup-pdflib.sh
      - ./letsencrypt:/etc/letsencrypt  # 証明書を永続化
      - ./apache-sites:/etc/apache2/sites-available  # 設定も永続化
      - apache_logs:/etc/httpd
    environment:
      - TZ=Asia/Tokyo
      - APACHE_RUN_USER=mtstaff
      - APACHE_RUN_GROUP=mtstaff
    depends_on:
      - db
    restart: unless-stopped
    networks:
      - ddds-network


  db:
    image: mariadb:10.3
    ports:
      - "53306:3306"
    command: 
      --default-authentication-plugin=mysql_native_password
      --max_allowed_packet=512M
      --innodb_buffer_pool_size=1G
      --character-set-server=utf8mb4
      --collation-server=utf8mb4_unicode_ci
      --innodb_file_format=Barracuda
      --innodb_file_per_table=1  
      --innodb_large_prefix=1
      --innodb_strict_mode=0
      --wait_timeout=28800
      --interactive_timeout=28800
    environment:
      - MYSQL_DATABASE=dev_ddds_db
      - MYSQL_USER=ddds
      - MYSQL_PASSWORD=123456
      - MYSQL_ROOT_PASSWORD=123456
      - TZ=Asia/Tokyo
    volumes:
      - mysql_data:/var/lib/mysql
      - ./docker/mysql/init:/docker-entrypoint-initdb.d
      - ./docker/mysql/conf.d/my.cnf:/etc/mysql/conf.d/my.cnf
    cap_add:
      - SYS_NICE
    restart: unless-stopped
    networks:
      - ddds-network

  #phpmyadmin:
  #  image: phpmyadmin/phpmyadmin:latest
  #  ports:
  #    - "58080:80"
  #  environment:
  #    - PMA_HOST=db
  #    - PMA_USER=root
  #    - PMA_PASSWORD=123456
  #    - TZ=Asia/Tokyo
  #  depends_on:
  #    - db
  #  restart: unless-stopped
  #  networks:
  #    - ddds-network

volumes:
  mysql_data:
  apache_logs:

networks:
  ddds-network:
    external: true
