0

I have a Django project and I'm trying to set it up with Docker. I use Poetry, so I have to install Poetry in the container. Below is my Dockerfile.

FROM python:3.9.7-alpine
WORKDIR /usr/src/app

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# install curl because it does not exist on alpine
RUN apk --no-cache add curl

# install poetry
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -

# install dependencies
RUN poetry install

COPY . .

However, it gives this obscure error which does not help at all:

Traceback (most recent call last):
  File "<stdin>", line 440, in run
  File "<stdin>", line 464, in install
  File "<stdin>", line 589, in install_poetry
  File "/usr/local/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/root/.local/share/pypoetry/venv/bin/python', '-m', 'pip', 'install', 'poetry==1.1.8']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 837, in <module>
  File "<stdin>", line 833, in main
  File "<stdin>", line 443, in run
AttributeError: 'NoneType' object has no attribute 'decode'
The command '/bin/sh -c curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -' returned a non-zero code: 1

Haven't found any issues or posts related to this, so I wanted to ask if anyone came across this issue or anyone knows how to troubleshoot this.

Thanks in advance.

Eray Erdin
  • 2,633
  • 1
  • 32
  • 66

1 Answers1

1

Unfortunately the installer script hides the original error message. Otherwise one could see, that the cryptography package can not be build due to a missing compiler.Install the package listed in the docs (gcc musl-dev python3-dev libffi-dev openssl-dev cargo) and it should work.

finswimmer
  • 10,896
  • 3
  • 34
  • 44