FROM registry.yandex.net/tools/raw-ubuntu:20.04

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 \
    && apt-get install -y postgresql-client-12 iproute2

COPY alembic.ini /
COPY hypercorn_conf.py /

COPY /trip/src/asgi/trip.asgi /trip
COPY /trip/src/arq/trip.arq /arq
COPY /trip/alembic/trip.alembic /trip-db

COPY /entrypoints/shell.sh /usr/local/bin/shell
COPY /entrypoints/dbshell.sh /usr/local/bin/dbshell
COPY /deploy/init.sh /

RUN chmod +x /usr/local/bin/shell
RUN chmod +x /usr/local/bin/dbshell

CMD if [ "$MODE" = "worker" ]; then \
        /arq intranet.trip.src.worker.settings.WorkerSettings; \
    else \
        /trip --config=file:/hypercorn_conf.py intranet.trip.src.main:app; \
    fi

RUN mkdir /ipython_profile
COPY ipython_config.py  /ipython_profile/ipython_config.py
