Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Poetry Installation Documentation for Dockerfile examples #86

Closed
joeld1 opened this issue Apr 28, 2021 · 1 comment
Closed

Update Poetry Installation Documentation for Dockerfile examples #86

joeld1 opened this issue Apr 28, 2021 · 1 comment

Comments

@joeld1
Copy link

joeld1 commented Apr 28, 2021

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:

curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -

to

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

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:

  • If installing using get-poetry.py, we have the following folder /opt/poetry/env
  • If using install-poetry.py, we have /opt/poetry/venv
  • The difference between these two is env vs venv, which causes poetry install to improperly install

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 install-poetry.py method. This issue is also raised here, but in poetry's channel

Thanks for everything!

JD

@tiangolo
Copy link
Owner

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

Repository owner locked and limited conversation to collaborators Aug 25, 2024
@tiangolo tiangolo converted this issue into discussion #319 Aug 25, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

2 participants