docker fixes

This commit is contained in:
Alexander Karpov 2023-08-26 09:59:56 +03:00
parent aa82f1d956
commit e5a259f551
2 changed files with 13 additions and 23 deletions

View File

@ -3,19 +3,6 @@ ARG PYTHON_VERSION=3.11-slim
# define an alias for the specfic python version used in this file. # define an alias for the specfic python version used in this file.
FROM python:${PYTHON_VERSION} as python 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 # Python 'run' stage
FROM python as python-run-stage FROM python as python-run-stage
@ -25,28 +12,28 @@ ARG APP_HOME=/app
ENV PYTHONUNBUFFERED 1 ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONDONTWRITEBYTECODE 1
ENV BUILD_ENV ${BUILD_ENVIRONMENT} ENV BUILD_ENV ${BUILD_ENVIRONMENT}
ENV POETRY_VERSION 1.4.2
WORKDIR ${APP_HOME} WORKDIR ${APP_HOME}
# Install required system dependencies # Install required system dependencies
RUN apt-get update && apt-get install --no-install-recommends -y \ RUN apt-get update && apt-get install --no-install-recommends -y \
# psycopg2 dependencies # psycopg2 dependencies
libpq-dev \ libpq-dev build-essential \
# Translations dependencies # Translations dependencies
gettext \ gettext \
# cleaning up unused files # cleaning up unused files
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
RUN pip install poetry RUN pip install "poetry==$POETRY_VERSION"
RUN python -m venv /venv
# Configuring poetry COPY pyproject.toml poetry.lock /app/
RUN poetry config virtualenvs.create false RUN poetry export -f requirements.txt | /venv/bin/pip install -r /dev/stdin
COPY pyproject.toml poetry.lock /
# Installing requirements
RUN poetry install
COPY . .
RUN poetry build && /venv/bin/pip install dist/*.whl
COPY ./compose/production/django/entrypoint /entrypoint COPY ./compose/production/django/entrypoint /entrypoint
RUN sed -i 's/\r$//g' /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 sed -i 's/\r$//g' /start-flower
RUN chmod +x /start-flower RUN chmod +x /start-flower
# copy application code to WORKDIR # copy application code to WORKDIR
COPY . ${APP_HOME} COPY . ${APP_HOME}

View File

@ -1,9 +1,11 @@
#!/bin/bash #!/bin/sh
set -e
set -o errexit set -o errexit
set -o pipefail
set -o nounset set -o nounset
. /venv/bin/activate
# N.B. If only .env files supported variable expansion... # N.B. If only .env files supported variable expansion...