FROM registry.yandex.net/tools/raw-ubuntu:20.04
ARG MODE=release
ENV REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
RUN locale-gen ru_RU.UTF-8 && update-locale LANG=ru_RU.UTF-8

EXPOSE 80

ADD https://crls.yandex.net/allCAs.pem /etc/
RUN chown www-data:www-data /etc/allCAs.pem

RUN apt-get update -qq \
    && apt-get install -y postgresql-client-12 iproute2 pip \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

COPY /requirements.txt /
RUN pip3 install --disable-pip-version-check -i https://pypi.yandex-team.ru/simple/ -r /requirements.txt

COPY /requirements-dev.txt /
RUN if [ "$MODE" = "dev" ]; then \
        pip3 install --disable-pip-version-check -i https://pypi.yandex-team.ru/simple/ -r /requirements-dev.txt; \
    fi


COPY alembic.ini /
COPY hypercorn_conf.py /

COPY src /src
COPY migrations /migrations

CMD hypercorn --config=file:/hypercorn_conf.py src.main_webapp:app
