version: "3.8"

services:
  wordpress-power-naffco:
    user: "33:33"
    image: wordpress:6.5-php8.2-apache
    depends_on:
      db-power-naffco:
        condition: service_healthy
    ports:
      - "127.0.0.1:8005:80"
    environment:
      WORDPRESS_DB_HOST: db-power-naffco:3306
      WORDPRESS_DB_USER: ${DB_USER}
      WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
      WORDPRESS_DB_NAME: ${DB_NAME}
    volumes:
      - ./php-power-naffco.ini:/usr/local/etc/php/conf.d/uploads.ini
      - naffco_data_power:/var/www/html
    networks:
      - naffco_power_network
    restart: always

  db-power-naffco:
    image: mysql:5.7
    volumes:
      - db_data_power_naffco:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
      MYSQL_DATABASE: ${DB_NAME}
      MYSQL_USER: ${DB_USER}
      MYSQL_PASSWORD: ${DB_PASSWORD}
    networks:
      - naffco_power_network
    restart: always
    command: --default-authentication-plugin=mysql_native_password
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      interval: 30s
      timeout: 10s
      retries: 5

volumes:
  naffco_data_power:
  db_data_power_naffco:

networks:
  naffco_power_network:
    driver: bridge
