gpt4 book ai didi

spring-boot - Spring Boot应用程序的Docker镜像

转载 作者:行者123 更新时间:2023-12-02 21:04:39 25 4
gpt4 key购买 nike

我想学习如何使用Gradle创建spring boot应用程序的docker镜像,因为它们在我的商店中是相同的要求。

首先,我已推荐https://spring.io/guides/gs/spring-boot-docker/

我遵循了此处提到的所有步骤。

我的Dockerfile如下所示

FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG DEPENDENCY=target/dependency
COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY ${DEPENDENCY}/META-INF /app/META-INF
COPY ${DEPENDENCY}/BOOT-INF/classes /app
EXPOSE 8080
ENTRYPOINT ["java","-cp","app:app/lib/*","hello.Application"]

而我的build.gradle是
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.6.RELEASE")
}
}

group = 'springio'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.palantir.docker'

bootJar {
baseName = 'gs-spring-boot-docker'
version = '0.1.0'
}

repositories {
mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
testCompile("org.springframework.boot:spring-boot-starter-test")
}

task unpack(type: Copy) {
dependsOn bootJar
from(zipTree(tasks.bootJar.outputs.files.singleFile))
into("build/dependency")
}
docker {
name "${project.group}/${bootJar.baseName}"
copySpec.from(tasks.unpack.outputs).into("dependency")
buildArgs(['DEPENDENCY': "dependency"])
}

但是当我毁了
    $./gradlew build docker

低于错误
    FAILURE: Build failed with an exception.

* Where:
Build file '/root/springboot-Dockerf/gs-spring-boot-docker/initial/build.gradle' line: 16

* What went wrong:
A problem occurred evaluating root project 'initial'.
> Plugin with id 'com.palantir.docker' not found.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get
more log output. Run with --scan to get full insights.

最佳答案

尝试使用以下方式

    plugins {
id "com.palantir.docker" version "0.22.1"
}

apply plugin: "com.palantir.git-version"

https://plugins.gradle.org/plugin/com.palantir.docker

尝试点击此链接
.jar file not found when building a Docker container with Palantir Gradle plug-in

关于spring-boot - Spring Boot应用程序的Docker镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58889429/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com