services:
  db:
    image: mariadb:11.8
    environment:
      MARIADB_DATABASE: ${WORDPRESS_DB_NAME:-wordpress}
      MARIADB_USER: ${WORDPRESS_DB_USER:-wordpress}
      MARIADB_PASSWORD: ${WORDPRESS_DB_PASSWORD:?Defina WORDPRESS_DB_PASSWORD no arquivo .env}
      MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD:?Defina MARIADB_ROOT_PASSWORD no arquivo .env}
    volumes:
      - db_data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      interval: 10s
      timeout: 5s
      retries: 10
      start_period: 30s

  wordpress:
    container_name: gustavoo-me
    image: wordpress:7-php8.3-apache
    depends_on:
      db:
        condition: service_healthy
    ports:
      - "${WORDPRESS_PORT:-8080}:80"
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_NAME: ${WORDPRESS_DB_NAME:-wordpress}
      WORDPRESS_DB_USER: ${WORDPRESS_DB_USER:-wordpress}
      WORDPRESS_DB_PASSWORD: ${WORDPRESS_DB_PASSWORD}
    volumes:
      - wordpress_data:/var/www/html
      - type: bind
        source: ./wp-content/themes
        target: /var/www/html/wp-content/themes
        bind:
          create_host_path: false
      - type: bind
        source: ./wp-content/plugins
        target: /var/www/html/wp-content/plugins
        bind:
          create_host_path: false

volumes:
  db_data:
  wordpress_data:
