version: "3"

services:
  nginx:
    build:
      context: ./nginx/
      dockerfile: dockerfile
    network_mode: host
    volumes:
      - ./nginx/conf.d:/etc/nginx/conf.d
      - ./nginx/sources.list:/etc/apt/sources.list
      - /var/www:/var/www
      - ./log/nginx:/var/log/nginx
    container_name: nginx
    restart: always
    profiles:
      - nginx-host
  nginx-bridge:
    build:
      context: ./nginx/
      dockerfile: dockerfile
    volumes:
      - ./nginx/conf.d:/etc/nginx/conf.d
      - ./nginx/sources.list:/etc/apt/sources.list
      - /var/www:/var/www
      - ./log/nginx:/var/log/nginx
    container_name: nginx
    restart: always
    networks:
      - server
    ports:
      - "80:80"
      - "443:443"
    profiles:
      - nginx-bridge
  php71:
    build:
      context: ./php7.1/
      dockerfile: dockerfile
#      args:
#        PROJECT_PATH: ${PROJECT_PATH:-/opt/project}
    volumes:
      - ./php7.1/sources.list:/etc/apt/sources.list
      - ./php7.1/docker-php-ext-xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
      - ./php7.1/php.ini:/usr/local/etc/php/php.ini
      - ${LOCAL_CODE_ROOT}:/var/www/http
      - ${PROJECT_PATH}:/opt/project # fix idea+python中xdebug项目路径
    networks:
      - server
    container_name: php71
    restart: always
  php74:
    build:
      context: ./php7.4/
      dockerfile: dockerfile
#      args:
#        PROJECT_PATH: ${PROJECT_PATH:-/opt/project}
    volumes:
      - ./php7.4/sources.list:/etc/apt/sources.list
      - ./php7.4/docker-php-ext-xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
      - ./php7.4/php.ini:/usr/local/etc/php/php.ini
      - ${LOCAL_CODE_ROOT}:/var/www
    networks:
      - server
    container_name: php74
    restart: always
  php83:
    build:
      context: ./php8.3/
      dockerfile: dockerfile
    volumes:
      - ./php8.3/sources.list:/etc/apt/sources.list
      - ./php8.3/docker-php-ext-xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
      - ./php8.3/php.ini:/usr/local/etc/php/php.ini
      - ${LOCAL_CODE_ROOT}:/var/www
    networks:
      - server
    container_name: php83
    restart: always
  mysql:
    build:
      context: mysql/
      dockerfile: dockerfile
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: root
      TZ: Asia/Shanghai
    volumes:
        - /etc/localtime:/etc/localtime:ro
        - ./data/mysql:/var/lib/mysql
    command: --default-authentication-plugin=mysql_native_password
#    platform: linux/amd64  # apple silicon
    networks:
      - server
    ports:
      - "3306:3306"
    container_name: mysql
  mysql8:
    build:
      context: mysql8/
      dockerfile: dockerfile
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: root
      TZ: Asia/Shanghai
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ./data/mysql8:/var/lib/mysql
    command: --default-authentication-plugin=mysql_native_password
    networks:
      - server
    ports:
      - "3306:3306"
    container_name: mysql8
  redis:
    build:
      context: ./redis/
      dockerfile: dockerfile
    restart: always
    networks:
      - server
#    volumes:
#      - ${REDIS_DATA_PATH}:/data
    ports:
    - "6379:6379"
    container_name: redis
  python:
    build:
      context: ./python/
      dockerfile: dockerfile
    volumes:
      - ${LOCAL_CODE_ROOT}:/code
    networks:
      - server
    container_name: python
    ports:
      - "8000:8000"
  node:
    build:
      context: ./node/
      dockerfile: dockerfile
    volumes:
      - ${LOCAL_CODE_ROOT}:/code
    networks:
      - server
    stdin_open: true # docker run -i
    tty: true        # docker run -t
    ipc: host
    container_name: node
networks:
  server:
