# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

services:
  nacos-mysql:
    image: nacos-mysql:5.7
    environment:
      - MYSQL_DATABASE=nacos_devtest
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_USER=nacos
      - MYSQL_PASSWORD=nacos
    expose:
      - 3306
    healthcheck:
      # mysql host MUST be ip address, if the host is localhost, may connect via socket file, the port will be ignored
      test: [ "CMD", "mysqladmin" ,"ping", "-h", "127.0.0.1" ]
      interval: 5s
      timeout: 5s
      retries: 20

  nacos:
    image: nacos/nacos-server:v2.1.2
    environment:
      - PREFER_HOST_MODE=hostname
      - MODE=standalone
      - NACOS_AUTH_ENABLE=true
      - SPRING_DATASOURCE_PLATFORM=mysql
      - MYSQL_SERVICE_HOST=nacos-mysql
      - MYSQL_SERVICE_DB_NAME=nacos_devtest
      - MYSQL_SERVICE_PORT=3306
      - MYSQL_SERVICE_USER=nacos
      - MYSQL_SERVICE_PASSWORD=nacos
      - MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=10000&socketTimeout=30000&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true
      - JVM_XMS=512m
      - JVM_XMX=512m
      - JVM_XMN=256m
    expose:
      - 8848
      - 9848
      - 9555
    depends_on:
      - nacos-mysql

  dubbo-samples-empty-protection-nacos:
    type: test
    basedir: .
    tests:
      - "**/*IT.class"
    systemProps:
      - nacos.address=nacos
      - nacos.port=8848
    waitPortsBeforeRun:
      - nacos:8848
    depends_on:
      - nacos

