diff --git a/jeecg-boot/jeecg-boot-starter/jeecg-boot-starter-cloud/nacos/jeecg-dev.yaml b/jeecg-boot/jeecg-boot-starter/jeecg-boot-starter-cloud/nacos/jeecg-dev.yaml index 0288e1f2..c01ff326 100644 --- a/jeecg-boot/jeecg-boot-starter/jeecg-boot-starter-cloud/nacos/jeecg-dev.yaml +++ b/jeecg-boot/jeecg-boot-starter/jeecg-boot-starter-cloud/nacos/jeecg-dev.yaml @@ -35,9 +35,9 @@ spring: datasource: master: - url: jdbc:mysql://127.0.0.1:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai - username: root - password: root + url: jdbc:mysql://${MYSQL-HOST:jeecg-boot-mysql}:${MYSQL-PORT:3306}/${MYSQL-DB:jeecg-boot}?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai + username: ${MYSQL-USER:root} + password: ${MYSQL-PWD:root} driver-class-name: com.mysql.cj.jdbc.Driver # 多数据源配置 #multi-datasource1: @@ -48,7 +48,7 @@ spring: #redis 配置 redis: database: 0 - host: 127.0.0.1 + host: jeecg-boot-redis lettuce: pool: max-active: 8 #最大连接数据库连接数,设 0 为没有限制 @@ -60,7 +60,7 @@ spring: port: 6379 #rabbitmq配置 rabbitmq: - host: 127.0.0.1 + host: jeecg-boot-rabbitmq username: guest password: guest port: 5672 @@ -129,7 +129,7 @@ jeecg : #xxl-job配置 xxljob: enabled: false - adminAddresses: http://127.0.0.1:9080/xxl-job-admin + adminAddresses: http://jeecg-boot-xxljob:9080/xxl-job-admin appname: ${spring.application.name} accessToken: '' logPath: logs/jeecg/job/jobhandler/ @@ -142,7 +142,7 @@ jeecg : data-type: yml #分布式锁配置 redisson: - address: 127.0.0.1:6379 + address: jeecg-boot-redis:6379 password: type: STANDALONE enabled: true diff --git a/jeecg-boot/jeecg-cloud-module/docker-compose.yml b/jeecg-boot/jeecg-cloud-module/docker-compose.yml index f3d73cfe..125501da 100644 --- a/jeecg-boot/jeecg-cloud-module/docker-compose.yml +++ b/jeecg-boot/jeecg-cloud-module/docker-compose.yml @@ -28,28 +28,18 @@ services: hostname: jeecg-boot-redis jeecg-boot-nacos: - restart: always - image: nacos/nacos-server:1.4.0 - container_name: jeecg-boot-nacos - hostname: jeecg-boot-nacos + restart: on-failure + build: + context: ./jeecg-cloud-nacos ports: - 8848:8848 depends_on: - jeecg-boot-mysql -# volumes: -# - ./init/docker-startup.sh:/home/nacos/bin/docker-startup.sh -# - ./init/application.properties:/home/nacos/conf/application.properties - environment: - MODE: standalone - PREFER_HOST_MODE: hostname - SPRING_DATASOURCE_PLATFORM: mysql - MYSQL_SERVICE_HOST: jeecg-boot-mysql - MYSQL_SERVICE_PORT: 3306 - MYSQL_SERVICE_USER: root - MYSQL_SERVICE_PASSWORD: root - MYSQL_SERVICE_DB_NAME: nacos + container_name: jeecg-boot-nacos + hostname: jeecg-boot-nacos jeecg-boot-gateway: + restart: on-failure build: context: ./jeecg-cloud-gateway ports: diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-nacos/Dockerfile b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-nacos/Dockerfile new file mode 100644 index 00000000..df876e18 --- /dev/null +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-nacos/Dockerfile @@ -0,0 +1,15 @@ +FROM anapsix/alpine-java:8_server-jre_unlimited + +MAINTAINER jeecgos@163.com + +RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime + +RUN mkdir -p /jeecg-cloud-nacos + +WORKDIR /jeecg-cloud-nacos + +EXPOSE 8848 + +ADD ./target/jeecg-cloud-nacos-2.4.2.jar ./ + +CMD sleep 5;java -Dfile.encoding=utf-8 -Djava.security.egd=file:/dev/./urandom -jar jeecg-cloud-nacos-2.4.2.jar \ No newline at end of file diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-nacos/pom.xml b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-nacos/pom.xml new file mode 100644 index 00000000..6b46693e --- /dev/null +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-nacos/pom.xml @@ -0,0 +1,54 @@ + + + 4.0.0 + + jeecg-cloud-module + org.jeecgframework.boot + 2.4.2 + + jeecg-cloud-nacos + jeecg-cloud-nacos + nacos启动模块 + + + + org.apache.tomcat.embed + tomcat-embed-jasper + + + org.springframework.boot + spring-boot-starter-security + + + org.jeecgframework.nacos + nacos-naming + 1.4.1 + + + org.jeecgframework.nacos + nacos-istio + 1.4.1 + + + org.jeecgframework.nacos + nacos-config + 1.4.1 + + + org.jeecgframework.nacos + nacos-console + 1.4.1 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-nacos/src/main/java/com/alibaba/nacos/JeecgNacosApplication.java b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-nacos/src/main/java/com/alibaba/nacos/JeecgNacosApplication.java new file mode 100644 index 00000000..959a4a84 --- /dev/null +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-nacos/src/main/java/com/alibaba/nacos/JeecgNacosApplication.java @@ -0,0 +1,35 @@ +package com.alibaba.nacos; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.scheduling.annotation.EnableScheduling; + +/** + * Nacos 启动类 + * 引用的nacos console 源码运行,简化开发 + * 生产建议从官网下载最新版配置运行 + * @author zyf + */ +@SpringBootApplication(scanBasePackages = "com.alibaba.nacos") +@ServletComponentScan +@EnableScheduling +public class JeecgNacosApplication { + + /** + * 是否单机模式启动 + */ + private static String standalone = "true"; + + /** + * 是否开启鉴权 + */ + private static String enabled = "false"; + + public static void main(String[] args) { + System.setProperty("nacos.standalone", standalone); + System.setProperty("nacos.core.auth.enabled", enabled); + System.setProperty("server.tomcat.basedir","logs"); + SpringApplication.run(JeecgNacosApplication.class, args); + } +} diff --git a/jeecg-boot/jeecg-cloud-module/jeecg-cloud-nacos/src/main/resources/application.yml b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-nacos/src/main/resources/application.yml new file mode 100644 index 00000000..1c5cadf0 --- /dev/null +++ b/jeecg-boot/jeecg-cloud-module/jeecg-cloud-nacos/src/main/resources/application.yml @@ -0,0 +1,55 @@ +server: + port: 8848 + servlet: + contextPath: /nacos + tomcat: + accesslog: + enabled: true + pattern: '%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i' + basedir: '' +spring: + datasource: + platform: mysql +db: + num: 1 + password: + '0': ${MYSQL-PWD:root} + url: + '0': jdbc:mysql://${MYSQL-HOST:jeecg-boot-mysql}:${MYSQL-PORT:3306}/${MYSQL-DB:nacos}?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true + user: + '0': ${MYSQL-USER:root} +management: + metrics: + export: + elastic: + enabled: false + influx: + enabled: false +nacos: + core: + auth: + caching: + enabled: true + default: + token: + expire: + seconds: 18000 + secret: + key: SecretKey012345678901234567890123456789012345678901234567890123456789 + enabled: false + system: + type: nacos + istio: + mcp: + server: + enabled: false + naming: + empty-service: + auto-clean: true + clean: + initial-delay-ms: 50000 + period-time-ms: 30000 + security: + ignore: + urls: /,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/** + standalone: true \ No newline at end of file diff --git a/jeecg-boot/jeecg-cloud-module/pom.xml b/jeecg-boot/jeecg-cloud-module/pom.xml index a240afab..a98b6c23 100644 --- a/jeecg-boot/jeecg-cloud-module/pom.xml +++ b/jeecg-boot/jeecg-cloud-module/pom.xml @@ -16,6 +16,7 @@ jeecg-cloud-gateway jeecg-cloud-monitor jeecg-cloud-xxljob + jeecg-cloud-nacos