【发布时间】:2020-03-12 08:08:16
【问题描述】:
我想学习如何使用 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.
【问题讨论】:
标签: spring-boot docker gradle amazon-ec2 microservices