docker build fails during ./mvnw clean package
apeiris opened this issue · comments
I have installed maven :
C:\Users\mapei\eclipse-workspace\OpenAs2App>mvnw --version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T07:57:37-04:00)
Maven home: C:\Users\mapei.m2\wrapper\dists\apache-maven-3.3.3-bin\3opbjp6rgl6qp7k2a6tljcpvgp\apache-maven-3.3.3
Java version: 17.0.5, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk-17.0.5
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 11", version: "10.0", arch: "amd64", family: "dos"
when the docker build -t openas2:latest .
it fails with
=> [builder 5/11] RUN rm -f Remote/dist/* 0.8s
=> [builder 6/11] RUN rm -f Bundle/dist/* 1.0s
=> ERROR [builder 7/11] RUN ./mvnw clean package
Try running the command on its own to get a better idea of what is failing:
./mvnw clean package
fork @ https://github.com/anbansal/OpenAs2App has the solution implemented with sed command. It is because of line-ending character mismatch when bundling the docker image
changes as below can solve the issue (works in Windows 11)
RUN rm -f Bundle/dist/*
RUN sed -i 's/\r$//' mvnw
RUN ./mvnw clean package
RUN mkdir ./Runtime && unzip Server/dist/OpenAS2Server-*.zip -d Runtime
RUN ./mvnw clean
Not sure if you are using the OpenAS2 official package or a fork but hethis command:
sed -i 's/\r$//' mvnw
... has no effect because the file ( mvnw in the root of the OpenAS2 repository) does not contain \r characters in the official OpenAS2 deployment and never has had.
Just a mention why this is necessary on Windows: The default of Git for Windows is to set line endings of text files to "CR LF" on pull. Pushing the files will replace the line ending back to "LF", see https://docs.github.com/de/get-started/getting-started-with-git/configuring-git-to-handle-line-endings.
This is always an issue with Docker images if the files are just copied into the image as the line ending is "CR LF" then.
There are typically two ways to handle this:
- Set the line endings to LF in the repo via .gitattributes ("* text=auto eol=lf" in the first line)
- Replace "CR LF" to "LF" as shown with sed above during build