version: "2"
services:
  nacos1:
    image: nacos/nacos-server:latest
    container_name: nacos1
    networks:
      nacos_net:
        ipv4_address: 172.16.238.10
    volumes:
      - ./cluster-logs/nacos1:/home/nacos/logs
    ports:
      - "8848:8848"
      - "9555:9555"
    env_file:
      - ../env/nacos-ip.env
    restart: on-failure
    depends_on:
      - mysql

  nacos2:
    image: nacos/nacos-server:latest
    container_name: nacos2
    networks:
      nacos_net:
        ipv4_address: 172.16.238.11
    volumes:
      - ./cluster-logs/nacos2:/home/nacos/logs
    ports:
      - "8849:8848"
    env_file:
      - ../env/nacos-ip.env
    restart: always
    depends_on:
      - mysql
  nacos3:
    image: nacos/nacos-server:latest
    container_name: nacos3
    networks:
      nacos_net:
        ipv4_address: 172.16.238.12
    volumes:
      - ./cluster-logs/nacos2:/home/nacos/logs
    ports:
      - "8850:8848"
    env_file:
      - ../env/nacos-ip.env
    restart: always
    depends_on:
      - mysql
  mysql:
    container_name: mysql
    image: nacos/nacos-mysql:5.7
    networks:
      nacos_net:
        ipv4_address: 172.16.238.13
    env_file:
      - ../env/mysql.env
    volumes:
      - ./mysql:/var/lib/mysql
    ports:
      - "3306:3306"
networks:
  nacos_net:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 172.16.238.0/24
