[英]Spring Boot Docker Maven Plugin with module dependencies
I am using docker-maven-plugin(Spotify) to build my docker images generated by Dockerfile in my Spring Boot project. 我正在使用docker-maven-plugin(Spotify)在Spring Boot项目中构建由Dockerfile生成的docker映像。 If the project has no any module dependency it works well.
如果项目没有任何模块依赖性,那么它将运行良好。 But if a module is dependent to another like:
但是,如果一个模块依赖于另一个模块,例如:
<dependency>
<groupId>com.mysite</groupId>
<artifactId>helper</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
When I run 当我跑步
./mvnw install dockerfile:build ./mvnw安装dockerfile:build
I got 我有
Could not resolve dependencies for project com.mysite:web:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: com.mysite:helper:jar:0.0.1-SNAPSHOT
无法解析项目com.mysite:web:jar:0.0.1-SNAPSHOT的依赖项:无法解析以下工件:com.mysite:helper:jar:0.0.1-SNAPSHOT
How can I solve this? 我该如何解决?
You don't need a plugin to accomplish this. 您不需要插件即可完成此操作。
1) Create a Dockerfile
: 1)创建一个
Dockerfile
:
FROM openjdk:8-jre-alpine
COPY build/libs/yourapp-0.0.1-SNAPSHOT.jar /application.jar
CMD ["java", "-jar", "/application.jar"]
2) Create a shell script, or use a simple Makefile
to do the building: 2)创建一个shell脚本,或使用一个简单的
Makefile
进行构建:
VERSION ?= $(shell git rev-parse HEAD)
APP ?= k8specs-platform-api
IMAGE ?= gcr.io/matthewdavis-devops/$(APP):$(VERSION)
.PHONY: build
all: build push
build:
./gradlew bootJar
docker build -t $(IMAGE) .
run:
docker run -p 8080:8080 $(IMAGE)
push:
docker push $(IMAGE)
3) Just run make all
and profit! 3)只要运行
make all
和利润!
No need for a silly plugin ;) 不需要愚蠢的插件;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.