Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
T
think-tank
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
张京坤
think-tank
Commits
011e40cc
提交
011e40cc
authored
5月 06, 2025
作者:
wangfeng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'yjzx_test' into yjzx_dev
上级
44086333
b112163b
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
143 行增加
和
85 行删除
+143
-85
Dockerfile
build/Dockerfile
+8
-2
build.sh
build/build.sh
+6
-3
env.prod
build/env/env.prod
+24
-10
env.test
build/env/env.test
+22
-8
run.sh
build/run.sh
+26
-16
pom.xml
pom.xml
+8
-3
ThinkTankApplication.java
src/main/java/com/zzsn/thinktank/ThinkTankApplication.java
+2
-3
WebConfig.java
src/main/java/com/zzsn/thinktank/config/WebConfig.java
+5
-4
application-dev.yml
src/main/resources/application-dev.yml
+7
-11
application-prod.yml
src/main/resources/application-prod.yml
+7
-12
application-test.yml
src/main/resources/application-test.yml
+7
-13
bootstrap.yml
src/main/resources/bootstrap.yml
+21
-0
没有找到文件。
build/Dockerfile
浏览文件 @
011e40cc
...
...
@@ -17,14 +17,20 @@ WORKDIR /workspace
COPY
--from=builder /workspace/target/*.jar /workspace/app.jar
ARG
ENV_NAME
ARG
NACOS_SERVER
ARG
NACOS_NAMESPACE
ARG
NACOS_REGISTER_IP
ARG
PORT
ENV
APP_OPTS1="-Dspring.profiles.active=${ENV_NAME}"
ENV
APP_OPTS2="-Djasypt.encryptor.password=1@wdLkj90#chMsdzxA%2024"
ENV
APP_OPTS3="-Dfile.encoding=utf-8"
ENV
APP_OPTS4="-Duser.timezone=Asia/Shanghai"
ENV
APP_OPTS5="-DNACOS_SERVER=${NACOS_SERVER}"
ENV
APP_OPTS6="-DNACOS_NAMESPACE=${NACOS_NAMESPACE}"
ENV
APP_OPTS7="-DNACOS_REGISTER_IP=${NACOS_REGISTER_IP}"
ENV
JVM_OPTS="-Xmx2024M -Xms256M"
EXPOSE
${PORT}
ENTRYPOINT
["sh","-c","java $APP_OPTS1 $APP_OPTS2 $APP_OPTS3 $APP_OPTS4 -jar $JVM_OPTS /workspace/app.jar"]
\ No newline at end of file
ENTRYPOINT
["sh","-c","java $APP_OPTS1 $APP_OPTS2 $APP_OPTS3 $APP_OPTS4 $APP_OPTS5 $APP_OPTS6 $APP_OPTS7 -jar $JVM_OPTS /workspace/app.jar"]
\ No newline at end of file
build/build.sh
浏览文件 @
011e40cc
...
...
@@ -33,24 +33,27 @@ function handle {
local
username
=
"
${
repo_username
}
"
local
passwd
=
"
${
repo_passwd
}
"
local
dir
=
"
${
root_dir
}
/
${
svc_name
}
/
${
svc_env
}
"
local
name
=
"
${
svc_name
}
-
${
svc_env
}
"
local
version
=
${
version
}
-
${
build_timestamp
}
# local internal_ip="${internal_ip}"
echo
"构建名称:
${
name
}
"
echo
"构建端口:
${
svc_port
}
"
echo
"部署节点:
${
internal_ip
[@]
}
"
echo
"构建版本:
${
version
}
"
echo
"推送仓库:
${
domain
}
/
${
namespace
}
"
echo
"完整镜像:
${
domain
}
/
${
namespace
}
/
${
name
}
:
${
version
}
"
echo
"---构建镜像---"
docker build
--build-arg
ENV_NAME
=
${
svc_env
}
--build-arg
PORT
=
${
svc_port
}
-f
./build/Dockerfile
-t
${
domain
}
/
${
namespace
}
/
${
name
}
:
${
version
}
.
docker build
--build-arg
NACOS_REGISTER_IP
=
${
internal_ip
}
--build-arg
NACOS_SERVER
=
${
nacos_server
}
--build-arg
NACOS_NAMESPACE
=
${
nacos_namespace
}
\
--build-arg
ENV_NAME
=
${
svc_env
}
--build-arg
PORT
=
${
svc_port
}
-f
./build/Dockerfile
-t
${
domain
}
/
${
namespace
}
/
${
name
}
:
${
version
}
.
echo
"---推送镜像---"
docker login
-u
=
$username
-p
=
${
passwd
}
${
domain
}
docker push
${
domain
}
/
${
namespace
}
/
${
name
}
:
${
version
}
echo
"---清理none镜像---"
echo
"---清理废弃容器和none镜像---"
docker container prune
-f
docker image prune
-af
}
...
...
build/env/env.prod
浏览文件 @
011e40cc
# 镜像仓库
# 版本 T1.0.0: T为测试版,R为稳定版
version="
R
1.0.0" # 可自定义
# 镜像仓库地址
#
#
版本 T1.0.0: T为测试版,R为稳定版
version="
T
1.0.0" # 可自定义
#
#
镜像仓库地址
domain="swr.cn-southwest-2.myhuaweicloud.com"
# 镜像分组,按部门区分
#
#
镜像分组,按部门区分
namespace="wd"
# 服务配置
# 数据挂载根目录
## 部署节点的内网IP
internal_ip=192.168.0.229
## 数据挂载根目录
root_dir="/zzsn"
# 需根据日志配置填写,比如:logback-spring.xml
#
#
需根据日志配置填写,比如:logback-spring.xml
svc_logs="/workspace/logs"
# 环境变量 test or prod
#
#
环境变量 test or prod
svc_env="prod"
# 服务名
#
#
服务名
svc_name="think-tank"
# 服务端口
svc_port="9098"
## 服务端口
svc_port="9099"
# nacos配置
## 往nacos注册IP,配置文件使用变量 NACOS_REGISTER_IP
## nacos服务地址, 配置文件使用 NACOS_SERVER
nacos_server="192.168.0.249:8848"
## nacos命名空间, 配置文件使用 NACOS_NAMESPACE
nacos_namespace="smartProd"
# 资源限制
## cpu
limit_cpu=1.0
limit_mem=2g
build/env/env.test
浏览文件 @
011e40cc
# 镜像仓库
# 版本 T1.0.0: T为测试版,R为稳定版
#
#
版本 T1.0.0: T为测试版,R为稳定版
version
=
"T1.0.0"
# 可自定义
# 镜像仓库地址
#
#
镜像仓库地址
domain
=
"swr.cn-southwest-2.myhuaweicloud.com"
# 镜像分组,按部门区分
#
#
镜像分组,按部门区分
namespace
=
"wd"
# 服务配置
# 数据挂载根目录
## 部署节点的内网IP
internal_ip
=
(
"192.168.0.19"
"192.168.0.249"
)
## 数据挂载根目录
root_dir
=
"/zzsn"
# 需根据日志配置填写,比如:logback-spring.xml
#
#
需根据日志配置填写,比如:logback-spring.xml
svc_logs
=
"/workspace/logs"
# 环境变量 test or prod
#
#
环境变量 test or prod
svc_env
=
"test"
# 服务名
#
#
服务名
svc_name
=
"think-tank"
# 服务端口
#
#
服务端口
svc_port
=
"9099"
# nacos配置
## 往nacos注册IP,配置文件使用变量 NACOS_REGISTER_IP
## nacos服务地址, 配置文件使用 NACOS_SERVER
nacos_server
=
"192.168.0.249:8848"
## nacos命名空间, 配置文件使用 NACOS_NAMESPACE
nacos_namespace
=
"smartTest"
# 资源限制
## cpu
limit_cpu
=
1.0
limit_mem
=
2
g
build/run.sh
浏览文件 @
011e40cc
...
...
@@ -34,26 +34,36 @@ function handle {
local
dir
=
"
${
root_dir
}
/
${
svc_name
}
/
${
svc_env
}
"
local
name
=
"
${
svc_name
}
-
${
svc_env
}
"
local
version
=
${
version
}
-
${
build_timestamp
}
# local internal_ip="${internal_ip}"
local
api_key
=
"uOyKfp20pdM3MFhr3KAQBoe1UHCaZLUeeLephB57MPvGXTY05Eis5eaxta6fEtpa"
echo
"---运行容器:
${
name
}
:
${
version
}
---"
# 构建 JSON 数据
json_data
=
"{
\
\"
container_name
\"
:
\"
$name
\"
,
\
\"
image_version
\"
:
\"
$domain
/
$namespace
/
$name
:
$version
\"
,
\
\"
ports
\"
: [
\"
$svc_port
:
$svc_port
\"
],
\
\"
mount_infos
\"
: [
\"
/etc/localtime:/etc/localtime:ro
\"
,
\"
$dir
/logs:
$svc_logs
\"
],
\
\"
cpu_count
\"
:
$limit_cpu
,
\
\"
memory_limit
\"
:
\"
$limit_mem
\"
,
\
\"
ulimit
\"
:
\"
nofile=65535:65535
\"
\
}"
docker pull
${
domain
}
/
${
namespace
}
/
${
name
}
:
${
version
}
if
[
"
$(
docker ps
-aqf
"name=^
${
name
}
"
)
"
]
;
then
# 如果存在,则停止并删除容器
echo
"停止并删除容器:
${
name
}
"
docker rm
-f
"
${
name
}
"
else
echo
"容器不存在直接运行:
${
name
}
"
fi
docker run
--restart
always
-d
-p
${
svc_port
}
:
${
svc_port
}
--name
${
name
}
\
-v
/etc/localtime:/etc/localtime:ro
\
-v
${
dir
}
/logs:
${
svc_logs
}
\
${
domain
}
/
${
namespace
}
/
${
name
}
:
${
version
}
echo
"执行的环境变量:
${
env_name
}
"
# 遍历 internal_ip 数组
for
ip
in
"
${
internal_ip
[@]
}
"
;
do
echo
"正在向
$ip
发送请求..."
# 发送 curl 请求并获取响应
response
=
$(
curl
-s
-X
POST
-H
"Content-Type: application/json"
-H
"X-API-Key:
$api_key
"
-d
"
$json_data
"
"http://
$ip
:10080/start-container"
)
echo
"响应结果:
${
response
}
"
# 检查响应中是否包含 "successfully
"
if
echo
"
$response
"
|
grep
-q
"successfully"
;
then
echo
"在
$ip
上部署成功"
else
echo
"在
$ip
上部署失败"
fi
done
echo
"---清理none镜像---"
docker image prune
-af
}
# 主程序入口点
...
...
pom.xml
浏览文件 @
011e40cc
...
...
@@ -96,9 +96,14 @@
<!-- 注册中心-->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-netflix-eureka-client
</artifactId>
<version>
2.1.5.RELEASE
</version>
<groupId>
com.alibaba.cloud
</groupId>
<artifactId>
spring-cloud-starter-alibaba-nacos-discovery
</artifactId>
<version>
2.1.4.RELEASE
</version>
</dependency>
<dependency>
<groupId>
com.alibaba.cloud
</groupId>
<artifactId>
spring-cloud-starter-alibaba-nacos-config
</artifactId>
<version>
2.1.4.RELEASE
</version>
</dependency>
<dependency>
...
...
src/main/java/com/zzsn/thinktank/ThinkTankApplication.java
浏览文件 @
011e40cc
...
...
@@ -3,13 +3,12 @@ package com.zzsn.thinktank;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.netflix.eureka.EnableEurekaClient
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
@SpringBootApplication
//@EnableAsync
@MapperScan
(
value
=
{
"com.zzsn.thinktank.mapper*"
})
@Enable
Eureka
Client
@Enable
Discovery
Client
public
class
ThinkTankApplication
{
public
static
void
main
(
String
[]
args
)
{
...
...
src/main/java/com/zzsn/thinktank/config/WebConfig.java
浏览文件 @
011e40cc
...
...
@@ -67,10 +67,10 @@ public class WebConfig implements WebMvcConfigurer {
}
@Override
public
void
addCorsMappings
(
CorsRegistry
registry
){
registry
.
addMapping
(
"/**"
)
.
allowedOrigins
(
"*"
)
.
allowedMethods
(
"*"
)
.
allowedHeaders
(
"*"
);
//
registry.addMapping("/**")
//
.allowedOrigins("*")
//
.allowedMethods("*")
//
.allowedHeaders("*");
}
}
\ No newline at end of file
src/main/resources/application-dev.yml
浏览文件 @
011e40cc
server
:
port
:
9099
eureka
:
instance
:
#注册到注册中心通过Feign调用时,hostname必须是服务器ip
hostname
:
1.95.42.138
instance-id
:
1.95.42.138:9099
prefer-ip-address
:
false
client
:
register-with-eureka
:
true
fetch-registry
:
false
service-url
:
defaultZone
:
http://sasac:Sasac09ckJHyujT!W@192.168.200.226:8017/eureka/
spring
:
cloud
:
nacos
:
config
:
namespace
:
smartDev
discovery
:
namespace
:
smartDev
src/main/resources/application-prod.yml
浏览文件 @
011e40cc
server
:
port
:
9098
eureka
:
instance
:
#注册到注册中心通过Feign调用时,hostname必须是服务器ip
hostname
:
1.95.42.138
instance-id
:
1.95.42.138:9098
prefer-ip-address
:
false
client
:
register-with-eureka
:
true
fetch-registry
:
false
service-url
:
defaultZone
:
http://sasac:BE4cYRvN2WG!YV5z@106.38.99.147:20717/eureka/
\ No newline at end of file
spring
:
cloud
:
nacos
:
discovery
:
ip
:
${NACOS_REGISTER_IP}
port
:
${server.port}
\ No newline at end of file
src/main/resources/application-test.yml
浏览文件 @
011e40cc
server
:
port
:
9099
eureka
:
instance
:
#注册到注册中心通过Feign调用时,hostname必须是服务器ip
hostname
:
1.95.42.138
instance-id
:
1.95.42.138:9099
prefer-ip-address
:
false
client
:
register-with-eureka
:
true
fetch-registry
:
false
service-url
:
#线上测试环境
defaultZone
:
http://sasac:Sasac09ckJHyujT!W@106.38.99.147:20591/eureka/
\ No newline at end of file
spring
:
cloud
:
nacos
:
discovery
:
ip
:
${NACOS_REGISTER_IP}
port
:
${server.port}
\ No newline at end of file
src/main/resources/bootstrap.yml
0 → 100644
浏览文件 @
011e40cc
spring
:
cloud
:
nacos
:
config
:
server-addr
:
${NACOS_SERVER}
username
:
ZZSN(ZIgriRlkxZ2g3SxM9x6sVYcMQe2QVxXx0/l4BAivWsTeVPkAYERSKxlHxzUwHF5M)
password
:
ZZSN(zB38iUSsp2RptT9HMrjJ0qGdSJ5iwq3jToor7ozqfMOYTiC6RwOvAxdayF7x9qm/)
file-extension
:
yml
namespace
:
${NACOS_NAMESPACE:smartDev}
discovery
:
server-addr
:
${NACOS_SERVER}
username
:
ZZSN(ZIgriRlkxZ2g3SxM9x6sVYcMQe2QVxXx0/l4BAivWsTeVPkAYERSKxlHxzUwHF5M)
password
:
ZZSN(zB38iUSsp2RptT9HMrjJ0qGdSJ5iwq3jToor7ozqfMOYTiC6RwOvAxdayF7x9qm/)
namespace
:
${NACOS_NAMESPACE:smartDev}
jasypt
:
encryptor
:
property
:
prefix
:
ZZSN(
suffix
:
)
algorithm
:
PBEWITHHMACSHA512ANDAES_256
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论