version: '3.8'

networks:
  my-network:
    driver: bridge

services:
  # 1. 前端
  group-buy-market-front:
    image: nginx:alpine
    container_name: group-buy-market-front
    restart: always
    ports:
      - '86:80'
    volumes:
      - ./nginx/html:/usr/share/nginx/html
    privileged: true
    networks:
      - my-network

  # 2. Java 后端
  group-buying-sys:
    build:
      context: ../..         # 从 docs/dev-ops 回到项目根
      dockerfile: group-buying-sys-app/Dockerfile
    image: smile/group-buying-sys:latest
    container_name: group-buying-sys
    restart: on-failure
    depends_on:
      mysql:
        condition: service_healthy
      redis:
        condition: service_healthy
    ports:
      - '8091:8091'
    environment:
      - TZ=PRC
      - SERVER_PORT=8091
      - SPRING_DATASOURCE_USERNAME=root
      - SPRING_DATASOURCE_PASSWORD=123456
      - SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/big_market?useUnicode=true&characterEncoding=utf8&autoReconnect=true&serverTimezone=Asia/Shanghai&useSSL=false
      - SPRING_DATASOURCE_DRIVER_CLASS_NAME=com.mysql.cj.jdbc.Driver
      - SPRING_HIKARI_POOL_NAME=Retail_HikariCP
      - REDIS_SDK_CONFIG_HOST=redis
      - REDIS_SDK_CONFIG_PORT=6379
    volumes:
      - ./log:/data/log
    logging:
      driver: json-file
      options:
        max-size: '10m'
        max-file: '3'
    networks:
      - my-network

