From b8f64167aeb93156eb6e066415116a3ce01ac0f9 Mon Sep 17 00:00:00 2001 From: Hassan Abouelela Date: Sat, 17 Sep 2022 23:22:20 +0400 Subject: Fix Poetry 1.2 Support Poetry 1.2 introduced a regression which broke pip `--user` installs. These types of install where the main way we did installations in docker and CI, which made it much more convenient to control their location, availability, and caching. Poetry's team does not recognize this as a supported use case, so major changes were required to get everything working again. Most of the changes were consolidated into chrislovering/python-poetry-base for docker, and hassanabouelela/setup-python for CI. Signed-off-by: Hassan Abouelela --- Dockerfile | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'Dockerfile') diff --git a/Dockerfile b/Dockerfile index 2b039fab..1d50e11d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,14 @@ -FROM --platform=linux/amd64 python:3.9-slim-buster +FROM ghcr.io/chrislovering/python-poetry-base:3.9-slim # Allow service to handle stops gracefully STOPSIGNAL SIGQUIT -# Set pip to have cleaner logs and no saved cache -ENV PIP_NO_CACHE_DIR=false \ - POETRY_VIRTUALENVS_CREATE=false - -# Install poetry -RUN pip install -U poetry - # Copy the project files into working directory WORKDIR /app # Install project dependencies COPY pyproject.toml poetry.lock ./ -RUN poetry install --no-dev +RUN poetry install --without dev # Set Git SHA environment variable ARG git_sha="development" @@ -34,14 +27,14 @@ RUN \ SECRET_KEY=dummy_value \ DATABASE_URL=postgres://localhost \ METRICITY_DB_URL=postgres://localhost \ - python manage.py collectstatic --noinput --clear + poetry run python manage.py collectstatic --noinput --clear # Build static files if we are doing a static build ARG STATIC_BUILD=false RUN if [ $STATIC_BUILD = "TRUE" ] ; \ - then SECRET_KEY=dummy_value python manage.py distill-local build --traceback --force ; \ + then SECRET_KEY=dummy_value poetry run python manage.py distill-local build --traceback --force ; \ fi # Run web server through custom manager -ENTRYPOINT ["python", "manage.py"] +ENTRYPOINT ["poetry", "run", "python", "manage.py"] CMD ["run"] -- cgit v1.2.3