docker-maven-plugin icon indicating copy to clipboard operation
docker-maven-plugin copied to clipboard

Support of binary log of container

Open mabrarov opened this issue 4 years ago • 4 comments

Description

Need to support the case when container stdout is a binary log, e.g. container command looks like:

CMD ["/usr/bin/cat", "/out.tar.gz"]

This is a frequent pattern for builder image approach when tarball with built application is created during build of builder image or during execution of builder container. Then, at the end of execution of builder container, tarball with built application is sent to stdout.

This feature looks simpler to implement comparing to #752, which can be used too when there is a need to extract file(s) from container (and when remote Docker instance is used).

Info

  • d-m-p version : 0.34.1
  • Maven version (./mvnw -v) :
    Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T19:00:29Z)
    Maven home: /home/user/.m2/wrapper/dists/apache-maven-3.6.1-bin/38pn40mp89t5c94bjdbeod370m/apache-maven-3.6.1
    Java version: 11.0.10, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
    Default locale: en_US, platform encoding: UTF-8
    OS name: "linux", version: "4.15.0-136-generic", arch: "amd64", family: "unix"
    
  • Docker version (docker version) :
    Client: Docker Engine - Community
     Version:           19.03.12
     API version:       1.40
     Go version:        go1.13.10
     Git commit:        48a66213fe
     Built:             Mon Jun 22 15:45:36 2020
     OS/Arch:           linux/amd64
     Experimental:      false
    
    Server: Docker Engine - Community
     Engine:
      Version:          19.03.12
      API version:      1.40 (minimum version 1.12)
      Go version:       go1.13.10
      Git commit:       48a66213fe
      Built:            Mon Jun 22 15:44:07 2020
      OS/Arch:          linux/amd64
      Experimental:     false
     containerd:
      Version:          1.2.13
      GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
     runc:
      Version:          1.0.0-rc10
      GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
     docker-init:
      Version:          0.18.0
      GitCommit:        fec3683
    
  • Use case : refer to "Description" section
  • Sample project :
    $ git clone --branch feature/docker-maven-plugin_app_tar https://github.com/mabrarov/maven-docker-builder.git && \
    cd maven-docker-builder && ./mvnw package
    ...
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Summary for maven-docker-builder 0.0.1:
    [INFO]
    [INFO] maven-docker-builder ............................... SUCCESS [ 16.226 s]
    [INFO] builder-image ...................................... SUCCESS [01:32 min]
    [INFO] app ................................................ SUCCESS [  1.984 s]
    [INFO] app-image .......................................... FAILURE [  0.055 s]
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  01:50 min
    [INFO] Finished at: 2021-03-08T10:44:35Z
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:3.3.0:single (build-rootfs) on project app-image: Failed to create assembly: Error creating assembly archive rootfs: Not in GZIP format -> [Help 1]
    
    It looks like the build fails, because container output is modified by d-m-p before it's written to the log file and this leads to invalid format of app/target/out.tar.gz file.

mabrarov avatar Oct 21 '20 02:10 mabrarov

I think it shouldn't be a huge problem to introduce a 'raw log' option, but as Maven itself is quite chatty, I'm not sure if this will solve your problem if we only shut up this plugin. Could you share your pom.xml from the Maven run shown above ? How doe the concrete generated (falsy) tarball looks like ?

rhuss avatar Mar 07 '21 07:03 rhuss

Here is the file (shuold be a valid tar.gz archive, but it isn't) which I get when using sample project from description of this issue: app.tar.gz

mabrarov avatar Mar 08 '21 01:03 mabrarov

Looking into the file it looks like that it's completely binary and I can't identify any special Maven logging output with eg. strings. So not sure how to fix this. What concrete steps have you done to generate that app.tar.gz ? A reproducer would be very helpful.

rhuss avatar Mar 08 '21 07:03 rhuss

@rhuss,

I just found that the repro project I provided in description stopped working completely after migration to the recent version of DMP. I updated the project and now it produces the same result as it was when I opened this issue.

What concrete steps have you done to generate that app.tar.gz ? A reproducer would be very helpful.

Refer to description of this issue:

$ git clone --branch feature/docker-maven-plugin_app_tar https://github.com/mabrarov/maven-docker-builder.git && \
cd maven-docker-builder && ./mvnw package

Use master branch of maven-docker-builder for the working example utilizing Maven AntRun Plugin.

Output generated by app module of feature/docker-maven-plugin_app_tar branch (the broken archive) when building on Windows 10 with Docker running on Ubuntu 18.04 (i.e. remote Docker instance is used): app.tar.gz

Output generated by app module of feature/docker-maven-plugin_app_tar branch (the broken archive) when building on Ubuntu 18.04 (i.e. when local Docker instance is used): app.tar.gz

Output generated by app module of master branch (the expected archive) when building on Windows 10 with remote Docker instance running on Ubuntu 18.04: app.tar.gz

mabrarov avatar Mar 08 '21 09:03 mabrarov