-
Hello! I'm reaching out because I ran into some issues installing Poetry dependencies yesterday. I realized that my issue was caused as a result of Poetry updating and deprecating the preferred installation method from:
to
I couldn't figure out my issue until taking a closer look at the directories. Downside, I spent a day on this; upside, I learned. From tinkering around with the Dockerfile I discovered that:
I had no idea until taking a closer look (see Dockerfile below, or gist). FROM tiangolo/uvicorn-gunicorn-fastapi:python3.8
RUN pip install --upgrade pip
ARG poetry_version="master"
# install-poetry.py and get-poetry.py are options; but get-poetry.py is deprecated though!
ARG poetry_script_name="install-poetry.py"
ARG debug_poetry="true"
ENV PATH="/opt/poetry/bin:${PATH}"
# Install Poetry
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/${poetry_version}/${poetry_script_name} | POETRY_HOME=/opt/poetry python && \
cd /usr/local/bin && \
ln -s /opt/poetry/bin/poetry && poetry config virtualenvs.create false && poetry config virtualenvs.in-project false && poetry config experimental.new-installer false
RUN if [ ${debug_poetry} = "true" ] ; then echo $debug_poetry && apt-get update && apt-get install -y tree && cd /opt && tree -la . ; fi
# Copy using poetry.lock* in case it doesn't exist yet
COPY ./app/pyproject.toml ./app/poetry.lock* /app/
WORKDIR /app/
# If using get-poetry.py - /opt/poetry/env instead of /opt/poetry/venv
RUN if [ ${poetry_script_name} = "get-poetry.py" ]; then which python && . /opt/poetry/env && poetry install --no-root --no-dev && poetry env info ; fi
# If using install-poetry.py - /opt/poetry/venv instead of /opt/poetry/env
RUN if [ ${debug_poetry} = "true" ] ; then echo $debug_poetry && apt-get update && apt-get install -y tree && cd /usr/local/bin && tree -la . ; fi
RUN if [ ${poetry_script_name} = "install-poetry.py" ]; then poetry export -f requirements.txt --output requirements.txt && pip install --no-cache-dir -r requirements.txt ; fi
# TODO: fix this once https://github.com/python-poetry/poetry/issues/3870 gets resolved
#RUN if [ ${poetry_script_name} = "install-poetry.py" ]; then which python && cd /usr/local/bin/ && poetry config --list && poetry config virtualenvs.create false && cd /app/ && poetry env use `which python` && poetry install --no-root --no-dev -vvv && poetry env info ; fi
# Resources for learning Bash if statements
# https://ryanstutorials.net/bash-scripting-tutorial/bash-if-statements.php
# Running pip list below to use output to verify that our pyproject.toml file has been installed correctly
RUN pip list
# Final copy
COPY ./app /app As such, I wanted to raise this issue and make this comment in case any other people are having similar issues with the new Thanks for everything! JD |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Thanks for the interest! ☕ Now that Uvicorn supports managing workers with Because of that, I deprecated this Docker image: https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker#-warning-you-probably-dont-need-this-docker-image |
Beta Was this translation helpful? Give feedback.
Thanks for the interest! ☕
Now that Uvicorn supports managing workers with
--workers
, including restarting dead ones, there's no need for Gunicorn. That also means that it's much simpler to build a Docker image from scratch now, I updated the docs to explain it.Because of that, I deprecated this Docker image: https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker#-warning-you-probably-dont-need-this-docker-image