version: '3.8'

services:
  cavalstudio_db:
    image: mysql:8.0
    volumes:
      - cavalstudio_db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: cavalstudio
      MYSQL_USER: cavalstudio
      MYSQL_PASSWORD: password
    ports:
        - 3306:3306
    networks:
      - cavalstudio-network

  cavalstudio_be:
    build:
      context: .
      dockerfile: ./docker/php/Dockerfile
    volumes:
      - .:/var/www/html
      - ./docker/apache/000-default.conf:/etc/apache2/sites-available/000-default.conf
    depends_on:
      - cavalstudio_db
    ports:
      - 8001:80
    networks:
      - cavalstudio-network

  wordpress:
    image: wordpress:latest
    volumes:
      - wordpress_data:/var/www/html
      - ./cavalstudio-blog:/var/www/html/wp-content/themes/cavalstudio-blog
    restart: always
    environment:
      WORDPRESS_DB_HOST: wordpress_db
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_DEBUG: 1
    ports:
      - 8002:80
    depends_on:
      - wordpress_db
    networks:
      - cavalstudio-network

  wordpress_db:
    image: mysql:8.0
    volumes:
      - wordpress_db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress
    networks:
      - cavalstudio-network

networks:
  cavalstudio-network:
    driver: bridge

volumes:
  cavalstudio_db_data:
  wordpress_data:
  wordpress_db_data: 