`
knight_black_bob
  • 浏览: 853063 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

springboot docker jenkins 部署 对比 tomcat

阅读更多

 

 

----------------------------------------------------------------------------------------------------------------

springboot 详解 (一) helloworld                                    下载demo          

springboot 详解 (二) crud                                             下载demo     

springboot 详解 (三) 多数据源                                        下载demo      

springboot 详解 (四)redis & filter                                    下载demo    

springboot 详解 (五)interceptor                                       下载demo     

springboot 详解 (六)servlet & scheduled & listener         下载demo     

springboot 详解(七) dubbox & zookeeper   下载(productor) 下载(constumser)

springboot 同步解耦 异步化 下载demo

springboot jenkins docker 部署 

springboot 详解(八) springboot & springcloud 

----------------------------------------------------------------------------------------------------------------

 

 

 

 

 

 

 

springboot docker jenkins 部署

1.pom 文件

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion> 
  <groupId>com.curiousby.baoyou.cn</groupId>
  <artifactId>showandshare.docker.jenkinsdockerdemo</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>showandshare.docker.jenkinsdockerdemo</name>
  <url>http://maven.apache.org</url>
  <packaging>jar</packaging>
  
  <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.5.RELEASE</version>
        <relativePath>../pom.xml</relativePath>  <!-- lookup parent from repository -->
    </parent>
    
   <repositories>
        <repository>
            <id>spring-snapshots</id>
            <url>http://repo.spring.io/libs-snapshot</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>spring-snapshots</id>
            <url>http://repo.spring.io/libs-snapshot</url>
        </pluginRepository>
    </pluginRepositories>
    

	

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
     
     
        <dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.tomcat.embed</groupId>
			<artifactId>tomcat-embed-jasper</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>jstl</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>  
		    <groupId>org.springframework.boot</groupId>  
		    <artifactId>spring-boot-starter-aop</artifactId>  
		</dependency>  
          <dependency>  
            <groupId>com.google.code.gson</groupId>  
            <artifactId>gson</artifactId>  
        </dependency>
        <dependency>
				<groupId>com.alibaba</groupId>
				<artifactId>fastjson</artifactId>
				<version>1.2.8</version>
			</dependency>
        
    </dependencies>

	<build>
		<finalName>showandshare.docker.jenkinsdockerdemo</finalName>
		<resources>
			<resource>
				<directory>src/main/java</directory>
				<includes>
					<include>**/*.properties</include>
					<include>**/*.xml</include>
				</includes>
				<filtering>false</filtering>
			</resource>
			<resource>
				<directory>src/main/resources</directory>
				<includes>
					<include>**/*</include>
				</includes>
				<filtering>false</filtering>
			</resource>
		</resources>
		<plugins>
			<plugin>
				<!-- 忽略测试失败或者跳过测试继续打包或安装 -->
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>2.10</version>
				<configuration>
					<skip>true</skip>
					<!-- <testFailureIgnore>true</testFailureIgnore> -->
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3.2</version>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
					<encoding>UTF-8</encoding>
					<compilerArguments>
						<verbose />
						<bootclasspath>${java.home}/lib/rt.jar</bootclasspath>
					</compilerArguments>
				</configuration>
			</plugin>
			
			
			<plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <!-- Docker maven plugin -->
        <plugin>
            <groupId>com.spotify</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>1.0.0</version>
            <configuration>
                <!-- <imageName>${docker.image.prefix}/${project.artifactId}</imageName> -->
                <imageName>curiousby/showandshare.docker.jenkinsdockerdemo</imageName>  
                <dockerDirectory>src/main/docker</dockerDirectory>
                <resources>
                    <resource>
                        <targetPath>/</targetPath>
                        <directory>${project.build.directory}</directory>
                        <include>${project.build.finalName}.jar</include>
                    </resource>
                </resources>
            </configuration>
        </plugin>
        <!-- Docker maven plugin -->
        
		</plugins>

	</build>
</project>

 

2.dockerfile

############################################  
# version:   
# desc : 当前版本安装的 
############################################  
  
  
# 设置继承自我们创建的 tools 镜像   
FROM dquintela/openjdk-8-jdk-alpine 

VOLUME /tmp 

ADD  showandshare.docker.jenkinsdockerdemo.jar app.jar

ENTRYPOINT java -Djava.security.egd=file:/dev/./urandom -jar /app.jar




 

 

 

3.svn 配置 



 

 

4.bulid



 MAVEN_OPTS 设置 -Xms128m -Xmx512m

执行mvn 命令 clean package docker:build

 

 

5.发布脚本



 

echo "======================================"
echo `date ` -- start start docker 


docker_container_name="curiousby/showandshare.docker.jenkinsdockerdemo"
docker_container_pid=`docker ps  | grep $docker_container_name | awk '{print $1}'`

if [ "" = "$docker_container_pid" ] ; then
        echo " docker_container isn't running."
else
        docker stop $docker_container_pid 
        echo " docker_container(pid:$docker_container_pid) be killed. sleep 5s"
        sleep 5
fi
 
docker run -p 7071:7071 -d $docker_container_name

echo `date ` -- end start docker 
echo "======================================"

 

 

6.构建输出日志

Started by user baoyou
Building in workspace /root/.jenkins/workspace/showandshare.docker.jenkinsdockerdemo
Updating svn://192.168.206.235/showandshare.docker.jenkinsdockerdemo at revision '2018-06-26T03:44:07.235 -0700' --quiet
Using sole credentials baoyou/****** in realm ‘<svn://192.168.206.235:3690> /data/svn/repo’
At revision 17

No changes for svn://192.168.206.235/showandshare.docker.jenkinsdockerdemo since the previous build
Parsing POMs
Established TCP socket on 44875
[showandshare.docker.jenkinsdockerdemo] $ /home/baoyou/soft/jdk1.8.0_151/bin/java -Xms128m -Xmx512m -cp /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-agent-1.12-alpha-1.jar:/home/baoyou/soft/apache-maven-3.5.4/boot/plexus-classworlds-2.5.2.jar:/home/baoyou/soft/apache-maven-3.5.4/conf/logging jenkins.maven3.agent.Maven35Main /home/baoyou/soft/apache-maven-3.5.4 /home/baoyou/soft/apache-tomcat-8.0.47/webapps/jenkins/WEB-INF/lib/remoting-3.20.jar /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-interceptor-1.12-alpha-1.jar /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.12-alpha-1.jar 44875
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven:  -B -f /root/.jenkins/workspace/showandshare.docker.jenkinsdockerdemo/pom.xml clean package docker:build
[INFO] Scanning for projects...
[INFO] 
[INFO] ---< com.curiousby.baoyou.cn:showandshare.docker.jenkinsdockerdemo >----
[INFO] Building showandshare.docker.jenkinsdockerdemo 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ showandshare.docker.jenkinsdockerdemo ---
[INFO] Deleting /root/.jenkins/workspace/showandshare.docker.jenkinsdockerdemo/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ showandshare.docker.jenkinsdockerdemo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] Copying 6 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ showandshare.docker.jenkinsdockerdemo ---
[INFO] Compiling 2 source files to /root/.jenkins/workspace/showandshare.docker.jenkinsdockerdemo/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ showandshare.docker.jenkinsdockerdemo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /root/.jenkins/workspace/showandshare.docker.jenkinsdockerdemo/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ showandshare.docker.jenkinsdockerdemo ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ showandshare.docker.jenkinsdockerdemo ---
[INFO] Tests are skipped.
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.BuildInfoRecorder$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[INFO] 
[INFO] --- maven-jar-plugin:2.5:jar (default-jar) @ showandshare.docker.jenkinsdockerdemo ---
[INFO] Building jar: /root/.jenkins/workspace/showandshare.docker.jenkinsdockerdemo/target/showandshare.docker.jenkinsdockerdemo.jar
[INFO] 
[INFO] --- spring-boot-maven-plugin:1.3.5.RELEASE:repackage (default) @ showandshare.docker.jenkinsdockerdemo ---
[INFO] 
[INFO] --- docker-maven-plugin:1.0.0:build (default-cli) @ showandshare.docker.jenkinsdockerdemo ---
[INFO] Using authentication suppliers: [ConfigFileRegistryAuthSupplier]
[INFO] Copying /root/.jenkins/workspace/showandshare.docker.jenkinsdockerdemo/target/showandshare.docker.jenkinsdockerdemo.jar -> /root/.jenkins/workspace/showandshare.docker.jenkinsdockerdemo/target/docker/showandshare.docker.jenkinsdockerdemo.jar
[INFO] Copying src/main/docker/.svn/text-base/Dockerfile.svn-base -> /root/.jenkins/workspace/showandshare.docker.jenkinsdockerdemo/target/docker/.svn/text-base/Dockerfile.svn-base
[INFO] Copying src/main/docker/.svn/format -> /root/.jenkins/workspace/showandshare.docker.jenkinsdockerdemo/target/docker/.svn/format
[INFO] Copying src/main/docker/.svn/entries -> /root/.jenkins/workspace/showandshare.docker.jenkinsdockerdemo/target/docker/.svn/entries
[INFO] Copying src/main/docker/Dockerfile -> /root/.jenkins/workspace/showandshare.docker.jenkinsdockerdemo/target/docker/Dockerfile
[INFO] Building image curiousby/showandshare.docker.jenkinsdockerdemo
Step 1/4 : FROM dquintela/openjdk-8-jdk-alpine
 ---> 419025210ef0
Step 2/4 : VOLUME /tmp
 ---> Using cache
 ---> 14f67319ff67
Step 3/4 : ADD showandshare.docker.jenkinsdockerdemo.jar app.jar
 ---> cc9ce84e0337
Step 4/4 : ENTRYPOINT java -Djava.security.egd=file:/dev/./urandom -jar /app.jar
 ---> Running in dfc3cb3f8494
 ---> a0b7f7d8132e
Removing intermediate container dfc3cb3f8494
ProgressMessage{id=null, status=null, stream=null, error=null, progress=null, progressDetail=null}
Successfully built a0b7f7d8132e
Successfully tagged curiousby/showandshare.docker.jenkinsdockerdemo:latest
[INFO] Built curiousby/showandshare.docker.jenkinsdockerdemo
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.MavenArtifactArchiver$2; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.MavenFingerprinter$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:06 min
[INFO] Finished at: 2018-06-26T03:45:23-07:00
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving /root/.jenkins/workspace/showandshare.docker.jenkinsdockerdemo/pom.xml to com.curiousby.baoyou.cn/showandshare.docker.jenkinsdockerdemo/0.0.1-SNAPSHOT/showandshare.docker.jenkinsdockerdemo-0.0.1-SNAPSHOT.pom
[JENKINS] Archiving /root/.jenkins/workspace/showandshare.docker.jenkinsdockerdemo/target/showandshare.docker.jenkinsdockerdemo.jar to com.curiousby.baoyou.cn/showandshare.docker.jenkinsdockerdemo/0.0.1-SNAPSHOT/showandshare.docker.jenkinsdockerdemo-0.0.1-SNAPSHOT.jar
channel stopped
[showandshare.docker.jenkinsdockerdemo] $ /bin/sh -xe /home/baoyou/soft/apache-tomcat-8.0.47/temp/jenkins5841437373663528941.sh
+ echo ======================================
======================================
++ date
+ echo Tue Jun 26 03:45:25 PDT 2018 -- start start docker
Tue Jun 26 03:45:25 PDT 2018 -- start start docker
+ docker_container_name=curiousby/showandshare.docker.jenkinsdockerdemo
++ docker ps
++ grep curiousby/showandshare.docker.jenkinsdockerdemo
++ awk '{print $1}'
+ docker_container_pid=
+ '[' '' = '' ']'
+ echo ' docker_container isn'\''t running.'
 docker_container isn't running.
+ docker run -p 7071:7071 -d curiousby/showandshare.docker.jenkinsdockerdemo
8690971a19f90dbdd49df757483c76462e3d360e2d2736eac87ce199fadb5d40
++ date
+ echo Tue Jun 26 03:45:29 PDT 2018 -- end start docker
Tue Jun 26 03:45:29 PDT 2018 -- end start docker
+ echo ======================================
======================================
Finished: SUCCESS

 

7.访问



 

 

 

 

 

对比 tomcat 部署方式,添加 

 



 

修改pom 中<packaging>

 jar 为 war 

生成war 包

重新访问 



 

 

 

捐助开发者 

在兴趣的驱动下,写一个免费的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(支持支付宝和微信 以及扣扣群),没钱捧个人场,谢谢各位。

 

个人主页http://knight-black-bob.iteye.com/



 
 
 谢谢您的赞助,我会做的更好!

  • 大小: 31.2 KB
  • 大小: 40 KB
  • 大小: 47.7 KB
  • 大小: 39.9 KB
  • 大小: 33.1 KB
  • 大小: 38.5 KB
2
0
分享到:
评论

相关推荐

    基于SpringBoot+Dubbo的微服务框架-SpringBoot-Dubbo-Docker-Jenkins.zip

    SpringBoot简化了应用开发,Dubbo实现了服务间的通信和治理,Docker保证了服务的隔离和部署的便捷性,而Jenkins则确保了整个流程的自动化。这种组合可以促进敏捷开发,提高开发效率,同时降低运维复杂度,是现代云...

    运维-jenkins-springboot-rancher自动化部署文件.zip

    直接根据PDF文档复制粘贴命令即可,遇到问题文档里面有具体的解决方案,收录了大多数的问题,新手大约30分钟即可完成springboot项目自动化的部署流程!!! 压缩包结构说明: 1. docker-compose.yml这个文件是安装...

    Jenkins自动化部署.docx

    Jenkins是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放...本文主要将一个Springboot项目通过Gitlab、Maven、Jenkins、Docker等技术,实现项目的自动化提交部署功能

    jenkins.war-2.356,适合JDK8的最后jenkins版本

    Jenkins作为一个基于Web的的平台,其核心是一个名为`jenkins.war`的Web应用程序档案(WAR),这个档案可以直接部署在支持Java的Web服务器上,如Tomcat。版本号2.356代表了该发布包含了一系列修复、增强和优化,以...

    SpringBoot微服务架构应用.zip

    12. **持续集成/持续部署(CI/CD)**:Jenkins、GitLab CI/CD或Travis CI等工具可以与SpringBoot微服务结合,实现自动化构建和部署。 通过以上知识点的介绍,我们可以看到SpringBoot在构建微服务架构时的全面性和...

    springboot源码分析教程.zip

    12. **SpringBoot与云服务的集成**:如Docker容器化、Cloud Foundry、Kubernetes等云平台的部署策略。 13. **微服务架构**:讨论SpringBoot在微服务场景中的应用,如Spring Cloud的相关组件如Eureka、Zuul、Ribbon...

    基于SpringBoot洗衣店管理系统.zip

    项目可能采用Git进行版本控制,Jenkins或GitHub Actions进行持续集成,Docker化部署,实现快速、可靠的软件发布流程。 通过以上技术栈,基于SpringBoot的洗衣店管理系统能有效提升洗衣店的业务处理能力和用户体验...

    springboot2.X.zip

    SpringBoot可以内嵌Tomcat、Jetty等Servlet容器,无需额外安装和配置,大大简化了部署流程。只需运行一个Java应用,服务器就随之启动。 **四、命令行接口** SpringBoot提供了一个命令行接口(CLI),使得开发者可以...

    SpringBoot快速入门单纯的SPringBoot项目

    - **嵌入式Servlet容器**: 可以直接使用内嵌的Tomcat或Jetty服务器,无需额外配置和部署。 - **自动配置(Auto Configuration)**: 根据类路径中的jar包和配置文件,自动配置Spring上下文。 - **命令行接口(CLI...

    04-springboot.zip

    - **嵌入式Web服务器**:SpringBoot可以内嵌Tomcat、Jetty等Web服务器,无需额外部署,方便快速开发和测试。 - **命令行界面(CLI)**:提供了命令行工具,用于快速运行Spring Boot应用,支持Groovy脚本。 2. **...

    SpringBoot实战(第四版)带目录可以复制粘贴

    12. **持续集成/持续部署(CI/CD)**:介绍Jenkins、GitLab CI/CD等工具,以及SpringBoot在自动化部署中的应用。 13. **最佳实践**:分享项目构建、代码管理、日志记录、错误处理等方面的最佳实践,提升开发效率和...

    springboot讲义

    SpringBoot与Jenkins、GitLab CI/CD等工具结合,可以实现自动化构建、测试和部署。 综上所述,SpringBoot以其强大的自动配置和预集成特性,极大地提高了开发效率,降低了项目复杂性,是现代Java应用开发的首选框架...

    SpringBoot+Vue 驾校理论课模拟考试系统(自动化部署).zip

    在"驾校理论课模拟考试系统"中,可能采用了诸如Docker、Jenkins或GitLab CI/CD等工具来实现代码的自动化构建、测试和部署。这使得开发者只需提交代码,系统就能自动完成编译、打包、部署等一系列流程,降低了运维...

    springboot实战

    最后,书籍还会讨论SpringBoot在云环境中的应用,如Docker容器化、Kubernetes编排等,以及SpringCloud系列组件,如Config Server、Bus、Service Registry等,帮助开发者构建可扩展的云原生应用。 总的来说,...

    SpringBoot博客后台管理系统

    Jenkins作为持续集成工具,可以帮助我们自动化构建、测试和部署SpringBoot应用。通过配置Jenkins,可以实现代码提交后自动触发构建和部署,确保开发流程的高效稳定。 总结,SpringBoot博客后台管理系统集成了众多...

    基于springboot的线上教学系统源码.zip

    使用Jenkins、GitLab CI/CD等工具,配合Docker容器化技术,可以实现代码自动构建、测试和部署,提高开发效率。 总的来说,基于SpringBoot的线上教学系统源码是一份综合运用Java编程语言、Spring生态组件和现代Web...

    基于springboot的个人博客系统

    完成开发后,博客系统可以通过SpringBoot内置的Tomcat服务器进行本地运行,也可以打包成jar文件,使用Docker容器化部署到云服务器上。对于生产环境,可以使用Jenkins等持续集成工具自动化构建和部署。 总结,基于...

    springboot搭建博客系统.zip

    10. **持续集成与部署**:项目可能包含Dockerfile,用于Docker化部署。同时,可以结合Jenkins或GitLab CI/CD实现自动化构建与部署。 【学习资源】 1. **官方文档**:SpringBoot的官方文档是学习的起点,详细介绍了...

    SpringBoot510人职匹配推荐系统.zip

    SpringBoot与Jenkins、Docker等工具配合,可以实现持续集成和持续部署(CI/CD),提高软件交付的效率和质量。 综上所述,SpringBoot510人职匹配推荐系统利用SpringBoot的强大功能,构建了一个高效、可扩展的推荐...

    SpringBoot框架

    - 与Docker、Jenkins、Git等工具结合,实现持续集成和持续部署。 总的来说,SpringBoot以其简洁的配置、强大的功能和广泛的社区支持,成为现代Java开发的首选框架。对于初学者来说,了解并掌握SpringBoot能够迅速...

Global site tag (gtag.js) - Google Analytics