首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Docker私有仓库实例

Docker私有仓库实例

作者头像
用户1112962
发布2018-07-03 16:39:33
5280
发布2018-07-03 16:39:33
举报
C:\Users\think\.m2\settings.xml文件配置:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
	<mirrors>
		<mirror>
			<id>nexus</id>
			<mirrorOf>*</mirrorOf>
			<url>http://maven.kjt.com/nexus/content/groups/public</url>
		</mirror>
	</mirrors>
	<servers>
	    <server>
	        <id>releases</id>
	        <username>p_user</username>
	        <password>p_password</password>
	    </server>
	    <server>
	        <id>snapshots</id>
	        <username>p_user</username>
	        <password>p_password</password>
	    </server>
	    <server>
	    	<id>docker-hub</id>
	    	<username>p_password</username>
    		<password>p_password</password>
    		<configuration>
		    	<email>docker@xxx.com</email>
		    </configuration>
	    </server>
	</servers>
	<profiles>
		<profile>
			<id>nexus</id>
			<repositories>
				<repository>
				    <id>central</id>
				    <url>http://repo1.maven.org/maven2/</url>
					<releases>
						<enabled>true</enabled>
					</releases>
					<snapshots>
						<enabled>true</enabled>
					</snapshots>
				</repository>
			</repositories>
			<pluginRepositories>
				<pluginRepository>
					<id>central</id>
					<url>http://central</url>
					<releases>
						<enabled>true</enabled>
					</releases>
					<snapshots>
						<enabled>true</enabled>
					</snapshots>
				</pluginRepository>
			</pluginRepositories>
		</profile>
		<profile>
	        <id>dev</id>
	        <activation>
	            <activeByDefault>true</activeByDefault>
	        </activation>
	        <properties>
	             <releases.repo>http://maven.kjt.com/nexus/content/repositories/releases</releases.repo>
	             <snapshots.repo>http://maven.kjt.com/nexus/content/repositories/snapshots</snapshots.repo>
	        </properties>
	     </profile>
	</profiles>
	<activeProfiles>
		<activeProfile>nexus</activeProfile>
	</activeProfiles>
</settings>
pom.xml
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>com.backportal</groupId>
	<artifactId>backportal</artifactId>
	<version>0.0.1</version>
	<packaging>jar</packaging>

	<name>com.backportal</name>
	<description>Demo project for Spring Boot</description>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.5.10.RELEASE</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<java.version>1.8</java.version>
		<thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>
		<!-- 布局功能的支持程序  thymeleaf3主程序  layout2以上版本 -->
		<!-- thymeleaf2   layout1-->
		<thymeleaf-layout-dialect.version>2.2.2</thymeleaf-layout-dialect.version>
		<docker.repostory>docker.xxx.com</docker.repostory>
		<docker.dockerhost>http://192.168.xx.xx:xxxx</docker.dockerhost>
		<docker.registry.name>x_project/xxx</docker.registry.name>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-jdbc</artifactId>
		</dependency>
		<!-- 引入web模块 -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
			<exclusions>
				<exclusion>
					<artifactId>spring-boot-starter-logging</artifactId>
					<groupId>org.springframework.boot</groupId>
				</exclusion>
			</exclusions>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-thymeleaf</artifactId>
		</dependency>
		<dependency>
			<groupId>org.mybatis.spring.boot</groupId>
			<artifactId>mybatis-spring-boot-starter</artifactId>
			<version>1.3.1</version>
		</dependency>

		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<scope>runtime</scope>
		</dependency>
		<!--引入jquery-webjar-->
		<dependency>
			<groupId>org.webjars</groupId>
			<artifactId>jquery</artifactId>
			<version>3.3.1</version>
		</dependency>

		<!--引入bootstrap-->
		<dependency>
			<groupId>org.webjars</groupId>
			<artifactId>bootstrap</artifactId>
			<version>4.0.0</version>
		</dependency>
		<!--引入阿里druid连接池监控-->
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>druid</artifactId>
			<version>1.1.8</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>com.github.pagehelper</groupId>
			<artifactId>pagehelper-spring-boot-starter</artifactId>
			<version>1.2.1</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
			<version>1.8.0-beta2</version>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<finalName>${project.artifactId}</finalName>
				</configuration>
			</plugin>
			<plugin>
				<groupId>com.spotify</groupId>
				<artifactId>docker-maven-plugin</artifactId>
				<version>0.4.13</version>
				<executions>
					<execution>
						<id>build-image</id>
						<phase>package</phase>
						<goals>
							<goal>build</goal>
						</goals>
					</execution>
					<execution>
						<id>push-image</id>
						<phase>deploy</phase>
						<goals>
							<goal>push</goal>
						</goals>
						<configuration>
							<imageName>${docker.repostory}/${docker.registry.name}:${project.version}</imageName>
						</configuration>
					</execution>
				</executions>
				<configuration>
					<serverId>docker-hub</serverId>
					<registryUrl>https://${docker.repostory}</registryUrl>
					<dockerHost>${docker.dockerhost}</dockerHost>
					<dockerDirectory>${project.basedir}</dockerDirectory>
					<pushImage>true</pushImage>
					<imageName>
						${docker.repostory}/${docker.registry.name}:${project.version}
					</imageName>
					<imageTags>
						<imageTag>latest</imageTag>
					</imageTags>
					<resources>
						<resource>
							<directory>${project.build.directory}</directory>
							<include>${project.build.finalName}.jar</include>
						</resource>
					</resources>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>
Dockerfile文件设置

FROM java:8-jre
MAINTAINER windMan <wen.chao@kjt.com>
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

ADD ./target/backportal.jar /app/
CMD ["java", "-Duser.timezone=GMT+8", "-jar", "/app/backportal.jar"]

EXPOSE 外部暴露端口(注意:外部端口不可以重复,内部端口和外部端口可以重复)
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-06-02 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
容器镜像服务
容器镜像服务(Tencent Container Registry,TCR)为您提供安全独享、高性能的容器镜像托管分发服务。您可同时在全球多个地域创建独享实例,以实现容器镜像的就近拉取,降低拉取时间,节约带宽成本。TCR 提供细颗粒度的权限管理及访问控制,保障您的数据安全。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档