version: "3.8"

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

  db-shop-naffco:
    image: mysql:5.7
    volumes:
      - db_data_shop_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_shop_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_shop:
  db_data_shop_naffco:

networks:
  naffco_shop_network:
    driver: bridge
