Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-boot-material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wxh
spring-boot-material
Commits
bcc419c7
Commit
bcc419c7
authored
Nov 07, 2019
by
XuYS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add jenkins files
parent
e6d16cc0
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
237 additions
and
1 deletions
+237
-1
Dockerfile
+12
-0
Jenkinsfile
+103
-0
k8s.yaml
+64
-0
src/main/resources/application-dev.yml
+44
-0
src/main/resources/application-k8s.yml
+8
-0
src/main/resources/application-local.yml
+5
-0
src/main/resources/application.yml
+1
-1
No files found.
Dockerfile
0 → 100644
View file @
bcc419c7
FROM
hub.orhoncloud.com/library/openjdk:8-jre-alpine
MAINTAINER
XuYS (xys@orhonit.com)
RUN
echo
"http://mirrors.aliyun.com/alpine/latest-stable/main/"
>
/etc/apk/repositories
RUN
echo
"http://mirrors.aliyun.com/alpine/latest-stable/community/"
>>
/etc/apk/repositories
ENV
NAME World
RUN
apk add
--no-cache
tzdata
ENV
TZ Asia/Shanghai
COPY
target/material-0.0.1-SNAPSHOT.jar /material-0.0.1-SNAPSHOT.jar
EXPOSE
8011
ENTRYPOINT
["java", "-jar", "/material-0.0.1-SNAPSHOT.jar"]
Jenkinsfile
0 → 100644
View file @
bcc419c7
node
(
'orhon-jnlp'
)
{
k8sAppName
=
"smartcampus-backend-material"
dataDir
=
"material"
k8sNamespace
=
"smartcampus-dev"
if
(
env
.
BRANCH_NAME
==
'master'
){
k8sNamespace
=
"smartcampus"
}
ingressHost
=
"material.dev.edu.mongol.pub"
if
(
env
.
BRANCH_NAME
==
'master'
){
ingressHost
=
"material.edu.mongol.pub"
}
servicePort
=
"8031"
if
(
env
.
BRANCH_NAME
==
'master'
){
servicePort
=
"8031"
}
podPort
=
"8031"
if
(
env
.
BRANCH_NAME
==
'master'
){
podPort
=
"8031"
}
registryAppName
=
"backend-material"
if
(
env
.
BRANCH_NAME
==
'master'
){
registryAppName
=
"backend-material"
}
stage
(
'Prepare'
)
{
echo
"1.Prepare Stage"
checkout
scm
echo
"----BRANCH_NAME: ${env.BRANCH_NAME }"
script
{
build_tag
=
sh
(
returnStdout:
true
,
script:
'git rev-parse --short HEAD'
).
trim
()
echo
"${env.BRANCH_NAME}-${build_tag}"
build_tag
=
"${env.BRANCH_NAME}-${build_tag}"
}
}
stage
(
'SET application config Stage'
)
{
echo
"2.SET application config Stage"
if
(
env
.
BRANCH_NAME
==
'develop'
)
{
sh
"sed -i 's/<APP-ACTIVE-CONFIG>/dev/' src/main/resources/application.yml"
}
else
if
(
env
.
BRANCH_NAME
==
'master'
){
sh
"sed -i 's/<APP-ACTIVE-CONFIG>/k8s/' src/main/resources/application.yml"
}
}
stage
(
'3 Build Maven Package'
)
{
echo
"3.1 Build Maven Package"
if
(
env
.
BRANCH_NAME
==
'develop'
)
{
echo
"3.1 Build Maven Package develop Branch"
sh
"mvn clean package -Dmvn.test.skip=true"
}
else
if
(
env
.
BRANCH_NAME
==
'master'
)
{
echo
"3.1 Build Maven Package master Branch"
sh
"mvn clean package -Dmvn.test.skip=true"
}
}
stage
(
'Docker Build and Push'
)
{
echo
"4.Push Docker Image Stage"
withCredentials
([
usernamePassword
(
credentialsId:
'orhonDockerHub'
,
passwordVariable:
'dockerHubPassword'
,
usernameVariable:
'dockerHubUser'
)])
{
if
(
env
.
BRANCH_NAME
==
'develop'
)
{
echo
"develop branch Push Docker Image Build and Push Stage"
}
else
if
(
env
.
BRANCH_NAME
==
'master'
)
{
echo
"develop master Push Docker Image Build and Push Stage"
}
echo
"Build Docker Image Stage"
sh
"docker build -t hub.orhoncloud.com/smartcampus/${registryAppName}:${build_tag} ."
echo
"docker login and push"
sh
"docker login -u ${dockerHubUser} -p ${dockerHubPassword} hub.orhoncloud.com"
sh
"docker push hub.orhoncloud.com/smartcampus/${registryAppName}:${build_tag}"
sh
"docker rmi hub.orhoncloud.com/smartcampus/${registryAppName}:${build_tag}"
}
}
stage
(
'Deploy'
)
{
echo
"5. Deploy Stage"
if
(
env
.
BRANCH_NAME
==
'master'
)
{
input
"确认要部署线上环境吗?"
echo
"开始部署线上环境"
}
else
if
(
env
.
BRANCH_NAME
==
'develop'
)
{
echo
"开始部署开发环境"
}
sh
"sed -i 's/<BUILD_TAG>/${build_tag}/' k8s.yaml"
sh
"sed -i 's/<BRANCH_NAME>/${env.BRANCH_NAME}/' k8s.yaml"
sh
"sed -i 's/<K8S-APP-NAME>/${k8sAppName}/' k8s.yaml"
sh
"sed -i 's/<DATA-DIR>/${dataDir}/' k8s.yaml"
sh
"sed -i 's/<K8S-NAMESPACE>/${k8sNamespace}/' k8s.yaml"
sh
"sed -i 's/<INGRESS-HOST>/${ingressHost}/' k8s.yaml"
sh
"sed -i 's/<SERVICE-PORT>/${servicePort}/' k8s.yaml"
sh
"sed -i 's/<POD-PORT>/${podPort}/' k8s.yaml"
sh
"sed -i 's/<REGISTRY-APP-NAME>/${registryAppName}/' k8s.yaml"
sh
"cat k8s.yaml"
sh
"kubectl apply -f k8s.yaml --record"
sh
"kubectl -n ${k8sNamespace} get pods"
echo
"Deploed end "
}
}
k8s.yaml
0 → 100644
View file @
bcc419c7
#deploy
apiVersion
:
apps/v1
kind
:
Deployment
metadata
:
name
:
<K8S-APP-NAME>
namespace
:
<K8S-NAMESPACE>
labels
:
release
:
<K8S-APP-NAME>
spec
:
selector
:
matchLabels
:
app
:
<K8S-APP-NAME>
replicas
:
1
template
:
metadata
:
labels
:
app
:
<K8S-APP-NAME>
spec
:
containers
:
-
name
:
<K8S-APP-NAME>
image
:
hub.orhoncloud.com/smartcampus/<REGISTRY-APP-NAME>:<BUILD_TAG>
env
:
-
name
:
branch
value
:
<BRANCH_NAME>
ports
:
-
containerPort
:
<POD-PORT>
volumeMounts
:
-
name
:
smartcampus-data-backend-<DATA-DIR>
mountPath
:
/data/<DATA-DIR>
volumes
:
-
name
:
smartcampus-data-backend-<DATA-DIR>
persistentVolumeClaim
:
claimName
:
smartcampus-data-claim
---
#service
apiVersion
:
v1
kind
:
Service
metadata
:
name
:
<K8S-APP-NAME>
namespace
:
<K8S-NAMESPACE>
spec
:
ports
:
-
port
:
<SERVICE-PORT>
protocol
:
TCP
targetPort
:
<POD-PORT>
selector
:
app
:
<K8S-APP-NAME>
---
#ingress
apiVersion
:
extensions/v1beta1
kind
:
Ingress
metadata
:
name
:
<K8S-APP-NAME>
namespace
:
<K8S-NAMESPACE>
spec
:
rules
:
-
host
:
<INGRESS-HOST>
http
:
paths
:
-
path
:
/
backend
:
serviceName
:
<K8S-APP-NAME>
servicePort
:
<SERVICE-PORT>
src/main/resources/application-dev.yml
0 → 100644
View file @
bcc419c7
eureka
:
client
:
service-url
:
defaultZone
:
http://smartcampus-backend-eureka.smartcampus-dev.svc.cluster.local/eureka
instance
:
hostname
:
smartcampus-backend-material.smartcampus-dev.svc.cluster.local
prefer-ip-address
:
false
spring
:
datasource
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
url
:
jdbc:mysql://39.104.181.104:3308/smartcloud?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&useSSL=true
#url: jdbc:mysql://localhost:3306/material?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&useSSL=true
username
:
root
password
:
SmartCampusDB7893
type
:
com.alibaba.druid.pool.DruidDataSource
#最大活跃数
maxActive
:
20
#初始化数量
initialSize
:
1
#最大连接等待超时时间
maxWait
:
60000
#打开PSCache,并且指定每个连接PSCache的大小ull
poolPreparedStatements
:
true
maxPoolPreparedStatementPerConnectionSize
:
20
#通过connectionProperties属性来打开mergeSql功能;慢SQL记录
#connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
minIdle
:
1
timeBetweenEvictionRunsMillis
:
60000
minEvictableIdleTimeMillis
:
300000
validationQuery
:
select 1 from dual
testWhileIdle
:
true
testOnBorrow
:
false
testOnReturn
:
false
#配置监控统计拦截的filters,去掉后监控界面sql将无法统计,'wall'用于防火墙
filters
:
stat, wall, log4j
#日志
#logging:
# config: classpath:logback-boot.xml
# level:
# com.orhon.smartcampus.modules.*.mapper: DEBUG
src/main/resources/application-k8s.yml
View file @
bcc419c7
eureka
:
client
:
service-url
:
defaultZone
:
http://smartcampus-backend-eureka.smartcampus.svc.cluster.local/eureka
instance
:
hostname
:
smartcampus-backend-material.smartcampus.svc.cluster.local
prefer-ip-address
:
false
spring
:
datasource
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
...
...
src/main/resources/application-local.yml
View file @
bcc419c7
eureka
:
client
:
service-url
:
defaultZone
:
http://192.168.2.135:30016/eureka
spring
:
datasource
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
...
...
src/main/resources/application.yml
View file @
bcc419c7
...
...
@@ -12,7 +12,7 @@ spring:
application
:
name
:
smartcampus-material
profiles
:
active
:
testenv
active
:
<APP-ACTIVE-CONFIG>
jackson
:
time-zone
:
GMT+8
date-format
:
yyyy-MM-dd HH:mm:ss
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment