diff --git a/compose/local/django/Dockerfile b/compose/local/django/Dockerfile index 4d57b7f..e809b97 100644 --- a/compose/local/django/Dockerfile +++ b/compose/local/django/Dockerfile @@ -3,19 +3,6 @@ ARG PYTHON_VERSION=3.11-slim # define an alias for the specfic python version used in this file. FROM python:${PYTHON_VERSION} as python -# Python build stage -FROM python as python-build-stage - -ARG BUILD_ENVIRONMENT=local - -# Install apt packages -RUN apt-get update && apt-get install --no-install-recommends -y \ - # dependencies for building Python packages - build-essential \ - # psycopg2 dependencies - libpq-dev - - # Python 'run' stage FROM python as python-run-stage @@ -25,28 +12,28 @@ ARG APP_HOME=/app ENV PYTHONUNBUFFERED 1 ENV PYTHONDONTWRITEBYTECODE 1 ENV BUILD_ENV ${BUILD_ENVIRONMENT} +ENV POETRY_VERSION 1.4.2 WORKDIR ${APP_HOME} # Install required system dependencies RUN apt-get update && apt-get install --no-install-recommends -y \ # psycopg2 dependencies - libpq-dev \ + libpq-dev build-essential \ # Translations dependencies gettext \ # cleaning up unused files && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ && 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 / - -# Installing requirements -RUN poetry install +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 ./compose/production/django/entrypoint /entrypoint RUN sed -i 's/\r$//g' /entrypoint @@ -73,6 +60,7 @@ COPY ./compose/local/django/celery/flower/start /start-flower RUN sed -i 's/\r$//g' /start-flower RUN chmod +x /start-flower + # copy application code to WORKDIR COPY . ${APP_HOME} diff --git a/compose/production/django/entrypoint b/compose/production/django/entrypoint index 62895e9..fce27b4 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...