Error in running spid-sp-test as Docker container on Windows 10
I was tying to setup a test environment on my host as a Docker container. I started cloning the repo locally. Then, I built the image typing docker build -t italia/spid-sp-test:0.5.6 ., as reported in doc, and the image was successfully built. Then, I tried to run the image in a local container, but this is the output:
$> docker run -it --name idptest-agid-local italia/spid-sp-test:0.5.6
/usr/bin/env: 'python3\r': No such file or directory
I am working on a Windows 10 host. It seems like something goes wrong when interpeting the CRLF or the EoL chars in general.
Seems to be related to this https://askubuntu.com/questions/896860/usr-bin-env-python3-r-no-such-file-or-directory
I have to check on a Windows machine. If you can in the meantime, you should find src/spid_sp_test/spid_sp_test and that shebang at the begin of the file, on top.
Do a eol fix before Building the image, this should do the trick.
If It's the patch feel free to l'et us know, I'll purpose your contribution for the next release
Here It Is https://github.com/italia/spid-sp-test/blob/053c812d34475099697443f94ef3eff94f43c629/src/spid_sp_test/spid_sp_test#L1
For a Quick way, don't rebuild the docker but Just enter in It executing a bash
docker exec -it
Then you'll find the spid_sp_test executable and a closer way to test our ipothesys
I resolved this issue disinstalling all Python version installed on my pc, deleting the folders relating to Python that didn't deleted during disinstallation and deleting the related environment variables. Then I installed Python to the path adviced from installer (behind user folder and not in C:\Program Files), than I added python paths on env variable. All works fine.
I solved using dos2unix when building the Dockerfile:
FROM python:3.8-slim-buster
LABEL maintainer="Giuseppe De Marco <[email protected]>"
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
xmlsec1 \
libxml2-dev \
libxmlsec1-dev \
libxmlsec1-openssl \
dos2unix \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& adduser \
--disabled-password \
--home /spid \
--quiet \
spid
COPY . /tmp/src/
RUN pip install --no-cache-dir /tmp/src/ \
&& rm -fr /tmp/src
WORKDIR /spid
RUN dos2unix $(which spid_sp_test)
USER spid
ENTRYPOINT ["spid_sp_test"]
CMD ["--help"]