version: "3.8"

services:
  db:
    image: mysql:8.0
    container_name: ${DB_CONTAINER_NAME}
    restart: always
    environment:
      MYSQL_DATABASE: ${DB_NAME}
      MYSQL_USER: ${DB_USER}
      MYSQL_PASSWORD: ${DB_PASSWORD}
      MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
    volumes:
      - db_data:/var/lib/mysql

  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    container_name: ${WP_CONTAINER_NAME}
    restart: always
    ports:
      - "${LOCAL_PORT}:80"
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: ${DB_USER}
      WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
      WORDPRESS_DB_NAME: ${DB_NAME}
      # ESTO LE DA MÁS GASOLINA A WORDPRESS
      WORDPRESS_CONFIG_EXTRA: |
        define('WP_MEMORY_LIMIT', '512M');
        define('WP_MAX_MEMORY_LIMIT', '512M');
    volumes:
      # EL :delegated HACE QUE WINDOWS Y DOCKER NO SE PELEEN TANTO
      - ./src:/var/www/html:delegated

volumes:
  db_data: