version: '3.8'

services:
  db:
    image: mysql:8.0
    container_name: noblecollectable_db
    environment:
      MYSQL_DATABASE: noblecollectable
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress_dev_password
      MYSQL_ROOT_PASSWORD: root_dev_password
      MYSQL_CHARSET: utf8mb4
      MYSQL_COLLATION: utf8mb4_unicode_ci
    ports:
      - "3306:3306"
    volumes:
      - db_data:/var/lib/mysql
    networks:
      - noblecollectable_net
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      timeout: 20s
      retries: 10

  wordpress:
    image: wordpress:6.9-php8.2-apache
    container_name: noblecollectable_wp
    depends_on:
      db:
        condition: service_healthy
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_NAME: noblecollectable
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress_dev_password
      WORDPRESS_TABLE_PREFIX: nc_
      WORDPRESS_DEBUG: 'true'
    ports:
      - "8000:80"
    volumes:
      - ./wp-content:/var/www/html/wp-content
      - wordpress_data:/var/www/html
    networks:
      - noblecollectable_net
    restart: unless-stopped

volumes:
  db_data:
  wordpress_data:

networks:
  noblecollectable_net:
    driver: bridge
