geosolutions-it/docker-geoserver

Wrong encoding for file geoserver-plugin-download.sh

FP-Geosolutions opened this issue · 4 comments

Wrong encoding for file geoserver-plugin-download.sh

[+] Building 5.5s (18/37)
 => [internal] load build definition from Dockerfile                                                                                                                                                                                    0.0s
 => => transferring dockerfile: 5.70kB                                                                                                                                                                                                  0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                       0.0s
 => => transferring context: 53B                                                                                                                                                                                                        0.0s
 => [internal] load metadata for docker.io/library/tomcat:9-jdk11-openjdk                                                                                                                                                               4.4s
 => [auth] library/tomcat:pull token for registry-1.docker.io                                                                                                                                                                           0.0s
 => https://build.geoserver.org/geoserver/main/geoserver-main-latest-war.zip                                                                                                                                                            0.4s
 => [mother  1/15] FROM docker.io/library/tomcat:9-jdk11-openjdk@sha256:2a335cf8a9f43a885227cc3cb927dccadcd22e075d4f2b0bc1e6d5668e744fa0                                                                                                0.0s
 => [internal] load build context                                                                                                                                                                                                       0.1s
 => => transferring context: 87.47kB                                                                                                                                                                                                    0.0s
 => CACHED [mother  2/15] RUN apt-get update && apt-get install -y unzip wget cmake nasm    && wget https://nav.dl.sourceforge.net/project/libjpeg-turbo/2.0.6/libjpeg-turbo-2.0.6.tar.gz     && tar -zxf ./libjpeg-turbo-2.0.6.tar.gz  0.0s
 => CACHED [mother  3/15] WORKDIR /output/datadir                                                                                                                                                                                       0.0s
 => CACHED [mother  4/15] ADD ./.placeholder ./                                                                                                                                                                                         0.0s
 => CACHED [mother  5/15] WORKDIR /output/webapp                                                                                                                                                                                        0.0s
 => CACHED [mother  6/15] ADD https://build.geoserver.org/geoserver/main/geoserver-main-latest-war.zip ./                                                                                                                               0.0s
 => CACHED [mother  7/15] RUN     if [ -f "./download" ] ; then       mv download geoserver.war.zip && unzip geoserver.war.zip -d geoserver.war && mkdir -p ./geoserver && unzip ./geoserver.war/geoserver.war -d ./geoserver && rm -r  0.0s
 => CACHED [mother  8/15] RUN     if [ "${GEOSERVER_WEBAPP_SRC##*.}" = "zip" ]; then         unzip "./*zip";         rm ./*zip;     fi     && [ -d "./geoserver" ] || (mkdir -p ./geoserver && unzip ./geoserver.war -d ./geoserver &&  0.0s
 => CACHED [mother  9/15] WORKDIR /output/plugins                                                                                                                                                                                       0.0s
 => CACHED [mother 10/15] ADD .placeholder  /output/plugins/                                                                                                                                                                            0.0s
 => CACHED [mother 11/15] COPY geoserver-plugin-download.sh /usr/local/bin/geoserver-plugin-download.sh                                                                                                                                 0.0s
 => ERROR [mother 12/15] RUN /usr/local/bin/geoserver-plugin-download.sh /output/plugins/                                                                                                                                               0.5s
------
 > [mother 12/15] RUN /usr/local/bin/geoserver-plugin-download.sh /output/plugins/ :
#20 0.437 /usr/bin/env: ‘bash\r’: No such file or directory
------
failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/bash -c /usr/local/bin/geoserver-plugin-download.sh /output/plugins/ ${PLUG_IN_URLS}]: exit code: 127```

geoserver-plugin-download.sh was pushed with CRLF, but the problem is during the commit phase that replace it

>git commit -m "fix issue#89" -a
warning: LF will be replaced by CRLF in geoserver-plugin-download.sh.
The file will have its original line endings in your working directory.
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean

here a problem mitigations:

https://stackoverflow.com/questions/5834014/lf-will-be-replaced-by-crlf-in-git-what-is-that-and-is-it-important

https://stackoverflow.com/questions/2517190/how-do-i-force-git-to-use-lf-instead-of-crlf-under-windows

can you please take a look @PabloBaronetti ?

Create .gitattributes file and add roules like:

* text=auto
*.sh text eol=lf

look at this reference:
https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings

Hello!

@randomorder sure!
@FP-Geosolutions

I start working on the issue, what do you think about these options for the .gitattributes file:

# Set default behavior to automatically normalize line endings.
* text=auto

# Declare files that will always have LF line endings on checkout.
*.xml         text eol=lf
*.js          text eol=lf
*.jsx         text eol=lf
*.json        text eol=lf
*.properties  text eol=lf
*.conf        text eol=lf
*.sh          text eol=lf

# Denote all files that are truly binary and should not be modified.
*.png  binary
*.jpg  binary

Thank you!