diff --git a/env/nacos-hostname.env b/env/nacos-hostname.env index 63baaa7..79f2dd1 100644 --- a/env/nacos-hostname.env +++ b/env/nacos-hostname.env @@ -5,4 +5,5 @@ MYSQL_SERVICE_HOST=mysql MYSQL_SERVICE_DB_NAME=nacos_devtest MYSQL_SERVICE_PORT=3306 MYSQL_SERVICE_USER=nacos -MYSQL_SERVICE_PASSWORD=nacos \ No newline at end of file +MYSQL_SERVICE_PASSWORD=nacos +MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true \ No newline at end of file diff --git a/env/nacos-ip.env b/env/nacos-ip.env index c37d9b6..d6becaf 100644 --- a/env/nacos-ip.env +++ b/env/nacos-ip.env @@ -4,4 +4,5 @@ MYSQL_SERVICE_HOST=mysql MYSQL_SERVICE_DB_NAME=nacos_devtest MYSQL_SERVICE_PORT=3306 MYSQL_SERVICE_USER=nacos -MYSQL_SERVICE_PASSWORD=nacos \ No newline at end of file +MYSQL_SERVICE_PASSWORD=nacos +MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true \ No newline at end of file diff --git a/env/nacos-standlone-mysql.env b/env/nacos-standlone-mysql.env index a724d15..993a9a0 100644 --- a/env/nacos-standlone-mysql.env +++ b/env/nacos-standlone-mysql.env @@ -6,4 +6,4 @@ 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=1000&socketTimeout=3000&autoReconnect=true&useSSL=false \ No newline at end of file +MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true \ No newline at end of file diff --git a/example/cluster-embedded.yaml b/example/cluster-embedded.yaml index 02971ee..40f5ab0 100644 --- a/example/cluster-embedded.yaml +++ b/example/cluster-embedded.yaml @@ -6,7 +6,6 @@ services: image: nacos/nacos-server:${NACOS_VERSION} volumes: - ./cluster-logs/nacos1:/home/nacos/logs - - ./init.d/custom.properties:/home/nacos/init.d/custom.properties ports: - "8848:8848" - "9848:9848" @@ -21,7 +20,6 @@ services: container_name: nacos2 volumes: - ./cluster-logs/nacos2:/home/nacos/logs - - ./init.d/custom.properties:/home/nacos/init.d/custom.properties ports: - "8849:8848" - "9849:9848" @@ -34,7 +32,6 @@ services: container_name: nacos3 volumes: - ./cluster-logs/nacos3:/home/nacos/logs - - ./init.d/custom.properties:/home/nacos/init.d/custom.properties ports: - "8850:8848" - "9850:9848" diff --git a/example/cluster-hostname.yaml b/example/cluster-hostname.yaml index 2f97840..1618b98 100644 --- a/example/cluster-hostname.yaml +++ b/example/cluster-hostname.yaml @@ -1,4 +1,4 @@ -version: "3" +version: "3.8" services: nacos1: hostname: nacos1 @@ -6,7 +6,6 @@ services: image: nacos/nacos-server:${NACOS_VERSION} volumes: - ./cluster-logs/nacos1:/home/nacos/logs - - ./init.d/custom.properties:/home/nacos/init.d/custom.properties ports: - "8848:8848" - "9848:9848" @@ -15,7 +14,8 @@ services: - ../env/nacos-hostname.env restart: always depends_on: - - mysql + mysql: + condition: service_healthy nacos2: hostname: nacos2 @@ -23,7 +23,6 @@ services: container_name: nacos2 volumes: - ./cluster-logs/nacos2:/home/nacos/logs - - ./init.d/custom.properties:/home/nacos/init.d/custom.properties ports: - "8849:8848" - "9849:9848" @@ -31,14 +30,14 @@ services: - ../env/nacos-hostname.env restart: always depends_on: - - mysql + mysql: + condition: service_healthy nacos3: hostname: nacos3 image: nacos/nacos-server:${NACOS_VERSION} container_name: nacos3 volumes: - ./cluster-logs/nacos3:/home/nacos/logs - - ./init.d/custom.properties:/home/nacos/init.d/custom.properties ports: - "8850:8848" - "9850:9848" @@ -46,14 +45,25 @@ services: - ../env/nacos-hostname.env restart: always depends_on: - - mysql + mysql: + condition: service_healthy mysql: container_name: mysql - image: nacos/nacos-mysql:5.7 + build: + context: . + dockerfile: ./image/mysql/5.7/Dockerfile + tags: + - "example/mysql:5.7" + image: example/mysql:5.7 env_file: - ../env/mysql.env volumes: - ./mysql:/var/lib/mysql ports: - "3306:3306" + healthcheck: + test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ] + interval: 5s + timeout: 10s + retries: 10 diff --git a/example/cluster-ip.yaml b/example/cluster-ip.yaml index a90aa5f..55e4582 100644 --- a/example/cluster-ip.yaml +++ b/example/cluster-ip.yaml @@ -1,4 +1,4 @@ -version: "2" +version: "3.8" services: nacos1: image: nacos/nacos-server:${NACOS_VERSION} @@ -16,7 +16,8 @@ services: - ../env/nacos-ip.env restart: on-failure depends_on: - - mysql + mysql: + condition: service_healthy nacos2: image: nacos/nacos-server:${NACOS_VERSION} @@ -33,7 +34,8 @@ services: - ../env/nacos-ip.env restart: always depends_on: - - mysql + mysql: + condition: service_healthy nacos3: image: nacos/nacos-server:${NACOS_VERSION} container_name: nacos3 @@ -49,10 +51,16 @@ services: - ../env/nacos-ip.env restart: always depends_on: - - mysql + mysql: + condition: service_healthy mysql: container_name: mysql - image: nacos/nacos-mysql:5.7 + build: + context: . + dockerfile: ./image/mysql/5.7/Dockerfile + tags: + - "example/mysql:5.7" + image: example/mysql:5.7 networks: nacos_net: ipv4_address: 172.16.238.13 @@ -62,6 +70,11 @@ services: - ./mysql:/var/lib/mysql ports: - "3306:3306" + healthcheck: + test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ] + interval: 5s + timeout: 10s + retries: 10 networks: nacos_net: driver: bridge diff --git a/example/image/mysql/5.7/Dockerfile b/example/image/mysql/5.7/Dockerfile new file mode 100644 index 0000000..d827376 --- /dev/null +++ b/example/image/mysql/5.7/Dockerfile @@ -0,0 +1,5 @@ +FROM mysql:5.7.39 +ADD https://raw.githubusercontent.com/alibaba/nacos/develop/distribution/conf/mysql-schema.sql /docker-entrypoint-initdb.d/nacos-mysql.sql +RUN chown -R mysql:mysql /docker-entrypoint-initdb.d/nacos-mysql.sql +EXPOSE 3306 +CMD ["mysqld", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"] \ No newline at end of file diff --git a/example/image/mysql/8/Dockerfile b/example/image/mysql/8/Dockerfile new file mode 100644 index 0000000..d4be7c6 --- /dev/null +++ b/example/image/mysql/8/Dockerfile @@ -0,0 +1,5 @@ +FROM mysql:8.0.30 +ADD https://raw.githubusercontent.com/alibaba/nacos/develop/distribution/conf/mysql-schema.sql /docker-entrypoint-initdb.d/nacos-mysql.sql +RUN chown -R mysql:mysql /docker-entrypoint-initdb.d/nacos-mysql.sql +EXPOSE 3306 +CMD ["mysqld", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"] \ No newline at end of file diff --git a/example/standalone-derby.yaml b/example/standalone-derby.yaml index 2363306..3cbbc2c 100644 --- a/example/standalone-derby.yaml +++ b/example/standalone-derby.yaml @@ -4,14 +4,13 @@ services: image: nacos/nacos-server:${NACOS_VERSION} container_name: nacos-standalone environment: - - PREFER_HOST_MODE=hostname - - MODE=standalone + - PREFER_HOST_MODE=hostname + - MODE=standalone volumes: - - ./standalone-logs/:/home/nacos/logs - - ./init.d/custom.properties:/home/nacos/init.d/custom.properties + - ./standalone-logs/:/home/nacos/logs ports: - - "8848:8848" - - "9848:9848" + - "8848:8848" + - "9848:9848" prometheus: container_name: prometheus image: prom/prometheus:latest diff --git a/example/standalone-mysql-5.7.yaml b/example/standalone-mysql-5.7.yaml index 4d0cee2..5176ec3 100644 --- a/example/standalone-mysql-5.7.yaml +++ b/example/standalone-mysql-5.7.yaml @@ -1,4 +1,4 @@ -version: "2" +version: "3.8" services: nacos: image: nacos/nacos-server:${NACOS_VERSION} @@ -13,17 +13,29 @@ services: - "9848:9848" - "9555:9555" depends_on: - - mysql + mysql: + condition: service_healthy + restart: on-failure mysql: container_name: mysql - image: nacos/nacos-mysql:5.7 + build: + context: . + dockerfile: ./image/mysql/5.7/Dockerfile + tags: + - "example/mysql:5.7" + image: example/mysql:5.7 env_file: - ../env/mysql.env volumes: - ./mysql:/var/lib/mysql ports: - "3306:3306" + healthcheck: + test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ] + interval: 5s + timeout: 10s + retries: 10 # prometheus: # container_name: prometheus # image: prom/prometheus:latest diff --git a/example/standalone-mysql-8.yaml b/example/standalone-mysql-8.yaml index 3835d12..d7b7802 100644 --- a/example/standalone-mysql-8.yaml +++ b/example/standalone-mysql-8.yaml @@ -1,4 +1,4 @@ -version: "2" +version: "3.8" services: nacos: image: nacos/nacos-server:${NACOS_VERSION} @@ -7,22 +7,32 @@ services: - ../env/nacos-standlone-mysql.env volumes: - ./standalone-logs/:/home/nacos/logs - - ./init.d/custom.properties:/home/nacos/init.d/custom.properties ports: - "8848:8848" - "9848:9848" - "9555:9555" depends_on: - - mysql + mysql: + condition: service_healthy restart: always mysql: container_name: mysql - image: nacos/nacos-mysql:8.0.16 + build: + context: . + dockerfile: ./image/mysql/8/Dockerfile + tags: + - "example/mysql:8.0.30" + image: example/mysql:8.0.30 env_file: - ../env/mysql.env volumes: - ./mysql:/var/lib/mysql ports: - "3306:3306" + healthcheck: + test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ] + interval: 5s + timeout: 10s + retries: 10