# version: "3.8"
networks:
  backend:
    name: "${COMPOSE_PROJECT_NAME:-laravel}.${APP_ENV:-local}_network"
services:
  php-fpm:
      container_name: "${COMPOSE_PROJECT_NAME:-laravel}.${APP_ENV:-local}.php-fpm"
      platform: linux/arm64
      build:
        context: "../../docker/php-fpm"
        target: "local"
      image: "${COMPOSE_PROJECT_NAME:-laravel}/php-fpm"
      volumes:
        - "../../src:/var/www:cached"
      environment:
        TZ: "Asia/Tokyo"
      networks:
        - "backend"

  web:
    container_name: "${COMPOSE_PROJECT_NAME:-laravel}.${APP_ENV:-local}.nginx"
    platform: linux/arm64/v8
    image: "${COMPOSE_PROJECT_NAME:-laravel}/nginx"
    ports:
      -  "${WEB_PORT:-80}:80"
    volumes:
      - "../../src:/var/www:cached"
    depends_on:
      - "php-fpm"
    networks:
      - "backend"

  mysql:
    container_name: "${COMPOSE_PROJECT_NAME:-laravel}.${APP_ENV:-local}.mysql"
    image: "mysql:8.0"
    platform: linux/amd64
    volumes:
      - "db_data:/var/lib/mysql"
    environment:
      MYSQL_ROOT_PASSWORD: "mysql"
      MYSQL_USER: "default"
      MYSQL_PASSWORD: "secret"
      MYSQL_DATABASE: "${COMPOSE_PROJECT_NAME:-laravel}_db"
      TZ: "Asia/Tokyo"
    ports:
      - "3307:3306"
    networks:
      - backend

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    platform: linux/amd64
    container_name: phpmyadmin
    environment:
      - PMA_ARBITRARY=1
      - PMA_HOST=mysql
      - PMA_USER=root
      - PMA_PORT=3306
      - PMA_PASSWORD=mysql
    links:
      - mysql
    ports:
    # コンテナのポートが4桁だとなぜか起動しない     
      - 8080:80
    volumes:
      - /sessions
    networks:
      - backend

  mailpit:
    container_name: "${COMPOSE_PROJECT_NAME:-laravel}.${APP_ENV:-local}.mailpit"
    platform: linux/arm64/v8
    image: "axllent/mailpit:latest"
    ports:
      - "${FORWARD_MAILPIT_PORT:-1025}:1025"
      - "${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025"
    networks:
      - "backend"

volumes:
  db_data:
  redis_volume:
    driver: "local"
