壹
創(chuàng)建一個(gè)Spring Boot
應(yīng)用
package com.keeep.bamboo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* update on 2019年08月23日10:06:35
*
* @author congco
*/
@SpringBootApplication
public class BambooApplication {
public static void main(String[] args) {
SpringApplication.run(BambooApplication.class, args);
}
}
項(xiàng)目結(jié)構(gòu)
├── bamboo.iml
├── Dockerfile #Dockerfile文件位于項(xiàng)目根目錄下
├── HELP.md
├── mvnw
├── mvnw.cmd
├── pom.xml
├── README.md
└── src
├── main
│ ├── java
│ └── resources
└── test
└── java
貳
Dockerfile
FROM openjdk:8-jdk-alpine
VOLUME /tmp
COPY target/*.jar app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
叁
pom.xml
使用dockerfile-maven-plugin
構(gòu)建鏡像
<docker.image.prefix>congco</docker.image.prefix>
<!-- dockerfile-maven-plugin -->
<build>
<plugins>
<!-- dockerfile-maven 插件 -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.9</version>
<configuration>
<repository>${docker.image.prefix}/${project.artifactId}</repository>
</configuration>
</plugin>
</plugins>
</build>
肆
build&push
$ mvn package docker:build
$ docker push <image:tags>
伍
附錄:
- 阿里云鏡像加速器
-
idea
中的配置使用