docker-compose.yml 6.08 KB
version: "3"
services:

  # nacos
  nacos:
    image: nacos/nacos-server:v2.1.0
    hostname: nacos-server
    restart: always
    container_name: project-nacos
    environment:
      - PREFER_HOST_MODE=hostname
      - MODE=standalone
    ports:
      - "8848:8848"
  # nacos config-init
  nacos-setup:
    image: radial/busyboxplus:curl
    container_name: config-init
    volumes:
      - ../config-init:/work
    working_dir: /work/scripts
    restart: "no"
    entrypoint: [ "./nacos-config-quick.sh"]   
    depends_on:
      - nacos
      - mysql
      - seata-server
      
  # mysql
  mysql:
    container_name: project-mysql
    hostname: project-mysql
    restart: always
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: project_storage
    ports:
      - "3306:3306"
    volumes:
      - ../config-init/sql/init.sql:/docker-entrypoint-initdb.d/init.sql
    command:
      [
        --character-set-server=utf8mb4,
        --collation-server=utf8mb4_unicode_ci
      ]

  # postgres
  postgres:
    image: postgres:14.1-alpine
    hostname: project-pg
    restart: always
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
    ports:
      - '5432:5432'
    volumes: 
      - ../config-init/sql/init.sql:/docker-entrypoint-initdb.d/create_tables.sql
      

  # rocketMQ
  rmqnamesrv:
    image: apache/rocketmq:4.9.4
    hostname: rocketmq
    restart: always
    container_name: project-rmqnamesrv
    ports:
      - "9876:9876"
    command: sh mqnamesrv

  rmqbroker:
    image: apache/rocketmq:4.9.4
    restart: always
    container_name: project-rmqbroker
    ports:
      - "10909:10909"
      - "10911:10911"
    volumes:
      - ../config-init/rocketmq/broker.conf:/opt/rocketmq-4.9.4/conf/broker.conf
    environment:
      NAMESRV_ADDR: "rmqnamesrv:9876"
      JAVA_OPTS: " -Duser.home=/opt"
      JAVA_OPT_EXT: "-server -Xms128m -Xmx128m -Xmn128m"
    command: sh mqbroker -c /opt/rocketmq-4.9.4/conf/broker.conf
    depends_on:
      - rmqnamesrv

  # seata
  seata-server:
    image: seataio/seata-server:1.5.1
    hostname: seata-server
    restart: always
    container_name: project-seata-server
    ports:
      - "8091:8091"
    environment:
      - SEATA_PORT=8091
      - STORE_MODE=file

  # redis
  redis:
    image: redis:6.2-alpine
    hostname: redis
    restart: always
    container_name: project-redis
    ports:
      - "6379:6379"
    command: redis-server --save 20 1 --loglevel warning  --requirepass 123456

  # gateway
  project-gateway:
    image: project-gateway
    restart: always
    hostname: gateway-service
    build:
      dockerfile: ./project-gateway/Dockerfile
      context: ../
    env_file:
        - .env
    container_name: project-gateway
    ports:
      - ${GATEWAY_PORT}:${GATEWAY_PORT}
    depends_on:
      - nacos
      
  project-account:
    image: project-account
    restart: always
    build:
      dockerfile: ./project-account/Dockerfile
      context: ../
    env_file:
        - .env
    container_name: project-account
    ports:
      - ${ACCOUNT_PORT}:${ACCOUNT_PORT}
    depends_on:
      - nacos
      - mysql

  project-order:
    image: project-order
    restart: always
    build:
      dockerfile: ./project-order/Dockerfile
      context: ../
    env_file:
        - .env
    container_name: project-order
    ports:
      - ${ORDER_PORT}:${ORDER_PORT}
    depends_on:
      - nacos
      - mysql

  project-storage:
    image: project-storage
    restart: always
    build:
      dockerfile: ./project-storage/Dockerfile
      context: ../
    env_file:
        - .env
    container_name: project-storage
    ports:
      - ${STORAGE_PORT}:${STORAGE_PORT}
    depends_on:
      - nacos
      - mysql

  project-praise-provider:
    image: project-praise-provider
    restart: always
    build:
      dockerfile: ./project-praise-provider/Dockerfile
      context: ../
    env_file:
        - .env
    container_name: project-praise-provider
    ports:
      - ${PRAISE_PROVIDER_PORT}:${PRAISE_PROVIDER_PORT}
    depends_on:
      - nacos

  project-praise-consumer:
    image: project-praise-consumer
    restart: always
    build:
      dockerfile: ./project-praise-consumer/Dockerfile
      context: ../
    env_file:
        - .env
    container_name: project-praise-consumer
    ports:
      - ${PRAISE_CONSUMER_PORT}:${PRAISE_CONSUMER_PORT}
    depends_on:
      - nacos
      - project-praise-provider

  project-frontend:
    image: project-frontend
    hostname: project-frontend
    restart: always
    build:
      dockerfile: ./project-frontend/Dockerfile
      context: ../
    env_file:
      - .env
    container_name: project-frontend
    ports:
      - ${FRONTEND_PORT}:${FRONTEND_PORT}
    depends_on:
      - project-gateway
      - project-account
      - project-order
      - project-storage
      - project-praise-consumer
      - project-praise-provider


  # user module
  project-user:
    image: project-user
    restart: always
    build:
      dockerfile: ./project-user/Dockerfile
      context: ../
    env_file:
        - .env
    container_name: project-user
    ports:
      - ${USER_PORT}:${USER_PORT}
    depends_on:
      - nacos
      - mysql


  # gis module
  project-gis:
    image: project-gis
    restart: always
    build:
      dockerfile: ./project-gis/Dockerfile
      context: ../
    env_file:
        - .env
    container_name: project-gis
    ports:
      - ${GIS_PORT}:${GIS_PORT}
    depends_on:
      - nacos
      - mysql
      - postgres
      - project-geometry

  # geometry module
  project-geometry:
    image: project-geometry
    restart: always
    build:
      dockerfile: ./project-geometry/Dockerfile
      context: ../
    env_file:
        - .env
    container_name: project-geometry
    ports:
      - ${GEOMETRY_PORT}:${GEOMETRY_PORT}
    depends_on:
      - nacos

  # district module
  project-district:
    image: project-district
    restart: always
    build:
      dockerfile: ./project-district/Dockerfile
      context: ../
    env_file:
        - .env
    container_name: project-district
    ports:
      - ${DISTRICT_PORT}:${DISTRICT_PORT}
    depends_on:
      - nacos