Skip to content

Commit

Permalink
Merge pull request #1 from visenze/dubbo-config
Browse files Browse the repository at this point in the history
config dubbo
  • Loading branch information
qpanvisz authored Aug 27, 2020
2 parents 2256293 + 91c4f31 commit 16f9901
Show file tree
Hide file tree
Showing 5 changed files with 278 additions and 3 deletions.
170 changes: 170 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
@Library('visenze-lib')_

pipeline {
// choose a suitable agent to build
agent {
label 'build'
}

options {
timestamps()
}

parameters {
string(name: 'DOCKER_REGISTRY', defaultValue: '', description: 'leave empty to use dockerhub as registry')
string(name: 'DOCKER_REGISTRY_CREDENTIAL', defaultValue: 'docker-hub-credential',
description: 'The credential ID stored in Jenkins to pull/push to docker registry')
string(name: 'AWS_MAVEN_CREDENTIALS_ID', defaultValue: 'visenze-test-maven-repo')
}

tools {
maven 'Default' // enable maven
}

stages {
stage('Checkout') {
steps {
// checkout the code from scm (github)
checkout scm
}
}

stage('Package') {
steps {
script {
sh "mvn clean compile package install"
}
}
}

stage('Docker Build') {
when {
expression {
return doBuildAndTest(env.BRANCH_NAME)
}
}
steps {
script {
// assume the Dockerfile is directly under WORKSPACE
def commitHash = getCommit()
// get jar build version for cas-server (version inherit from cas-parent)
def jarVersion = readMavenPom(file: 'pom.xml').version
echo "jarVersion ${jarVersion}"
// pull build image
docker.withRegistry(params.DOCKER_REGISTRY, params.DOCKER_REGISTRY_CREDENTIAL) {
// assume the docker registry is visenze/dubbo-admin
docker.build("visenze/dubbo-admin:${commitHash}", "-f docker/Dockerfile .")
}
}
}
}

stage('Docker Push') {
when {
expression {
return doBuildAndTest(env.BRANCH_NAME)
}
}
steps {
script {
def commitHash = getCommit()
def version = getVersion()
docker.withRegistry(params.DOCKER_REGISTRY, params.DOCKER_REGISTRY_CREDENTIAL) {
def image = docker.image("visenze/dubbo-admin:${commitHash}")
// push all the tags
def tags = genDockerTags(env.BRANCH_NAME, commitHash, version, env.BUILD_NUMBER)
// keep the last tag as a global variable used by later stages
TAG = tags[-1]
tags.add(commitHash)

tags.each {
retry(2) {
image.push(it)
}
}
}
}
}
}


stage('Archive') {
when {
expression {
return doBuildAndTest(env.BRANCH_NAME) || isProdRelease(env.BRANCH_NAME)
}
}
steps {
script {
def archive = [
docker_tag: TAG,
version: getVersion(),
docker_repos: ['visenze/dubbo-admin']
]
writeFile(file: "${WORKSPACE}/version.json", text: groovy.json.JsonOutput.toJson(archive))
archiveArtifacts(artifacts: "version.json", allowEmptyArchive: true)
}
}
}
}

}



// Get commit sha
def getCommit() {
return sh(
script: "(cd '${WORKSPACE}'; git rev-parse HEAD)", returnStdout: true
).trim()
}

def getVersion() {
// read version from pom
return readMavenPom(file: 'pom.xml').version
}

// Get snapshot version
def genSnapShotVersion(version) {
def suffix = "-SNAPSHOT"
if (!version.endsWith(suffix)) {
return version + suffix
}
return version
}

// Get Release version
def genReleaseVersion(version) {
def suffix = "-SNAPSHOT"
if (version.endsWith(suffix)) {
return version.substring(0, version.length() - suffix.length())
}
return version
}

def genDockerTags(branch, commit, version=null, buildNumber=null) {
def tags = []
def shortCommit = commit.substring(0, 9)
tags.add(branch.replaceAll("/", "_"))
tags.add("${branch.replaceAll("/", "_")}-${shortCommit}")
//if(branch == 'production') {
// assert version !=null
// tags.add("${version}")
//} else {
// assert version != null && buildNumber != null
// tags.add("${version}.${buildNumber}-${shortCommit}")
//}
return tags
}

def isPullRequest(branch) {
return branch.startsWith('PR')
}

def doBuildAndTest(branch) {
return branch.startsWith('PR') || branch == 'staging' || branch == 'production'
}

def isProdRelease(branch) {
return env.BRANCH_NAME == "production"
}
7 changes: 7 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM openjdk:8-jdk

COPY ./dubbo-admin-distribution/target/dubbo-admin-0.2.0-SNAPSHOT.jar /

EXPOSE 8080

CMD ["java", "-jar", "/dubbo-admin-0.2.0-SNAPSHOT.jar"]
47 changes: 47 additions & 0 deletions dubbo-admin-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,53 @@
<artifactId>dubbo-serialization-kryo</artifactId>
</dependency>

<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-rpc-rest</artifactId>
<version>2.7.7</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-rpc-http</artifactId>
<version>2.7.7</version>
</dependency>

<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
<version>4.0.2</version>
</dependency>
<dependency>
<groupId>de.javakaffee</groupId>
<artifactId>kryo-serializers</artifactId>
<version>0.45</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-serialization-fst</artifactId>
<version>2.7.8</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-serialization-avro</artifactId>
<version>2.7.8</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-serialization-gson</artifactId>
<version>2.7.8</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-serialization-fastjson</artifactId>
<version>2.7.8</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-rpc-rmi</artifactId>
<version>2.7.8</version>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# centers in dubbo2.7
admin.registry.address=zookeeper://zk-prod-cs:2181
admin.config-center=zookeeper://zk-prod-cs:2181
admin.metadata-report.address=zookeeper://zk-prod-cs:2181

admin.root.user.name=root
admin.root.user.password=root
#group
admin.registry.group=dubbo
admin.config-center.group=dubbo
admin.metadata-report.group=dubbo

admin.apollo.token=e16e5cd903fd0c97a116c873b448544b9d086de9
admin.apollo.appId=test
admin.apollo.env=dev
admin.apollo.cluster=default
admin.apollo.namespace=dubbo

#compress
server.compression.enabled=true
server.compression.mime-types=text/css,text/javascript,application/javascript
server.compression.min-response-size=10240
server.port=8080

dubbo.protocol.id=dubbo
dubbo.protocol.name=dubbo
dubbo.protocol.port=-1
dubbo.protocol.serialization=fst
12 changes: 9 additions & 3 deletions dubbo-admin-server/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#

# centers in dubbo2.7
admin.registry.address=zookeeper://127.0.0.1:2181
admin.config-center=zookeeper://127.0.0.1:2181
admin.metadata-report.address=zookeeper://127.0.0.1:2181
admin.registry.address=zookeeper://zookeeper:2181
admin.config-center=zookeeper://zookeeper:2181
admin.metadata-report.address=zookeeper://zookeeper:2181

admin.root.user.name=root
admin.root.user.password=root
Expand All @@ -37,3 +37,9 @@ admin.apollo.namespace=dubbo
server.compression.enabled=true
server.compression.mime-types=text/css,text/javascript,application/javascript
server.compression.min-response-size=10240
server.port=8080

dubbo.protocol.id=dubbo
dubbo.protocol.name=dubbo
dubbo.protocol.port=-1
dubbo.protocol.serialization=fst

0 comments on commit 16f9901

Please sign in to comment.