From 49ffd7317bb46c3cce1402f3797263d92acfe22e Mon Sep 17 00:00:00 2001 From: Alexander-D-Karpov Date: Wed, 30 Aug 2023 11:55:35 +0300 Subject: [PATCH] moved poetry install to pip --- compose/local/django/Dockerfile | 16 ++++++++-------- compose/production/django/Dockerfile | 12 ++++++------ compose/production/django/entrypoint | 6 ++++-- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/compose/local/django/Dockerfile b/compose/local/django/Dockerfile index c03255f..d64c840 100644 --- a/compose/local/django/Dockerfile +++ b/compose/local/django/Dockerfile @@ -19,6 +19,7 @@ ENV PYTHONUNBUFFERED 1 ENV DRAWIO_VERSION 15.7.3 ENV PYTHONDONTWRITEBYTECODE 1 ENV BUILD_ENV ${BUILD_ENVIRONMENT} +ENV POETRY_VERSION 1.4.2 WORKDIR ${APP_HOME} @@ -30,16 +31,15 @@ RUN apt-get update && \ apt-get purge -y --auto-remove -o APT:AutoRemove:RecommendsImportant=false && \ rm -rf /var/lib/apt/lists/* -RUN curl -sSL https://install.python-poetry.org | python3 - -# Dependencies for file preview generation -# RUN curl -LO https://github.com/jgraph/drawio-desktop/releases/download/v${DRAWIO_VERSION}/drawio-x86_64-${DRAWIO_VERSION}.AppImage && mv drawio-x86_64-${DRAWIO_VERSION}.AppImage /usr/local/bin/drawio -ENV PATH="/root/.local/bin:$PATH" +RUN pip install "poetry==$POETRY_VERSION" +RUN python -m venv /venv -RUN poetry config virtualenvs.create false +COPY pyproject.toml poetry.lock /app/ +RUN poetry export -f requirements.txt | /venv/bin/pip install -r /dev/stdin + +COPY . . +RUN poetry build && /venv/bin/pip install dist/*.whl -COPY ./pyproject.toml ./poetry.lock /app/ -RUN poetry install --no-root --only main -RUN preview --check-dependencies COPY ./compose/production/django/entrypoint /entrypoint RUN sed -i 's/\r$//g' /entrypoint diff --git a/compose/production/django/Dockerfile b/compose/production/django/Dockerfile index 6ef8c04..f78675a 100644 --- a/compose/production/django/Dockerfile +++ b/compose/production/django/Dockerfile @@ -44,14 +44,14 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ && rm -rf /var/lib/apt/lists/* -RUN pip install poetry +RUN pip install "poetry==$POETRY_VERSION" +RUN python -m venv /venv -# Configuring poetry -RUN poetry config virtualenvs.create false -COPY pyproject.toml poetry.lock / +COPY pyproject.toml poetry.lock /app/ +RUN poetry export -f requirements.txt | /venv/bin/pip install -r /dev/stdin -# Installing requirements -RUN poetry install +COPY . . +RUN poetry build && /venv/bin/pip install dist/*.whl COPY --chown=django:django ./compose/production/django/entrypoint /entrypoint RUN sed -i 's/\r$//g' /entrypoint diff --git a/compose/production/django/entrypoint b/compose/production/django/entrypoint index 78c520b..9d55da1 100644 --- a/compose/production/django/entrypoint +++ b/compose/production/django/entrypoint @@ -1,9 +1,11 @@ -#!/bin/bash +#!/bin/sh +set -e set -o errexit -set -o pipefail set -o nounset +. /venv/bin/activate + # N.B. If only .env files supported variable expansion...