spotify / dockerfile-maven

MATURE: A set of Maven tools for dealing with Dockerfiles
Apache License 2.0
2.75k stars 493 forks source link

Add a folder recursively #338

Closed tschlat closed 4 years ago

tschlat commented 4 years ago

This is a Bug Report

Description

I am trying to add a complete directory with all content to a docker image. I am using the following command in the respective Dockerfile:

ADD ./target/docker/ ${PF_TC_DIR}/

The docker dir contains subdirectories (conf and webapps). The Dockerfile executes correctly, when I run it from bamboo using a docker task that has the Dockerfile configured. If I try to run the same Dockerfile from the plugin i get the following error:

build 20-Jan-2020 08:33:44 [ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.4.13:build (default-cli) on project build-komm-server-docker-content: Could not copy files: /appl/bamboo/bamboo-agent-home4/xml-data/build-dir/ENTE-EFJAVA0-JOB1/ef_tools/komm/target/docker/conf (Is a directory) -> [Help 1]

Indicating that the source is a directoy - which is in fact true.

Version used: dockerfile-maven-plugin 1.4.13

By looking at the stacktrace below it looks like the mojo always interpretes the source as file and tries to load it as such. Is it at all possible to copy a directory (recursively) with the plugin?

Thanks for help.

Complete Trace

build 20-Jan-2020 08:02:40 [INFO] Status: Downloaded newer image for middleware-docker-local.repo.pnet.ch/pf/mw/tomcat-aplat:9.0-jre8-aplat19.10 build 20-Jan-2020 08:02:40 [INFO] ---> adee33361f84 build 20-Jan-2020 08:02:40 [INFO] Step 2/10 : USER root build 20-Jan-2020 08:02:40 [INFO] build 20-Jan-2020 08:02:40 [INFO] ---> Running in c18fdfb33403 build 20-Jan-2020 08:02:40 [INFO] Removing intermediate container c18fdfb33403 build 20-Jan-2020 08:02:40 [INFO] ---> f59cc8776fa6 build 20-Jan-2020 08:02:40 [INFO] Step 3/10 : RUN sed -i '/^networkaddress.cache.ttl=0$/d' ${JAVA_HOME}/jre/lib/security/java.security build 20-Jan-2020 08:02:40 [INFO] build 20-Jan-2020 08:02:40 [INFO] ---> Running in 9a98110aa9a5 build 20-Jan-2020 08:02:41 [INFO] Removing intermediate container 9a98110aa9a5 build 20-Jan-2020 08:02:41 [INFO] ---> 6c2de6cfc950 build 20-Jan-2020 08:02:41 [INFO] Step 4/10 : ENV MIDW_JVM_OPTIONS_APPLICATION="-Dsun.net.inetaddr.ttl=3 -Djavax.net.ssl.trustStore=/var/opt/neviskeybox/default/pki-all/truststore.jks" build 20-Jan-2020 08:02:41 [INFO] build 20-Jan-2020 08:02:41 [INFO] ---> Running in a8861e1205e7 build 20-Jan-2020 08:02:41 [INFO] Removing intermediate container a8861e1205e7 build 20-Jan-2020 08:02:41 [INFO] ---> d76fe85d16c3 build 20-Jan-2020 08:02:41 [INFO] Step 5/10 : RUN mkdir -p ${PF_TC_DIR}/conf/Catalina/localhost/ef/classes build 20-Jan-2020 08:02:41 [INFO] build 20-Jan-2020 08:02:41 [INFO] ---> Running in 0355f80a35d0 build 20-Jan-2020 08:02:42 [INFO] Removing intermediate container 0355f80a35d0 build 20-Jan-2020 08:02:42 [INFO] ---> b135e654b71b build 20-Jan-2020 08:02:42 [INFO] Step 6/10 : RUN mkdir -p ${PF_TC_DIR}/conf/Catalina/localhost/ef/lib build 20-Jan-2020 08:02:42 [INFO] build 20-Jan-2020 08:02:42 [INFO] ---> Running in 5009f1105195 build 20-Jan-2020 08:02:43 [INFO] Removing intermediate container 5009f1105195 build 20-Jan-2020 08:02:43 [INFO] ---> b10db5eebd94 build 20-Jan-2020 08:02:43 [INFO] Step 7/10 : COPY --chown=tomcat ./deploy.yaml /var/opt/neviskeybox/default/efin/d build 20-Jan-2020 08:02:43 [INFO] build 20-Jan-2020 08:02:43 [INFO] ---> 5b0984e4c518 build 20-Jan-2020 08:02:43 [INFO] Step 8/10 : USER tomcat build 20-Jan-2020 08:02:43 [INFO] build 20-Jan-2020 08:02:43 [INFO] ---> Running in 3a77d393b311 build 20-Jan-2020 08:02:43 [INFO] Removing intermediate container 3a77d393b311 build 20-Jan-2020 08:02:43 [INFO] ---> 1182cc852d7b build 20-Jan-2020 08:02:43 [INFO] Step 9/10 : ADD ./target/docker/ ${PF_TC_DIR}/ build 20-Jan-2020 08:02:43 [INFO] build 20-Jan-2020 08:02:44 [INFO] ---> 7358df6b71fb build 20-Jan-2020 08:02:44 [INFO] Step 10/10 : EXPOSE 8080 build 20-Jan-2020 08:02:44 [INFO] build 20-Jan-2020 08:02:44 [INFO] ---> Running in e9a5c324e06c build 20-Jan-2020 08:02:45 [INFO] Removing intermediate container e9a5c324e06c build 20-Jan-2020 08:02:45 [INFO] ---> 54326c827a11 build 20-Jan-2020 08:02:45 [INFO] [Warning] One or more build-args [JAR_FILE_NAME PROJECT_NAME PROJECT_VERSION JAR_FILE] were not consumed build 20-Jan-2020 08:02:45 [INFO] Successfully built 54326c827a11 build 20-Jan-2020 08:02:45 [INFO] Successfully tagged ente-docker-local.repo.pnet.ch/ef/komm-ef-e4:e4 build 20-Jan-2020 08:02:45 [INFO] build 20-Jan-2020 08:02:45 [INFO] Detected build of image with id 54326c827a11 build 20-Jan-2020 08:02:45 [WARNING] An attempt failed, will retry 1 more times build 20-Jan-2020 08:02:45 org.apache.maven.plugin.MojoExecutionException: Could not copy files build 20-Jan-2020 08:02:45 at com.spotify.plugin.dockerfile.AbstractDockerMojo.writeTestMetadata (AbstractDockerMojo.java:327) build 20-Jan-2020 08:02:45 at com.spotify.plugin.dockerfile.AbstractDockerMojo.writeMetadata (AbstractDockerMojo.java:284) build 20-Jan-2020 08:02:45 at com.spotify.plugin.dockerfile.BuildMojo.execute (BuildMojo.java:151) build 20-Jan-2020 08:02:45 at com.spotify.plugin.dockerfile.AbstractDockerMojo.tryExecute (AbstractDockerMojo.java:265) build 20-Jan-2020 08:02:45 at com.spotify.plugin.dockerfile.AbstractDockerMojo.execute (AbstractDockerMojo.java:254) build 20-Jan-2020 08:02:45 at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) build 20-Jan-2020 08:02:45 at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) build 20-Jan-2020 08:02:45 at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) build 20-Jan-2020 08:02:45 at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) build 20-Jan-2020 08:02:45 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) build 20-Jan-2020 08:02:45 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) build 20-Jan-2020 08:02:45 at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) build 20-Jan-2020 08:02:45 at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) build 20-Jan-2020 08:02:45 at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) build 20-Jan-2020 08:02:45 at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) build 20-Jan-2020 08:02:45 at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) build 20-Jan-2020 08:02:45 at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956) build 20-Jan-2020 08:02:45 at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288) build 20-Jan-2020 08:02:45 at org.apache.maven.cli.MavenCli.main (MavenCli.java:192) build 20-Jan-2020 08:02:45 at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) build 20-Jan-2020 08:02:45 at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) build 20-Jan-2020 08:02:45 at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) build 20-Jan-2020 08:02:45 at java.lang.reflect.Method.invoke (Method.java:498) build 20-Jan-2020 08:02:45 at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) build 20-Jan-2020 08:02:45 at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) build 20-Jan-2020 08:02:45 at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) build 20-Jan-2020 08:02:45 at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) build 20-Jan-2020 08:02:45 Caused by: java.io.FileNotFoundException: /appl/bamboo/bamboo-agent-home0/xml-data/build-dir/ENTE-EFJAVA0-JOB1/ef_tools/komm/target/docker/conf (Is a directory) build 20-Jan-2020 08:02:45 at java.io.FileInputStream.open0 (Native Method) build 20-Jan-2020 08:02:45 at java.io.FileInputStream.open (FileInputStream.java:195) build 20-Jan-2020 08:02:45 at java.io.FileInputStream. (FileInputStream.java:138) build 20-Jan-2020 08:02:45 at com.google.common.io.Files$FileByteSource.openStream (Files.java:130) build 20-Jan-2020 08:02:45 at com.google.common.io.Files$FileByteSource.openStream (Files.java:120) build 20-Jan-2020 08:02:45 at com.google.common.io.ByteSource.copyTo (ByteSource.java:266) build 20-Jan-2020 08:02:45 at com.google.common.io.Files.copy (Files.java:327) build 20-Jan-2020 08:02:45 at com.spotify.plugin.dockerfile.AbstractDockerMojo.writeTestMetadata (AbstractDockerMojo.java:325) build 20-Jan-2020 08:02:45 at com.spotify.plugin.dockerfile.AbstractDockerMojo.writeMetadata (AbstractDockerMojo.java:284) build 20-Jan-2020 08:02:45 at com.spotify.plugin.dockerfile.BuildMojo.execute (BuildMojo.java:151) build 20-Jan-2020 08:02:45 at com.spotify.plugin.dockerfile.AbstractDockerMojo.tryExecute (AbstractDockerMojo.java:265) build 20-Jan-2020 08:02:45 at com.spotify.plugin.dockerfile.AbstractDockerMojo.execute (AbstractDockerMojo.java:254) build 20-Jan-2020 08:02:45 at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) build 20-Jan-2020 08:02:45 at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) build 20-Jan-2020 08:02:45 at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) build 20-Jan-2020 08:02:45 at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) build 20-Jan-2020 08:02:45 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) build 20-Jan-2020 08:02:45 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) build 20-Jan-2020 08:02:45 at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) build 20-Jan-2020 08:02:45 at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) build 20-Jan-2020 08:02:45 at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) build 20-Jan-2020 08:02:45 at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) build 20-Jan-2020 08:02:45 at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) build 20-Jan-2020 08:02:45 at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956) build 20-Jan-2020 08:02:45 at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288) build 20-Jan-2020 08:02:45 at org.apache.maven.cli.MavenCli.main (MavenCli.java:192) build 20-Jan-2020 08:02:45 at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) build 20-Jan-2020 08:02:45 at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) build 20-Jan-2020 08:02:45 at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) build 20-Jan-2020 08:02:45 at java.lang.reflect.Method.invoke (Method.java:498) build 20-Jan-2020 08:02:45 at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) build 20-Jan-2020 08:02:45 at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) build 20-Jan-2020 08:02:45 at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) build 20-Jan-2020 08:02:45 at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) build 20-Jan-2020 08:02:45 [INFO] dockerfile: null build 20-Jan-2020 08:02:45 [INFO] contextDirectory: /appl/bamboo/bamboo-agent-home0/xml-data/build-dir/ENTE-EFJAVA0-JOB1/ef_tools/komm build 20-Jan-2020 08:02:45 [INFO] Building Docker context /appl/bamboo/bamboo-agent-home0/xml-data/build-dir/ENTE-EFJAVA0-JOB1/ef_tools/komm build 20-Jan-2020 08:02:45 [INFO] Path(dockerfile): null build 20-Jan-2020 08:02:45 [INFO] Path(contextDirectory): /appl/bamboo/bamboo-agent-home0/xml-data/build-dir/ENTE-EFJAVA0-JOB1/ef_tools/komm build 20-Jan-2020 08:02:45 [INFO] build 20-Jan-2020 08:02:45 [INFO] Image will be built as ente-docker-local.repo.pnet.ch/ef/komm-ef-e4:e4 build 20-Jan-2020 08:02:45 [INFO] build 20-Jan-2020 08:02:49 [INFO] Step 1/10 : FROM middleware-docker-local.repo.pnet.ch/pf/mw/tomcat-aplat:9.0-jre8-aplat19.10 build 20-Jan-2020 08:02:49 [INFO] build 20-Jan-2020 08:02:49 [INFO] Pulling from pf/mw/tomcat-aplat build 20-Jan-2020 08:02:49 [INFO] Digest: sha256:bf3d3601d874228b45a760e77ffe3a9e49f4b1f4930dde90675aea74add6132d build 20-Jan-2020 08:02:49 [INFO] Status: Image is up to date for middleware-docker-local.repo.pnet.ch/pf/mw/tomcat-aplat:9.0-jre8-aplat19.10 build 20-Jan-2020 08:02:49 [INFO] ---> adee33361f84 build 20-Jan-2020 08:02:49 [INFO] Step 2/10 : USER root build 20-Jan-2020 08:02:49 [INFO] build 20-Jan-2020 08:02:49 [INFO] ---> Using cache build 20-Jan-2020 08:02:49 [INFO] ---> f59cc8776fa6 build 20-Jan-2020 08:02:49 [INFO] Step 3/10 : RUN sed -i '/^networkaddress.cache.ttl=0$/d' ${JAVA_HOME}/jre/lib/security/java.security build 20-Jan-2020 08:02:49 [INFO] build 20-Jan-2020 08:02:49 [INFO] ---> Using cache build 20-Jan-2020 08:02:49 [INFO] ---> 6c2de6cfc950 build 20-Jan-2020 08:02:49 [INFO] Step 4/10 : ENV MIDW_JVM_OPTIONS_APPLICATION="-Dsun.net.inetaddr.ttl=3 -Djavax.net.ssl.trustStore=/var/opt/neviskeybox/default/pki-all/truststore.jks" build 20-Jan-2020 08:02:49 [INFO] build 20-Jan-2020 08:02:49 [INFO] ---> Using cache build 20-Jan-2020 08:02:49 [INFO] ---> d76fe85d16c3 build 20-Jan-2020 08:02:49 [INFO] Step 5/10 : RUN mkdir -p ${PF_TC_DIR}/conf/Catalina/localhost/ef/classes build 20-Jan-2020 08:02:49 [INFO] build 20-Jan-2020 08:02:49 [INFO] ---> Using cache build 20-Jan-2020 08:02:49 [INFO] ---> b135e654b71b build 20-Jan-2020 08:02:49 [INFO] Step 6/10 : RUN mkdir -p ${PF_TC_DIR}/conf/Catalina/localhost/ef/lib build 20-Jan-2020 08:02:49 [INFO] build 20-Jan-2020 08:02:49 [INFO] ---> Using cache build 20-Jan-2020 08:02:49 [INFO] ---> b10db5eebd94 build 20-Jan-2020 08:02:49 [INFO] Step 7/10 : COPY --chown=tomcat ./deploy.yaml /var/opt/neviskeybox/default/efin/d build 20-Jan-2020 08:02:49 [INFO] build 20-Jan-2020 08:02:49 [INFO] ---> Using cache build 20-Jan-2020 08:02:49 [INFO] ---> 5b0984e4c518 build 20-Jan-2020 08:02:49 [INFO] Step 8/10 : USER tomcat build 20-Jan-2020 08:02:49 [INFO] build 20-Jan-2020 08:02:49 [INFO] ---> Using cache build 20-Jan-2020 08:02:49 [INFO] ---> 1182cc852d7b build 20-Jan-2020 08:02:49 [INFO] Step 9/10 : ADD ./target/docker/ ${PF_TC_DIR}/ build 20-Jan-2020 08:02:49 [INFO] build 20-Jan-2020 08:02:50 [INFO] ---> e3b235154a5f build 20-Jan-2020 08:02:50 [INFO] Step 10/10 : EXPOSE 8080 build 20-Jan-2020 08:02:50 [INFO] build 20-Jan-2020 08:02:50 [INFO] ---> Running in 7892772f2af1 build 20-Jan-2020 08:02:51 [INFO] Removing intermediate container 7892772f2af1 build 20-Jan-2020 08:02:51 [INFO] ---> ab6d6fccc722 build 20-Jan-2020 08:02:51 [INFO] [Warning] One or more build-args [PROJECT_NAME PROJECT_VERSION JAR_FILE JAR_FILE_NAME] were not consumed build 20-Jan-2020 08:02:51 [INFO] Successfully built ab6d6fccc722 build 20-Jan-2020 08:02:51 [INFO] Successfully tagged ente-docker-local.repo.pnet.ch/ef/komm-ef-e4:e4 build 20-Jan-2020 08:02:51 [INFO] build 20-Jan-2020 08:02:51 [INFO] Detected build of image with id ab6d6fccc722 build 20-Jan-2020 08:02:51 [INFO] ------------------------------------------------------------------------ build 20-Jan-2020 08:02:51 [INFO] BUILD FAILURE build 20-Jan-2020 08:02:51 [INFO] ------------------------------------------------------------------------ build 20-Jan-2020 08:02:51 [INFO] Total time: 03:21 min build 20-Jan-2020 08:02:51 [INFO] Finished at: 2020-01-20T08:02:51+01:00 build 20-Jan-2020 08:02:51 [INFO] ------------------------------------------------------------------------ build 20-Jan-2020 08:02:51 [ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.4.13:build (default-cli) on project build-komm-server-docker-content: Could not copy files: /appl/bamboo/bamboo-agent-home0/xml-data/build-dir/ENTE-EFJAVA0-JOB1/ef_tools/komm/target/docker/conf (Is a directory) -> [Help 1] build 20-Jan-2020 08:02:51 [ERROR] build 20-Jan-2020 08:02:51 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. build 20-Jan-2020 08:02:51 [ERROR] Re-run Maven using the -X switch to enable full debug logging.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.