Giriş
Açıklaması şöyle
Spotify Dev team open-sourced many tools they are using among others dockerfile-maven-plugin as well.The dockerfile-maven-plugin can create and publish a docker image based on your Dockerfile meanwhile running maven commands.
Örnek
Şöyle yaparız
<plugin><groupId>com.spotify</groupId><artifactId>dockerfile-maven-plugin</artifactId><version>${dockerfile-maven-plugin.version}</version><configuration><repository>${docker.image.prefix}/${project.artifactId}</repository></configuration><executions><execution><id>default</id><phase>install</phase><goals><goal>build</goal></goals></execution></executions></plugin>
Docker dosyası için şöyle yaparız. maven install komutu ile önce jar yapılandırılıyor. En son olarak ta Docker dosyası çalıştırılıyor
FROM openjdk:17-alpine as builder WORKDIR application ARG JAR_FILE=target/*.jar COPY ${JAR_FILE} application.jar RUN java -Djarmode=layertools -jar application.jar extract FROM openjdk:17-alpine WORKDIR application COPY --from=builder application/dependencies/ ./ COPY --from=builder application/spring-boot-loader/ ./ COPY --from=builder application/snapshot-dependencies/ ./ COPY --from=builder application/application/ ./ ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
mvn deploy ile de Docker image Docker deposuna gönderilir
Hiç yorum yok:
Yorum Gönder