chore: using poetry

This commit is contained in:
2022-08-30 19:50:21 -03:00
parent c91ee89999
commit 9ecc3acdd0
6 changed files with 900 additions and 86 deletions

View File

@@ -1,12 +1,52 @@
FROM python:3.8
FROM python:3.8-slim-buster
ADD . /app
WORKDIR /app
ARG SCOPE
RUN apt-get update && apt-get install -y \
# Setup env
ENV SCOPE=${SCOPE} \
# python
PYTHONDONTWRITEBYTECODE=1 \
PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
LC_ALL=C.UTF-8 \
LANG=C.UTF-8 \
# pip
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
# poetry:
POETRY_VERSION=1.1.13 \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_CACHE_DIR='/var/cache/pypoetry' \
POETRY_HOME='/usr/local'
SHELL ["/bin/bash", "-eo", "pipefail", "-c"]
RUN apt-get update && apt-get upgrade -y \
&& apt-get install --no-install-recommends -y \
bash \
default-libmysqlclient-dev \
curl \
build-essential \
&& pip install --no-cache-dir -r /app/requirements.txt
default-libmysqlclient-dev \
libpq-dev \
# Installing `poetry` package manager:
# https://github.com/python-poetry/poetry
&& curl -sSL 'https://install.python-poetry.org' | python - \
&& poetry --version \
# Cleaning cache:
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
CMD ["/app/commands/run-prod.sh"]
# Copy only requirements to cache them in docker layer
WORKDIR /code
COPY poetry.lock pyproject.toml /code/
RUN poetry config virtualenvs.create false \
&& poetry install $(test "$SCOPE" == production && echo "--no-dev") --no-interaction --no-ansi
# Creating folders, and files for a project:
COPY . /code
CMD ["/code/commands/run-prod.sh"]