version: '3.8'
name: fzx-aliyun-dev

networks:
  fzx-devops-net:
    external: true
    name: fzx-devops-net

services:
  registry:
    container_name: fzx-aliyun-registry
    image: docker.m.daocloud.io/library/registry:2
    restart: always
    networks:
      fzx-devops-net:
        aliases:
          - registry
    ports:
      - "0.0.0.0:5000:5000"
    environment:
      - REGISTRY_STORAGE_DELETE_ENABLED=true
    volumes:
      - fzx-aliyun-registry-data:/var/lib/registry
      - /opt/fzx/infrastructure/registry/auth:/auth
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"
    deploy:
      resources:
        limits:
          cpus: "0.2"
          memory: "256M"
        reservations:
          cpus: "0.1"
          memory: "128M"
    healthcheck:
      test: [ "CMD-SHELL", "nc -z localhost 5000" ]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 30s

  mariadb:
    container_name: fzx-aliyun-mariadb
    image: docker.m.daocloud.io/library/mariadb:10.11
    restart: always
    networks:
      fzx-devops-net:
        aliases:
          - mariadb
    ports:
      - "0.0.0.0:3306:3306"
    environment:
      MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD}
      MARIADB_DATABASE: ${MARIADB_DATABASE}
      MARIADB_USER: ${MARIADB_USER}
      MARIADB_PASSWORD: ${MARIADB_PASSWORD}
      TZ: ${TZ}
    command:
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_unicode_ci
      - "--init_connect=SET NAMES utf8mb4"
      - --skip-character-set-client-handshake
      - --default-storage-engine=InnoDB
      - --max-connections=200
    volumes:
      - fzx-aliyun-mariadb-data:/var/lib/mysql
      - ../database/mariadb/init:/docker-entrypoint-initdb.d
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"
    deploy:
      resources:
        limits:
          cpus: "0.8"
          memory: "1536M"
        reservations:
          cpus: "0.8"
          memory: "1536M"
    healthcheck:
      test: [ "CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "${MARIADB_USER}", "-p${MARIADB_PASSWORD}" ]
      interval: 10s
      timeout: 5s
      retries: 5

  redis:
    container_name: fzx-aliyun-redis
    image: docker.m.daocloud.io/library/redis:7.2.4
    restart: always
    networks:
      fzx-devops-net:
        aliases:
          - redis
    ports:
      - "0.0.0.0:6379:6379"
    command: [ "redis-server", "--requirepass", "${REDIS_PASSWORD}", "--maxmemory", "768mb", "--maxmemory-policy", "allkeys-lru", "--appendonly", "yes" ]
    volumes:
      - fzx-aliyun-redis-data:/data
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"
    deploy:
      resources:
        limits:
          cpus: "0.3"
          memory: "512M"
        reservations:
          cpus: "0.3"
          memory: "512M"
    healthcheck:
      test: [ "CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping" ]
      interval: 10s
      timeout: 5s
      retries: 3

  nacos:
    container_name: fzx-aliyun-nacos
    image: docker.m.daocloud.io/nacos/nacos-server:v2.4.3
    restart: always
    networks:
      fzx-devops-net:
        aliases:
          - nacos
    ports:
      - "0.0.0.0:8848:8848"
      - "0.0.0.0:9848:9848"
      - "0.0.0.0:9849:9849"
    environment:
      MODE: standalone
      NACOS_AUTH_ENABLE: "true"
      NACOS_AUTH_SYSTEM_TYPE: nacos
      NACOS_AUTH_TOKEN_EXPIRE_SECONDS: 18000
      NACOS_AUTH_TOKEN: ${NACOS_AUTH_TOKEN:-Rnp4TmFjb3NTZWNyZXRLZXkyMDI2IUAjJCVeJipGenhOYWNvc1NlY3JldEtleTIwMjYhQCMkJV4mKg==}
      NACOS_AUTH_CACHE_ENABLE: "true"
      NACOS_AUTH_IDENTITY_KEY: ${NACOS_AUTH_IDENTITY_KEY:-fzx-nacos-key}
      NACOS_AUTH_IDENTITY_VALUE: ${NACOS_AUTH_IDENTITY_VALUE:-fzx-nacos-value}
      NACOS_AUTH_USER_AGENT_AUTH_WHITE_ENABLE: "false"
      MYSQL_SERVICE_HOST: mariadb
      MYSQL_SERVICE_PORT: 3306
      MYSQL_SERVICE_DB_NAME: nacos_config
      MYSQL_SERVICE_DB_PARAM: characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
      MYSQL_SERVICE_USER: ${MARIADB_USER}
      MYSQL_SERVICE_PASSWORD: ${MARIADB_PASSWORD}
      SPRING_DATASOURCE_PLATFORM: mysql
      NACOS_USERNAME: ${NACOS_USERNAME:-nacos}
      NACOS_PASSWORD: ${NACOS_PASSWORD:-nacos}
      NACOS_JVM_ARGS: "-Xms256M -Xmx512M -XX:MetaspaceSize=64M -XX:MaxMetaspaceSize=128M"
      TZ: ${TZ}
    volumes:
      - fzx-aliyun-nacos-data:/home/nacos/data
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"
    deploy:
      resources:
        limits:
          cpus: "0.5"
          memory: "1G"
        reservations:
          cpus: "0.25"
          memory: "512M"
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:8848/nacos/v1/console/health/readiness" ]
      interval: 10s
      timeout: 5s
      retries: 10
      start_period: 30s
    depends_on:
      mariadb:
        condition: service_healthy

  #  prometheus:
  #    container_name: fzx-aliyun-prometheus
  #    image: docker.m.daocloud.io/prom/prometheus:v2.54.1
  #    restart: always
  #    networks:
  #      fzx-devops-net:
  #        aliases:
  #          - prometheus
  #    ports:
  #      - "0.0.0.0:9090:9090"
  #    volumes:
  #      - ../config/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
  #      - fzx-aliyun-prometheus-data:/prometheus
  #    command: --config.file=/etc/prometheus/prometheus.yml --web.enable-lifecycle
  #    logging:
  #      driver: "json-file"
  #      options:
  #        max-size: "100m"
  #        max-file: "10"
  #    deploy:
  #      resources:
  #        limits:
  #          cpus: "0.2"
  #          memory: "384M"
  #        reservations:
  #          cpus: "0.2"
  #          memory: "384M"
  #    healthcheck:
  #      test: ["CMD", "curl", "-f", "http://localhost:9090/-/healthy"]
  #      interval: 30s
  #      timeout: 10s
  #      retries: 3
  #
  #  grafana:
  #    container_name: fzx-aliyun-grafana
  #    image: docker.m.daocloud.io/grafana/grafana:11.2.0
  #    restart: always
  #    networks:
  #      fzx-devops-net:
  #        aliases:
  #          - grafana
  #    ports:
  #      - "0.0.0.0:3000:3000"
  #    environment:
  #      GF_SECURITY_ADMIN_USER: ${GRAFANA_USER}
  #      GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD}
  #      GF_USERS_ALLOW_SIGN_UP: "false"
  #      TZ: ${TZ}
  #    volumes:
  #      - fzx-aliyun-grafana-data:/var/lib/grafana
  #    logging:
  #      driver: "json-file"
  #      options:
  #        max-size: "100m"
  #        max-file: "10"
  #    deploy:
  #      resources:
  #        limits:
  #          cpus: "0.15"
  #          memory: "256M"
  #        reservations:
  #          cpus: "0.15"
  #          memory: "256M"
  #    healthcheck:
  #      test: ["CMD", "curl", "-f", "http://localhost:3000/api/health"]
  #      interval: 30s
  #      timeout: 10s
  #      retries: 3
  #      start_period: 30s
  #
  #  skywalking-oap:
  #    container_name: fzx-aliyun-skywalking-oap
  #    image: docker.m.daocloud.io/apache/skywalking-oap-server:9.7.0
  #    restart: always
  #    networks:
  #      fzx-devops-net:
  #        aliases:
  #          - skywalking-oap
  #    ports:
  #      - "0.0.0.0:11800:11800"
  #      - "0.0.0.0:12800:12800"
  #    environment:
  #      TZ: ${TZ}
  #      JAVA_TOOL_OPTIONS: "-Xms192M -Xmx512M"
  #    logging:
  #      driver: "json-file"
  #      options:
  #        max-size: "100m"
  #        max-file: "10"
  #    deploy:
  #      resources:
  #        limits:
  #          cpus: "0.2"
  #          memory: "512M"
  #        reservations:
  #          cpus: "0.2"
  #          memory: "512M"
  #    healthcheck:
  #      test: ["CMD", "curl", "-f", "http://localhost:12800/health"]
  #      interval: 30s
  #      timeout: 10s
  #      retries: 3
  #      start_period: 60s
  #    depends_on:
  #      mariadb:
  #        condition: service_healthy
  #
  #  skywalking-ui:
  #    container_name: fzx-aliyun-skywalking-ui
  #    image: docker.m.daocloud.io/apache/skywalking-ui:9.7.0
  #    restart: always
  #    networks:
  #      fzx-devops-net:
  #        aliases:
  #          - skywalking-ui
  #    ports:
  #      - "0.0.0.0:8888:8080"
  #    environment:
  #      SW_OAP_ADDRESS: http://fzx-aliyun-skywalking-oap:12800
  #      TZ: ${TZ}
  #    logging:
  #      driver: "json-file"
  #      options:
  #        max-size: "100m"
  #        max-file: "10"
  #    deploy:
  #      resources:
  #        limits:
  #          cpus: "0.1"
  #          memory: "128M"
  #        reservations:
  #          cpus: "0.1"
  #          memory: "128M"
  #    healthcheck:
  #      test: ["CMD", "curl", "-f", "http://localhost:8080/"]
  #      interval: 30s
  #      timeout: 10s
  #      retries: 3
  #      start_period: 30s
  #    depends_on:
  #      skywalking-oap:
  #        condition: service_healthy

  api-gateway:
    container_name: fzx-aliyun-gateway
    image: ${IMAGE_REGISTRY}/api-gateway-${IMAGE_ENV}:${IMAGE_TAG}
    restart: always
    networks:
      fzx-devops-net:
        aliases:
          - api-gateway
    ports:
      - "0.0.0.0:8083:8083"
    environment:
      SPRING_PROFILES_ACTIVE: aliyun-dev
      SERVER_PORT: 8083
      SPRING_DATASOURCE_URL: jdbc:mariadb://mariadb:3306/${MARIADB_DATABASE}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8
      SPRING_DATASOURCE_USERNAME: ${MARIADB_USER}
      SPRING_DATASOURCE_PASSWORD: ${MARIADB_PASSWORD}
      SPRING_REDIS_HOST: redis
      SPRING_REDIS_PORT: 6379
      SPRING_REDIS_PASSWORD: ${REDIS_PASSWORD}
      NACOS_SERVER_ADDR: nacos:8848
      NACOS_USERNAME: ${NACOS_USERNAME:-nacos}
      NACOS_PASSWORD: ${NACOS_PASSWORD:-nacos}
      NACOS_NAMESPACE: aliyun-dev
      SPRING_CLOUD_NACOS_DISCOVERY_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      SPRING_CLOUD_NACOS_CONFIG_ENABLED: ${NACOS_CONFIG_ENABLED}
      SPRING_CLOUD_NACOS_DISCOVERY_USERNAME: ${NACOS_USERNAME:-nacos}
      SPRING_CLOUD_NACOS_DISCOVERY_PASSWORD: ${NACOS_PASSWORD:-nacos}
      SPRING_CLOUD_SERVICE_REGISTRY_AUTO_REGISTRATION_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      JWT_SECRET_KEY: ${JWT_SECRET_KEY}
      TZ: ${TZ}
      JAVA_TOOL_OPTIONS: "-Xms512M -Xmx1G -XX:+UseG1GC -Dlogback.scan=false"
    volumes:
      - /opt/fzx/infrastructure/logs/api-gateway-aliyun:/logs
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"
    deploy:
      resources:
        limits:
          cpus: "0.75"
          memory: "1G"
        reservations:
          cpus: "0.5"
          memory: "768M"
    healthcheck:
      test: [ "CMD", "wget", "--spider", "http://localhost:8083/actuator/health" ]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s
    depends_on:
      mariadb:
        condition: service_healthy
      redis:
        condition: service_healthy
      nacos:
        condition: service_healthy

  user-service:
    container_name: fzx-aliyun-user
    image: ${IMAGE_REGISTRY}/user-service-${IMAGE_ENV}:${IMAGE_TAG}
    restart: always
    networks:
      fzx-devops-net:
        aliases:
          - user-service
    ports:
      - "0.0.0.0:8095:8095"
    environment:
      SPRING_PROFILES_ACTIVE: aliyun-dev
      SERVER_PORT: 8095
      SPRING_DATASOURCE_URL: jdbc:mariadb://mariadb:3306/${MARIADB_DATABASE}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8
      SPRING_DATASOURCE_USERNAME: ${MARIADB_USER}
      SPRING_DATASOURCE_PASSWORD: ${MARIADB_PASSWORD}
      SPRING_REDIS_HOST: redis
      SPRING_REDIS_PORT: 6379
      SPRING_REDIS_PASSWORD: ${REDIS_PASSWORD}
      NACOS_SERVER_ADDR: nacos:8848
      NACOS_USERNAME: ${NACOS_USERNAME:-nacos}
      NACOS_PASSWORD: ${NACOS_PASSWORD:-nacos}
      NACOS_NAMESPACE: aliyun-dev
      SPRING_CLOUD_NACOS_DISCOVERY_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      SPRING_CLOUD_NACOS_CONFIG_ENABLED: ${NACOS_CONFIG_ENABLED}
      SPRING_CLOUD_NACOS_DISCOVERY_USERNAME: ${NACOS_USERNAME:-nacos}
      SPRING_CLOUD_NACOS_DISCOVERY_PASSWORD: ${NACOS_PASSWORD:-nacos}
      SPRING_CLOUD_SERVICE_REGISTRY_AUTO_REGISTRATION_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      JWT_SECRET_KEY: ${JWT_SECRET_KEY}
      APP_SECURITY_PUBLIC_PATHS: "/api/auth/login,/api/auth/register,/actuator/**,/swagger-ui/**,/v3/api-docs/**,/swagger-resources/**,/webjars/**,/health,/api/user/health,/test/public"
      TZ: ${TZ}
      JAVA_TOOL_OPTIONS: "-Xms512M -Xmx1G -XX:+UseG1GC -Dlogback.scan=false"
    volumes:
      - /opt/fzx/infrastructure/logs/user-service-aliyun:/logs
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"
    deploy:
      resources:
        limits:
          cpus: "0.75"
          memory: "1G"
        reservations:
          cpus: "0.5"
          memory: "768M"
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:8095/actuator/health" ]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s
    depends_on:
      mariadb:
        condition: service_healthy
      redis:
        condition: service_healthy
      nacos:
        condition: service_healthy

  auth-service:
    container_name: fzx-aliyun-auth
    image: ${IMAGE_REGISTRY}/auth-service-${IMAGE_ENV}:${IMAGE_TAG}
    restart: always
    networks:
      fzx-devops-net:
        aliases:
          - auth-service
    ports:
      - "0.0.0.0:8082:8082"
    environment:
      SERVER_PORT: 8082
      SPRING_PROFILES_ACTIVE: aliyun-dev
      SPRING_DATASOURCE_URL: jdbc:mariadb://mariadb:3306/${MARIADB_DATABASE}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8
      SPRING_DATASOURCE_USERNAME: ${MARIADB_USER}
      SPRING_DATASOURCE_PASSWORD: ${MARIADB_PASSWORD}
      SPRING_REDIS_HOST: redis
      SPRING_REDIS_PORT: 6379
      SPRING_REDIS_PASSWORD: ${REDIS_PASSWORD}
      NACOS_SERVER_ADDR: nacos:8848
      NACOS_USERNAME: ${NACOS_USERNAME:-nacos}
      NACOS_PASSWORD: ${NACOS_PASSWORD:-nacos}
      NACOS_NAMESPACE: aliyun-dev
      SPRING_CLOUD_NACOS_DISCOVERY_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      SPRING_CLOUD_NACOS_CONFIG_ENABLED: ${NACOS_CONFIG_ENABLED}
      SPRING_CLOUD_NACOS_DISCOVERY_USERNAME: ${NACOS_USERNAME:-nacos}
      SPRING_CLOUD_NACOS_DISCOVERY_PASSWORD: ${NACOS_PASSWORD:-nacos}
      SPRING_CLOUD_SERVICE_REGISTRY_AUTO_REGISTRATION_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      JWT_SECRET_KEY: ${JWT_SECRET_KEY}
      TZ: ${TZ}
      JAVA_TOOL_OPTIONS: "-Xms512M -Xmx1G -XX:+UseG1GC -Dlogback.scan=false"
    volumes:
      - /opt/fzx/infrastructure/logs/auth-service-aliyun:/logs
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"
    deploy:
      resources:
        limits:
          cpus: "0.75"
          memory: "1G"
        reservations:
          cpus: "0.5"
          memory: "768M"
    healthcheck:
      test: [ "CMD", "wget", "--spider", "http://localhost:8082/actuator/health" ]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s
    depends_on:
      mariadb:
        condition: service_healthy
      redis:
        condition: service_healthy
      nacos:
        condition: service_healthy

  merchant-service:
    container_name: fzx-aliyun-merchant
    image: ${IMAGE_REGISTRY}/merchant-service-${IMAGE_ENV}:${IMAGE_TAG}
    restart: always
    networks:
      fzx-devops-net:
        aliases:
          - merchant-service
    ports:
      - "0.0.0.0:8093:8083"
    environment:
      SPRING_PROFILES_ACTIVE: aliyun-dev
      SPRING_APPLICATION_JSON: '{"spring":{"redis":{"host":"redis","port":6379}}}'
      SPRING_DATASOURCE_URL: jdbc:mariadb://mariadb:3306/${MARIADB_DATABASE}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8
      SPRING_DATASOURCE_USERNAME: ${MARIADB_USER}
      SPRING_DATASOURCE_PASSWORD: ${MARIADB_PASSWORD}
      SPRING_REDIS_HOST: redis
      SPRING_REDIS_PORT: 6379
      SPRING_REDIS_PASSWORD: ${REDIS_PASSWORD}
      NACOS_SERVER_ADDR: nacos:8848
      NACOS_USERNAME: ${NACOS_USERNAME:-nacos}
      NACOS_PASSWORD: ${NACOS_PASSWORD:-nacos}
      NACOS_NAMESPACE: aliyun-dev
      SPRING_CLOUD_NACOS_DISCOVERY_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      SPRING_CLOUD_NACOS_CONFIG_ENABLED: ${NACOS_CONFIG_ENABLED}
      SPRING_CLOUD_NACOS_DISCOVERY_USERNAME: ${NACOS_USERNAME:-nacos}
      SPRING_CLOUD_NACOS_DISCOVERY_PASSWORD: ${NACOS_PASSWORD:-nacos}
      SPRING_CLOUD_SERVICE_REGISTRY_AUTO_REGISTRATION_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      TZ: ${TZ}
      JAVA_TOOL_OPTIONS: "-Xms512M -Xmx1G -XX:+UseG1GC -Dlogback.scan=false"
      BANK_PAYMENT_API_URL: ${BANK_PAYMENT_API_URL}
      BANK_PAYMENT_APP_ID: ${BANK_PAYMENT_APP_ID}
      BANK_PAYMENT_APP_SECRET: ${BANK_PAYMENT_APP_SECRET}
      BANK_PAYMENT_MERCHANT_ID: ${BANK_PAYMENT_MERCHANT_ID}
    volumes:
      - /opt/fzx/infrastructure/logs/merchant-service-aliyun:/logs
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"
    deploy:
      resources:
        limits:
          cpus: "0.75"
          memory: "1G"
        reservations:
          cpus: "0.5"
          memory: "768M"
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:8085/actuator/health" ]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s
    depends_on:
      mariadb:
        condition: service_healthy
      redis:
        condition: service_healthy
      nacos:
        condition: service_healthy

  order-service:
    container_name: fzx-aliyun-order
    image: ${IMAGE_REGISTRY}/order-service-${IMAGE_ENV}:${IMAGE_TAG}
    restart: always
    networks:
      fzx-devops-net:
        aliases:
          - order-service
    ports:
      - "0.0.0.0:8086:8086"
    environment:
      SPRING_PROFILES_ACTIVE: aliyun-dev
      SPRING_APPLICATION_JSON: '{"spring":{"redis":{"host":"redis","port":6379}}}'
      SPRING_DATASOURCE_URL: jdbc:mariadb://mariadb:3306/${MARIADB_DATABASE}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8
      SPRING_DATASOURCE_USERNAME: ${MARIADB_USER}
      SPRING_DATASOURCE_PASSWORD: ${MARIADB_PASSWORD}
      SPRING_REDIS_HOST: redis
      SPRING_REDIS_PORT: 6379
      SPRING_REDIS_PASSWORD: ${REDIS_PASSWORD}
      NACOS_SERVER_ADDR: nacos:8848
      NACOS_USERNAME: ${NACOS_USERNAME:-nacos}
      NACOS_PASSWORD: ${NACOS_PASSWORD:-nacos}
      NACOS_NAMESPACE: aliyun-dev
      SPRING_CLOUD_NACOS_DISCOVERY_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      SPRING_CLOUD_NACOS_CONFIG_ENABLED: ${NACOS_CONFIG_ENABLED}
      SPRING_CLOUD_NACOS_DISCOVERY_USERNAME: ${NACOS_USERNAME:-nacos}
      SPRING_CLOUD_NACOS_DISCOVERY_PASSWORD: ${NACOS_PASSWORD:-nacos}
      SPRING_CLOUD_SERVICE_REGISTRY_AUTO_REGISTRATION_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      TZ: ${TZ}
      JAVA_TOOL_OPTIONS: "-Xms512M -Xmx1G -XX:+UseG1GC -Dlogback.scan=false"
    volumes:
      - /opt/fzx/infrastructure/logs/order-service-aliyun:/logs
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"
    deploy:
      resources:
        limits:
          cpus: "0.75"
          memory: "1G"
        reservations:
          cpus: "0.5"
          memory: "768M"
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:8086/actuator/health" ]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s
    depends_on:
      mariadb:
        condition: service_healthy
      redis:
        condition: service_healthy
      nacos:
        condition: service_healthy

  rider-service:
    container_name: fzx-aliyun-rider
    image: ${IMAGE_REGISTRY}/rider-service-${IMAGE_ENV}:${IMAGE_TAG}
    restart: always
    networks:
      fzx-devops-net:
        aliases:
          - rider-service
    ports:
      - "0.0.0.0:8088:8088"
    environment:
      SPRING_PROFILES_ACTIVE: aliyun-dev
      SPRING_APPLICATION_JSON: '{"spring":{"redis":{"host":"redis","port":6379}}}'
      SPRING_DATASOURCE_URL: jdbc:mariadb://mariadb:3306/${MARIADB_DATABASE}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8
      SPRING_DATASOURCE_USERNAME: ${MARIADB_USER}
      SPRING_DATASOURCE_PASSWORD: ${MARIADB_PASSWORD}
      SPRING_REDIS_HOST: redis
      SPRING_REDIS_PORT: 6379
      SPRING_REDIS_PASSWORD: ${REDIS_PASSWORD}
      NACOS_SERVER_ADDR: nacos:8848
      NACOS_USERNAME: ${NACOS_USERNAME:-nacos}
      NACOS_PASSWORD: ${NACOS_PASSWORD:-nacos}
      NACOS_NAMESPACE: aliyun-dev
      SPRING_CLOUD_NACOS_DISCOVERY_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      SPRING_CLOUD_NACOS_CONFIG_ENABLED: ${NACOS_CONFIG_ENABLED}
      SPRING_CLOUD_NACOS_DISCOVERY_USERNAME: ${NACOS_USERNAME:-nacos}
      SPRING_CLOUD_NACOS_DISCOVERY_PASSWORD: ${NACOS_PASSWORD:-nacos}
      SPRING_CLOUD_SERVICE_REGISTRY_AUTO_REGISTRATION_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      TZ: ${TZ}
      JAVA_TOOL_OPTIONS: "-Xms512M -Xmx1G -XX:+UseG1GC -Dlogback.scan=false"
    volumes:
      - /opt/fzx/infrastructure/logs/rider-service-aliyun:/logs
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"
    deploy:
      resources:
        limits:
          cpus: "0.75"
          memory: "1G"
        reservations:
          cpus: "0.5"
          memory: "768M"
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:8088/actuator/health" ]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s
    depends_on:
      mariadb:
        condition: service_healthy
      redis:
        condition: service_healthy
      nacos:
        condition: service_healthy

  product-service:
    container_name: fzx-aliyun-product
    image: ${IMAGE_REGISTRY}/product-service-${IMAGE_ENV}:${IMAGE_TAG}
    restart: always
    networks:
      fzx-devops-net:
        aliases:
          - product-service
    ports:
      - "0.0.0.0:8087:8087"
    environment:
      SPRING_PROFILES_ACTIVE: aliyun-dev
      SPRING_APPLICATION_JSON: '{"spring":{"redis":{"host":"redis","port":6379}}}'
      SPRING_DATASOURCE_URL: jdbc:mariadb://mariadb:3306/${MARIADB_DATABASE}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8
      SPRING_DATASOURCE_USERNAME: ${MARIADB_USER}
      SPRING_DATASOURCE_PASSWORD: ${MARIADB_PASSWORD}
      SPRING_REDIS_HOST: redis
      SPRING_REDIS_PORT: 6379
      SPRING_REDIS_PASSWORD: ${REDIS_PASSWORD}
      NACOS_SERVER_ADDR: nacos:8848
      NACOS_USERNAME: ${NACOS_USERNAME:-nacos}
      NACOS_PASSWORD: ${NACOS_PASSWORD:-nacos}
      NACOS_NAMESPACE: aliyun-dev
      SPRING_CLOUD_NACOS_DISCOVERY_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      SPRING_CLOUD_NACOS_CONFIG_ENABLED: ${NACOS_CONFIG_ENABLED}
      SPRING_CLOUD_NACOS_DISCOVERY_USERNAME: ${NACOS_USERNAME:-nacos}
      SPRING_CLOUD_NACOS_DISCOVERY_PASSWORD: ${NACOS_PASSWORD:-nacos}
      SPRING_CLOUD_SERVICE_REGISTRY_AUTO_REGISTRATION_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      TZ: ${TZ}
      JAVA_TOOL_OPTIONS: "-Xms512M -Xmx1G -XX:+UseG1GC -Dlogback.scan=false"
    volumes:
      - /opt/fzx/infrastructure/logs/product-service-aliyun:/logs
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"
    deploy:
      resources:
        limits:
          cpus: "0.5"
          memory: "768M"
        reservations:
          cpus: "0.4"
          memory: "512M"
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:8087/actuator/health" ]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s
    depends_on:
      mariadb:
        condition: service_healthy
      redis:
        condition: service_healthy
      nacos:
        condition: service_healthy

  map-service:
    container_name: fzx-aliyun-map
    image: ${IMAGE_REGISTRY}/map-service-${IMAGE_ENV}:${IMAGE_TAG}
    restart: always
    networks:
      fzx-devops-net:
        aliases:
          - map-service
    ports:
      - "0.0.0.0:8089:8089"
    environment:
      SPRING_PROFILES_ACTIVE: aliyun-dev
      SPRING_APPLICATION_JSON: '{"spring":{"redis":{"host":"redis","port":6379}}}'
      SPRING_DATASOURCE_URL: jdbc:mariadb://mariadb:3306/${MARIADB_DATABASE}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8
      SPRING_DATASOURCE_USERNAME: ${MARIADB_USER}
      SPRING_DATASOURCE_PASSWORD: ${MARIADB_PASSWORD}
      SPRING_REDIS_HOST: redis
      SPRING_REDIS_PORT: 6379
      SPRING_REDIS_PASSWORD: ${REDIS_PASSWORD}
      NACOS_SERVER_ADDR: nacos:8848
      NACOS_USERNAME: ${NACOS_USERNAME:-nacos}
      NACOS_PASSWORD: ${NACOS_PASSWORD:-nacos}
      NACOS_NAMESPACE: aliyun-dev
      SPRING_CLOUD_NACOS_DISCOVERY_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      SPRING_CLOUD_NACOS_CONFIG_ENABLED: ${NACOS_CONFIG_ENABLED}
      SPRING_CLOUD_NACOS_DISCOVERY_USERNAME: ${NACOS_USERNAME:-nacos}
      SPRING_CLOUD_NACOS_DISCOVERY_PASSWORD: ${NACOS_PASSWORD:-nacos}
      SPRING_CLOUD_SERVICE_REGISTRY_AUTO_REGISTRATION_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      TZ: ${TZ}
      JAVA_TOOL_OPTIONS: "-Xms512M -Xmx1G -XX:+UseG1GC -Dlogback.scan=false"
      MAP_AMAP_KEY: ${MAP_AMAP_KEY:}
      MAP_BAIDU_KEY: ${MAP_BAIDU_KEY:}
      MAP_TENCENT_KEY: ${MAP_TENCENT_KEY:}
    volumes:
      - /opt/fzx/infrastructure/logs/map-service-aliyun:/logs
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"
    deploy:
      resources:
        limits:
          cpus: "0.5"
          memory: "768M"
        reservations:
          cpus: "0.4"
          memory: "512M"
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:8089/actuator/health" ]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s
    depends_on:
      mariadb:
        condition: service_healthy
      redis:
        condition: service_healthy
      nacos:
        condition: service_healthy

  marketing-service:
    container_name: fzx-aliyun-marketing
    image: ${IMAGE_REGISTRY}/marketing-service-${IMAGE_ENV}:${IMAGE_TAG}
    restart: always
    networks:
      fzx-devops-net:
        aliases:
          - marketing-service
    ports:
      - "0.0.0.0:8090:8090"
    environment:
      SPRING_PROFILES_ACTIVE: aliyun-dev
      SPRING_APPLICATION_JSON: '{"spring":{"redis":{"host":"redis","port":6379}}}'
      SPRING_DATASOURCE_URL: jdbc:mariadb://mariadb:3306/${MARIADB_DATABASE}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8
      SPRING_DATASOURCE_USERNAME: ${MARIADB_USER}
      SPRING_DATASOURCE_PASSWORD: ${MARIADB_PASSWORD}
      SPRING_REDIS_HOST: redis
      SPRING_REDIS_PORT: 6379
      SPRING_REDIS_PASSWORD: ${REDIS_PASSWORD}
      NACOS_SERVER_ADDR: nacos:8848
      NACOS_USERNAME: ${NACOS_USERNAME:-nacos}
      NACOS_PASSWORD: ${NACOS_PASSWORD:-nacos}
      NACOS_NAMESPACE: aliyun-dev
      SPRING_CLOUD_NACOS_DISCOVERY_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      SPRING_CLOUD_NACOS_CONFIG_ENABLED: ${NACOS_CONFIG_ENABLED}
      SPRING_CLOUD_NACOS_DISCOVERY_USERNAME: ${NACOS_USERNAME:-nacos}
      SPRING_CLOUD_NACOS_DISCOVERY_PASSWORD: ${NACOS_PASSWORD:-nacos}
      SPRING_CLOUD_SERVICE_REGISTRY_AUTO_REGISTRATION_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      TZ: ${TZ}
      JAVA_TOOL_OPTIONS: "-Xms512M -Xmx1G -XX:+UseG1GC -Dlogback.scan=false"
    volumes:
      - /opt/fzx/infrastructure/logs/marketing-service-aliyun:/logs
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"
    deploy:
      resources:
        limits:
          cpus: "0.5"
          memory: "768M"
        reservations:
          cpus: "0.4"
          memory: "512M"
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:8090/actuator/health" ]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s
    depends_on:
      mariadb:
        condition: service_healthy
      redis:
        condition: service_healthy
      nacos:
        condition: service_healthy

  upload-service:
    container_name: fzx-aliyun-upload
    image: ${IMAGE_REGISTRY}/upload-service-${IMAGE_ENV}:${IMAGE_TAG}
    restart: always
    networks:
      fzx-devops-net:
        aliases:
          - upload-service
    ports:
      - "0.0.0.0:8092:8092"
    environment:
      SPRING_PROFILES_ACTIVE: aliyun-dev
      SPRING_APPLICATION_JSON: '{"spring":{"redis":{"host":"redis","port":6379}}}'
      SPRING_DATASOURCE_URL: jdbc:mariadb://mariadb:3306/${MARIADB_DATABASE}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8
      SPRING_DATASOURCE_USERNAME: ${MARIADB_USER}
      SPRING_DATASOURCE_PASSWORD: ${MARIADB_PASSWORD}
      SPRING_REDIS_HOST: redis
      SPRING_REDIS_PORT: 6379
      SPRING_REDIS_PASSWORD: ${REDIS_PASSWORD}
      NACOS_SERVER_ADDR: nacos:8848
      NACOS_USERNAME: ${NACOS_USERNAME:-nacos}
      NACOS_PASSWORD: ${NACOS_PASSWORD:-nacos}
      NACOS_NAMESPACE: aliyun-dev
      SPRING_CLOUD_NACOS_DISCOVERY_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      SPRING_CLOUD_NACOS_CONFIG_ENABLED: ${NACOS_CONFIG_ENABLED}
      SPRING_CLOUD_NACOS_DISCOVERY_USERNAME: ${NACOS_USERNAME:-nacos}
      SPRING_CLOUD_NACOS_DISCOVERY_PASSWORD: ${NACOS_PASSWORD:-nacos}
      SPRING_CLOUD_SERVICE_REGISTRY_AUTO_REGISTRATION_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      TZ: ${TZ}
      JAVA_TOOL_OPTIONS: "-Xms384M -Xmx512M -XX:+UseG1GC -Dlogback.scan=false"
    volumes:
      - /opt/fzx/infrastructure/logs/upload-service-aliyun:/logs
      - /opt/fzx/infrastructure/upload:/opt/upload
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"
    deploy:
      resources:
        limits:
          cpus: "0.75"
          memory: "1G"
        reservations:
          cpus: "0.5"
          memory: "768M"
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:8092/actuator/health" ]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s
    depends_on:
      mariadb:
        condition: service_healthy
      redis:
        condition: service_healthy
      nacos:
        condition: service_healthy

  platform-service:
    container_name: fzx-aliyun-platform
    image: ${IMAGE_REGISTRY}/platform-service-${IMAGE_ENV}:${IMAGE_TAG}
    restart: always
    networks:
      fzx-devops-net:
        aliases:
          - platform-service
    ports:
      - "0.0.0.0:8091:8089"
    environment:
      SPRING_PROFILES_ACTIVE: aliyun-dev
      SERVER_PORT: 8089
      SPRING_DATASOURCE_URL: jdbc:mariadb://mariadb:3306/${MARIADB_DATABASE}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8
      SPRING_DATASOURCE_USERNAME: ${MARIADB_USER}
      SPRING_DATASOURCE_PASSWORD: ${MARIADB_PASSWORD}
      SPRING_REDIS_HOST: redis
      SPRING_REDIS_PORT: 6379
      SPRING_REDIS_PASSWORD: ${REDIS_PASSWORD}
      NACOS_SERVER_ADDR: nacos:8848
      NACOS_USERNAME: ${NACOS_USERNAME:-nacos}
      NACOS_PASSWORD: ${NACOS_PASSWORD:-nacos}
      NACOS_NAMESPACE: aliyun-dev
      SPRING_CLOUD_NACOS_DISCOVERY_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      SPRING_CLOUD_NACOS_CONFIG_ENABLED: ${NACOS_CONFIG_ENABLED}
      SPRING_CLOUD_NACOS_DISCOVERY_USERNAME: ${NACOS_USERNAME:-nacos}
      SPRING_CLOUD_NACOS_DISCOVERY_PASSWORD: ${NACOS_PASSWORD:-nacos}
      SPRING_CLOUD_SERVICE_REGISTRY_AUTO_REGISTRATION_ENABLED: ${NACOS_DISCOVERY_ENABLED}
      TZ: ${TZ}
      JAVA_TOOL_OPTIONS: "-Xms512M -Xmx1G -XX:+UseG1GC -Dlogback.scan=false"
    volumes:
      - /opt/fzx/infrastructure/logs/platform-service-aliyun:/logs
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"
    deploy:
      resources:
        limits:
          cpus: "0.5"
          memory: "768M"
        reservations:
          cpus: "0.4"
          memory: "512M"
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:8089/actuator/health" ]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s
    depends_on:
      mariadb:
        condition: service_healthy
      redis:
        condition: service_healthy
      nacos:
        condition: service_healthy

  nginx:
    container_name: fzx-aliyun-nginx
    image: docker.m.daocloud.io/library/nginx:1.25.5
    restart: always
    networks:
      fzx-devops-net:
        aliases:
          - nginx
    ports:
      - "0.0.0.0:80:80"
      - "0.0.0.0:443:443"
    volumes:
      - /opt/fzx/infrastructure/nginx/conf/aliyun-dev.conf:/etc/nginx/nginx.conf:ro
      - /opt/fzx/infrastructure/logs/nginx-aliyun:/var/log/nginx
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"
    deploy:
      resources:
        limits:
          cpus: "0.15"
          memory: "256M"
        reservations:
          cpus: "0.075"
          memory: "128M"
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:80/" ]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 30s

  jenkins:
    container_name: fzx-aliyun-jenkins
    build:
      context: infrastructure/images/jenkins
      dockerfile: Containerfile
    restart: always
    networks:
      fzx-devops-net:
        aliases:
          - jenkins
    ports:
      - "0.0.0.0:8099:8099"
    volumes:
      - fzx-aliyun-jenkins-data:/var/jenkins_home
      - /opt/fzx/infrastructure/logs/jenkins-aliyun:/var/log/jenkins
      - /var/run/podman/podman.sock:/var/run/podman/podman.sock
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    environment:
      - TZ=Asia/Shanghai
      - JENKINS_HOME=/var/jenkins_home
      - 'JAVA_OPTS=-Xms1024m -Xmx2048m -XX:MaxMetaspaceSize=512m -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:+UseStringDeduplication -Djava.awt.headless=true -Djenkins.install.runSetupWizard=false'
      - 'JENKINS_OPTS=--httpPort=8099 --prefix=/jenkins --sessionTimeout=86400'
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"
    deploy:
      resources:
        limits:
          cpus: "1.0"
          memory: "2G"
        reservations:
          cpus: "0.5"
          memory: "1G"
    healthcheck:
      test: [ "CMD", "wget", "-qO-", "--timeout=5", "http://localhost:8099/jenkins/login" ]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 120s

volumes:
  fzx-aliyun-registry-data:
    name: fzx-aliyun-registry-data
    driver: local
  fzx-aliyun-mariadb-data:
    name: fzx-aliyun-mariadb-data
    driver: local
  fzx-aliyun-redis-data:
    name: fzx-aliyun-redis-data
    driver: local
  fzx-aliyun-nacos-data:
    name: fzx-aliyun-nacos-data
    driver: local
  fzx-aliyun-jenkins-data:
    name: fzx-aliyun-jenkins-data
    driver: local
#  fzx-aliyun-prometheus-data:
#    name: fzx-aliyun-prometheus-data
#    driver: local
#  fzx-aliyun-grafana-data:
#    name: fzx-aliyun-grafana-data
#    driver: local

