# FROM registry.yandex.net/rtc-base/focal:stable AS base
FROM debian:buster-slim AS base
COPY ./YandexInternalRootCA.crt /usr/local/share/ca-certificates/YandexInternalRootCA.crt
RUN apt-get update && \
    apt-get install --no-install-suggests --no-install-recommends --yes python3

FROM base AS build
RUN apt-get update && \
    apt-get install --no-install-suggests --no-install-recommends --yes python3-venv && \
    python3 -m venv /venv && \
    /venv/bin/pip install --upgrade pip

# Build the virtualenv as a separate step: Only re-execute this step when requirements.txt changes
FROM build AS build-venv
COPY ./requirements.txt /requirements.txt
RUN /venv/bin/pip install --disable-pip-version-check -i https://pypi.yandex-team.ru/simple/ -r /requirements.txt

# Copy the virtualenv into a distroless image
FROM base
# FROM registry.yandex.net/security/base/distroless-python3
COPY --from=build-venv /venv /venv
COPY ./app /app

WORKDIR /app

ENTRYPOINT ["/venv/bin/python3", "-m", "gunicorn.app.wsgiapp", "--bind", "[::]:80", "app:flaskapp"]
