将.jar许可证文件添加到 Docker 映像的类路径?



我有一个 springboot 应用程序,它连接到 DB2 数据库,然后检索一些数据并为其提供 REST 端点。为了方便这一点,将许可证添加到应用程序的类路径中,以允许它与 DB2 数据库进行通信。这行得通。但是,当我在本地构建和映像并运行该映像时,我收到一个错误,指出许可证不存在。

{
"timestamp": 1569854043909,
"status": 500,
"error": "Internal Server Error",
"exception": "org.springframework.jdbc.CannotGetJdbcConnectionException",
"message": "Could not get JDBC Connection; nested exception is com.ibm.db2.jcc.am.SqlSyntaxErrorException: [jcc][t4][10509][13454][4.26.14] Connection to the data server failed. The IBM Data Server for JDBC and SQLJ license was invalid nor was not activated for the DB2 for z/OS subsystem. If you are connecting directly to nthe data server and using DB2 Connect Unlimited Edition for System z, perform the nactivation step by running the activation program in the license activation kit.  nIf you are using any other edition of DB2 Connect, obtain the license file, ndb2jcc_license_cisuz.jar, from the license activation kit, and follow the installation ndirections to include the license file in the class path. ERRORCODE=-4230, SQLSTATE=42968",
"path": "/test"
}

我假设这是因为许可证现在不包含在 Docker 容器类路径中。我已经对此进行了相当多的研究,但看不到任何关于我将如何做到这一点的指示。因此,任何帮助将不胜感激。

我的许可证保存在项目根目录的 lib 文件夹中,是一个 jar 文件。

我的码头工人文件:

FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG JAR_FILE
COPY target/mydb2jdbcproject-1.jar mydb2jdbcproject-1.jar
COPY lib/db2jcc_license_cisuz.jar db2jcc_license_cisuz.jar
#CLASSPATH: lib/db2jcc_license_cisuz.jar/
EXPOSE 8080
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","mydb2jdbcproject-1.jar"]

我最终不得不更改用于在运行前手动设置多个类路径的 CMD,并且由于某种原因它不适用于 -jar,所以我不得不通过启动器类运行。

生成的 dockerfile 如下所示:

FROM openjdk:8-jdk-alpine
RUN mkdir -p /opt/mvp2/db2jdbc /opt/mvp2/app
COPY target/db2new-0.1.jar /opt/mvp2/app/
COPY jdbc/db2jcc4.jar  /opt/mvp2/db2jdbc/
COPY jdbc/db2jcc_license_cisuz.jar  /opt/mvp2/db2jdbc/
CMD ["java","-classpath","/opt/mvp2/db2jdbc/db2jcc4.jar:/opt/mvp2/db2jdbc/db2jcc_license_cisuz.jar:/opt/mvp2/app/db2new-0.1.jar:.","org.springframework.boot.loader.JarLauncher"]

最新更新