docker - gradle docker 文件来构建 jars
问题描述
在构建 docker 映像之前,我需要建议在 docker 文件中包含什么来构建 jar。
最初,我使用这个 test.bat 文件来构建 jar
现在我需要改变这种方式,改为使用 docker compose。
CALL gradlew build
rem docker build test-query/. -t testquery
rem docker run --name testquery -dit -p 8002:8002 --network lsvc --restart=unless-stopped testquery
rem docker build test-command/. -t testcommand
rem docker run --name testcommand -dit -p 8008:8008 --network lsvc --restart=unless-stopped testcommand
Docker 文件,我修改为下载 gradle docker 然后构建文件
FROM gradle:4.7.0-jdk8-alpine AS build
COPY --chown=gradle:gradle . /test-command/src
ADD --chown=gradle . /app
WORKDIR /app
RUN gradle build test-query/. -t testquery
RUN gradle build test-command/. -t testcommand
FROM ubuntu
FROM openjdk:8-alpine
WORKDIR /app
VOLUME ["/app"]
COPY test-command/build/libs/*.jar /app/test-command.jar
COPY test-command/docker/startup.sh /app/startup.sh
#RUN sh -c 'touch /app/test-command.jar'
RUN chmod +x /app/startup.sh
RUN chmod +x /app/test-command.jar
ENTRYPOINT ["/bin/sh", "/app/startup.sh"]
启动.sh
#!/bin/sh
sleep 150; java -jar /app/test-command.jar
docker-compose up 时出错
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'test'.
> Failed to apply plugin [id 'io.gitlab.arturbosch.detekt']
> Could not create an instance of type io.gitlab.arturbosch.detekt.extensions.DetektExtension_Decorated.
> org.gradle.api.file.ProjectLayout.configurableFiles([Ljava/lang/Object;)Lorg/gradle/api/file/ConfigurableFileCollection;
* 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.
* Get more help at https://help.gradle.org
解决方案
您使用的插件版本与io.gitlab.arturbosch.detekt
您使用的旧 Gradle 版本 4.7 不兼容。我假设您已经在 docker 之外测试了 Gradle 构建,因此您可能只是使用了错误版本的 Gradle for Docker。看看是否可以将其升级到 5.x 或 6.x(通常,越新越好)。
否则,您将不得不降级插件(尽管我不知道哪个版本放弃了对 Gradle 4.7 的支持),或者您必须找到与旧版本兼容的替代品。
推荐阅读
- java - 列表类型的 Java 泛型用法
- c++ - std::pair 的初始化列表
, 双> - windows - 自动安装 NDIS 过滤器驱动程序
- php - 通过 html 表单 php 加载、编辑和更新 xml 文件
- algorithm - 判断数组中是否有名人
- windows - WINDOWS“启动cmd”让我发疯(设置颜色)
- julia - 如何向 Julia 中的特定 URL 发出请求?
- python-3.6 - 在两个字符串中查找相同的单词序列
- python - 从按升序排序的数组中返回大于给定数字的最小数字的索引的 C 函数
- c - Windows WFP 驱动程序:在 ClassifyFn 回调中处理数据包时出现 BSOD