nacos server本地化jar方式启动,简化开发

This commit is contained in:
zhangdaiscott 2021-03-09 11:40:13 +08:00
parent 64c861aa68
commit c5bb6143ba
7 changed files with 173 additions and 23 deletions

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>jeecg-cloud-module</artifactId>
<groupId>org.jeecgframework.boot</groupId>
<version>2.4.2</version>
</parent>
<artifactId>jeecg-cloud-nacos</artifactId>
<name>jeecg-cloud-nacos</name>
<description>nacos启动模块</description>
<dependencies>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.jeecgframework.nacos</groupId>
<artifactId>nacos-naming</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>org.jeecgframework.nacos</groupId>
<artifactId>nacos-istio</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>org.jeecgframework.nacos</groupId>
<artifactId>nacos-config</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>org.jeecgframework.nacos</groupId>
<artifactId>nacos-console</artifactId>
<version>1.4.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@ -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);
}
}

View File

@ -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

View File

@ -16,6 +16,7 @@
<module>jeecg-cloud-gateway</module>
<module>jeecg-cloud-monitor</module>
<module>jeecg-cloud-xxljob</module>
<module>jeecg-cloud-nacos</module>
</modules>