简体   繁体   English

具有模块依赖项的Spring Boot Docker Maven插件

[英]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.

相关问题 Maven Docker插件用于Spring Boot构建错误 - Maven docker plugin for spring boot build error Kafka Docker,docker-maven-plugin,Spring Boot - Kafka Docker, docker-maven-plugin, Spring Boot 使用自定义名称构建 docker 映像 Spring Boot Maven 插件 - Build docker image with a custom name using Spring Boot Maven plugin 在 Z9792E23419583666B178605ZDECAEC5 中构建和推送 Spring 启动 maven 插件 docker 映像 - Building and pushing Spring Boot maven plugin docker image in Gitlab CI 在 Spring Boot Maven 插件创建的 Docker 镜像中安装包 - Install package in Docker image created by Spring Boot Maven plugin 努力使用 spring boot maven 插件发布到 hub.docker.com - Struggling to publish to hub.docker.com with spring boot maven plugin 如何将 maven 多模块 Spring Boot 部署到 docker 容器 - How to deploy maven multi-module spring boot to docker container Spring 启动 2 应用程序在 docker-maven-plugin 触发的 docker 容器内运行时无法连接到 mysql - Spring Boot 2 app cannot connect to mysql while run inside docker container triggered by docker-maven-plugin Docker Containers for Maven Multi-module Spring Boot project with Angular Frontend module - Docker Containers for Maven Multi-module Spring Boot project with Angular Frontend module 如何在 Spring boot build-image maven 插件生成的 docker 镜像上设置编码 - How to set encoding on docker image generated by Spring boot build-image maven plugin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM