Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lineEnding and fileMode used in assembly.xml don't work #127

Closed
dugchez opened this issue Mar 16, 2015 · 11 comments
Closed

lineEnding and fileMode used in assembly.xml don't work #127

dugchez opened this issue Mar 16, 2015 · 11 comments

Comments

@dugchez
Copy link

dugchez commented Mar 16, 2015

Using version 0.11.2.

I have the following in assembly.xml. In the container I can see the file has indeed been copied to /usr/local/tomcat/bin/start.sh. However, the permissions are:

-rw-r--r-- 1 root root 89 Mar 16 06:04 start.sh

<file>
            <source>${basedir}/target/docker/start.sh</source>
            <outputDirectory>/usr/local/tomcat/bin</outputDirectory>
            <lineEnding>unix</lineEnding>
            <fileMode>0777</fileMode>
</file>

Also, if I open the file (which was originally created on Windows, and therefore had CRLF in it) in Notepad++ I can see that the CRLF have not been replaced with LF.

Environment:

Apache Maven 3.2.2
Java version: 1.8.0_40, vendor: Oracle Corporation
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"

@jgangemi
Copy link
Collaborator

can you re-try w/ the latest release? i didn't verify line endings were adjusted but but file permissions were correctly set.

@alexkrauss
Copy link

The issue still occurs with 0.13.4, at least on Windows.

Note that the problem already seems to be present in the intermediate tar file created under target/.

Here is a minimal project that can be used to reproduce the issue:
https://github.com/alexkrauss/maven-docker-reproducer/

@rhuss
Copy link
Collaborator

rhuss commented Sep 28, 2015

Can you please an assembly mode of tar (instead of dir) ? dir has issues on Windows, therefor the assembly mode tar was introduced which uses an tar-archive as intermediate format to avoid permission issues while using a plain directory for file creation.

@rhuss
Copy link
Collaborator

rhuss commented Sep 28, 2015

See also #51 and #139.

@alexkrauss
Copy link

OK. Switching assembly mode to tar solves the file permissions, but the line ending problem persists.

Updated the test case (and corresponding readme) to reflect this.

@sebglon
Copy link

sebglon commented Jan 29, 2016

How can you set assembly mode to tar?

@rhuss
Copy link
Collaborator

rhuss commented Jan 29, 2016

<build>
   <assembly>
       <mode>tar</mode>
       ...
   </assembly>
   ....
</build>

See also the manual

@raffaelespazzoli
Copy link

lineEnding seems to be working for me in Windows on version 0.13.7. It doesn't work with the following versions. Also with versions 0.13.8 and 0.13.9, in Windows,even if a have a file with unix lined ending it seems to overwrite the end of line character(s) with the Windows style.
This feature is very important because many corporations give Windows laptops to their employees. This plugin is a good way to work with docker.
I'd ask the project owner to increase the priority of this issue.

@rhuss
Copy link
Collaborator

rhuss commented Feb 22, 2016

I will try to reproduce this which is not so easy because of lack of a proper Windows development environment.

Of course you always can increase the speed by providing some pull request ;-)

@rhuss
Copy link
Collaborator

rhuss commented Feb 23, 2016

I could reproduce the issue, it's due to a bug in the maven-assemply-plugin 2.5.1 which doesn't do a conversion of file endings if filtering is switched off.

The next version of d-m-p (probably 0.14.0) will upgrade to the fixed Maven Assembly Plugin. A current development version 0.14.0-SNAPSHOT has been pushed to Maven central containing this fix.

In the meantime the following workaround will do it on Windows:

  • use a <mode>tar</mode> in <assembly> config of d-m-p (thats for the permissions)
  • use <lineEnding>unix</lineEnding> and <filtered>true</filtered> in assembly descriptor

I updated the referenced example above.

@rhuss rhuss closed this as completed in bae1fc0 Feb 23, 2016
@techjoshua
Copy link

I can run "docker build" manually on windows and inside my linux vm just fine, but creating an image via this plugin does not work for scripts that must be marked as executable. Adding <mode>tar</mode> doesn't seem to change anything. Indeed the problem seems to be that the lack of executable bits inside the tar on windows. On filesystems that don't have executable bits for permissions, Docker always assumes every file is executable. However, since its packed in a tar file that does have permissions, it honors the permissions of the file inside the archive.

I'm not sure why you're packaging things in a tar file beforehand, but that seems to be the default behavior at this point and it breaks executable permissions on windows. I can't even get it to use the 'dir' mode at this point. If you want to keep doing this I'd suggest you at least do as Docker has done and assume chmod +x on all files coming from filesystems that don't support executable permissions (like Windows) when you create your tar file.

leusonmario pushed a commit to leusonmario/docker-maven-plugin that referenced this issue Aug 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants