version: "3"

services:
    mysql:
        image: mysql:8.0.34
        container_name: zac_mysql
        environment:
            # 时区上海 - Time zone Shanghai (Change if needed)
            TZ: Asia/Shanghai
            # root 密码 - root password
            MYSQL_ROOT_PASSWORD: zacyfg87gyuYiy1
            MYSQL_DATABASE: zac
            MYSQL_USER: zac
            MYSQL_PASSWORD: zac5vg67b3UNHu8
        ports:
            - "22201:3306"
        volumes:
            # 数据挂载 - Data mounting
            - ./data/mysql/data:/var/lib/mysql
            # 日志
        command:
            # 将mysql8.0默认密码策略 修改为 原先 策略 (mysql8.0对其默认策略做了更改 会导致密码无法匹配)
            # Modify the Mysql 8.0 default password strategy to the original strategy (MySQL8.0 to change its default strategy will cause the password to be unable to match)
            --default-authentication-plugin=mysql_native_password
            --character-set-server=utf8mb4
            --collation-server=utf8mb4_general_ci
            --explicit_defaults_for_timestamp=true
            --lower_case_table_names=1
        privileged: true
        restart: always
        networks:
            - zac_net
           
           

    redis:
        image: redis:7.4.0
        container_name: zac_redis
        ports:
            - "22202:6379"
        environment:
            # 时区上海 - Time zone Shanghai (Change if needed)
            TZ: Asia/Shanghai
        volumes:
            # 数据文件 - data files
            - ./data/redis/data:/data:rw
        command: "redis-server --requirepass zac3m3WsgyCKWqz  --appendonly yes"
        privileged: true
        restart: always
        networks:
            - zac_net

    asynqmon:
        image: hibiken/asynqmon:latest
        container_name: zac_asynqmon
        ports:
            - "22203:8080"
        environment:
            - TZ=Asia/Shanghai
        command:
            - "--redis-addr=zac_redis:6379"
            - "--redis-password=zac3m3WsgyCKWqz"
        restart: always
        networks:
            - zac_net
        depends_on:
            - redis

    main:
        container_name: zac_main
        build:
            context: .
            dockerfile: app/main/api/Dockerfile
        ports:
            - "22204:8888"
        volumes:
            - ./data/authorization_docs:/app/data/authorization_docs:rw
        environment:
            - TZ=Asia/Shanghai
            - ENV=production
        depends_on:
            - mysql
            - redis
        networks:
            - zac_net
        restart: always

networks:
    zac_net:
        driver: bridge

