version: '3'
# 默认使用 flink 1.13.3

services:
  # 配置 dinky 后端服务
  dinky-server:
    image: sivacohan/dinky-server:lastest
    build:
      context: .
      dockerfile: ./docker/server/Dockerfile
#    command: [ "/bin/sh", "-c", "java -Dloader.path=./lib,./plugins -Ddruid.mysql.usePingMethod=false -jar -Xms512M -Xmx2048M ./dlink-admin-*.jar" ]
#    volumes:
#      # 挂载dinky lib/plugins 目录
#      - ./docker/dinky/lib:/app/lib
#      - ./docker/dinky/plugins:/app/plugins
    environment:
      SPRING_DATASOURCE_URL: jdbc:mysql://database:3306/dlink?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
    depends_on:
      - database
    restart: unless-stopped

  # 配置 dinky web 界面
  dinky-web:
    image: sivacohan/dinky-web:lastest
    build:
      context: .
      dockerfile: ./docker/web/Dockerfile
    environment:
      # API_HOST dinky 后端服务地址 (可以是IP、或者Hostname)
      # API_HOST dinky 后端服务端口
      API_HOST: dinky-server
      API_PORT: 8888
    ports:
      - "8080:80"
    depends_on:
      - dinky-server
      - database

  # 配置 mysql5.7 数据库
  database:
    image: sivacohan/dinky-mysql-server:5.7
    build:
      context: .
      dockerfile: ./docker/mysql/Dockerfile
    command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
    ports:
      - 3306:3306
    volumes:
      - mysql-data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: 123456
      MYSQL_DATABASE: dlink
      MYSQL_USER: dlink
      MYSQL_PASSWORD: dlink
    healthcheck:
      test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
      timeout: 20s
      retries: 10
    restart: unless-stopped


volumes:
  mysql-data: