0

我正在使用 dockerfile maven 插件来构建 docker 映像。在 pom.xml 文件中,3 个 args 将被发送到 dockerfile。我在这里添加了我的 dockerfile。

ARG PROJECT_BASE_DIR
ARG TOMCAT_JULI_ADAPTER_VERSION
ARG TOMCAT_JULI_VERSION
FROM tomcat:8.0-jre8
ADD ${PROJECT_BASE_DIR}/target/dependency/log4j-1.2.17.jar /usr/local/tomcat/lib/
ADD ${PROJECT_BASE_DIR}/target/dependency/ojdbc7-12.1.0.2.jar /usr/local/tomcat/lib/
ADD ${PROJECT_BASE_DIR}/target/dependency/tomcat-extras-juli ${TOMCAT_JULI_ADAPTER_VERSION}.jar /usr/local/tomcat/lib/

ADD ${PROJECT_BASE_DIR}/target/dependency/tomcat-juli-${TOMCAT_JULI_VERSION}.jar /usr/local/tomcat/bin/

ADD ${PROJECT_BASE_DIR}/configuration/log4j.properties /usr/local/tomcat/lib/
ADD ${PROJECT_BASE_DIR}/configuration/server.xml /usr/local/tomcat/conf/
ADD ${PROJECT_BASE_DIR}/scripts/setenv.sh /usr/local/tomcat/

RUN chmod +x setenv.sh
RUN rm /usr/local/tomcat/conf/logging.properties
EXPOSE 8080
ENTRYPOINT [ "sh", "-c", "./setenv.sh" ]

pom.xml 文件

<configuration>
        <repository>${docker.image.name}</repository>
        <tag>${project.version}</tag>
        <buildArgs>
           <PROJECT_BASE_DIR>${project.basedir}</PROJECT_BASE_DIR>
           <TOMCAT_JULI_VERSION>${tomcat-juli.version}</TOMCAT_JULI_VERSION>
           <TOMCAT_JULI_ADAPTER_VERSION>${tomcat-juli-adapters.version}</TOMCAT_JULI_ADAPTER_VERSION>
         </buildArgs>
 </configuration>

运行时,它不会采用${TOMCAT_JULI_VERSION}${TOMCAT_JULI_ADAPTER_VERSION}中的值,而是采用 ${PROJECT_BASE_DIR} 值。我收到以下错误。

添加失败:stat /var/lib/docker/tmp/docker-builder537359917/target/dependency/tomcat-extras-juli-.jar:没有这样的文件或目录

4

0 回答 0