I have an application in dockerfile where it is necessary to call a .sh file to download packages, but there is always an error when calling this file.
My dockerfile is:
FROM alpine:3.12 as builder
ARG VERSION=7.16.0
ARG DISTRO=tomcat
ARG SNAPSHOT=true
ARG JMX_PROMETHEUS_VERSION=0.12.0
RUN apk add --no-cache \
bash \
ca-certificates \
maven \
tar \
wget \
xmlstarlet
COPY settings.xml download.sh camunda-run.sh camunda-tomcat.sh camunda-wildfly.sh /tmp/
RUN /tmp/download.sh
FROM alpine:3.12
RUN apk add --no-cache \
bash \
ca-certificates \
curl \
openjdk11-jre-headless \
tzdata \
tini \
xmlstarlet \
&& curl -o /usr/local/bin/wait-for-it.sh \
"https://raw.githubusercontent.com/vishnubob/wait-for-it/a454892f3c2ebbc22bd15e446415b8fcb7c1cfa4/wait-for-it.sh" \
&& chmod +x /usr/local/bin/wait-for-it.sh
RUN addgroup -g 1000 -S camunda && \
adduser -u 1000 -S camunda -G camunda -h /camunda -s /bin/bash -D camunda
WORKDIR /camunda
USER camunda
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["./camunda.sh"]
COPY --chown=camunda:camunda --from=builder /camunda .
My download.sh file looks exactly like this: https://github.com/camunda/docker-camunda-bpm-platform/blob/next/download.sh
When running the command: docker build . -t servicecamundadocker/latest i get the error:
=> ERROR [builder 4/4] RUN /tmp/download.sh 0.2s ------
> [builder 4/4] RUN /tmp/download.sh:
#11 0.216 /bin/sh: illegal option -
------

Does anyone know how to fix this error? Thanks
After a lot of research, I found the solution.
The problem is that Windows uses \r\n as an end of line, whereas unix only uses \n. So, inside my download.sh file, there was a ^M character that led to the error /bin/sh: illegal option
The solution was to copy the code from the downlod.sh file and convert it to LF:
Once that is done, the docker build works correctly.
Thank you all for the support.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With