FROM python:3.9-alpine
ENV PYTHONUNBUFFERED 1
WORKDIR /app
COPY . ./

ENV POETRY_VERSION=1.1.4

# Rust and shit https://cryptography.io/en/latest/installation.html
RUN apk --no-cache --update --upgrade add gcc musl-dev python3-dev libffi-dev openssl-dev cargo \
  # Pillow and maybe some unnneeded?
  jpeg-dev zlib-dev build-base linux-headers pcre-dev bash \
  # PSQL
  && apk add --no-cache postgresql-dev

# System deps:
RUN pip install -U pip
RUN pip install "poetry==$POETRY_VERSION"

# Project initialization:
RUN poetry config virtualenvs.create false \
  && poetry install --no-dev --no-interaction --no-ansi

RUN python manage.py collectstatic --noinput

CMD ["sh", "-c", "./production_entrypoint.sh"]
