# set base image (host OS)
FROM python:3.8

# https://stackoverflow.com/a/54763270/1106893
# ENV yarndevtools_env="production"
ENV yarndevtools_env="test"

ENV PYTHONFAULTHANDLER=1 \
  PYTHONUNBUFFERED=1 \
  PYTHONHASHSEED=random \
  PIP_NO_CACHE_DIR=off \
  PIP_DISABLE_PIP_VERSION_CHECK=on \
  PIP_DEFAULT_TIMEOUT=100 \
  POETRY_VERSION=1.2.1

RUN pip install "poetry==$POETRY_VERSION"
WORKDIR /home/cdsw
COPY ../../poetry.lock ../../pyproject.toml ./

# Project initialization
RUN poetry install $(test "$yarndevtools_env" == production && echo "--no-dev") --no-interaction --no-ansi


RUN mkdir job_configs
RUN mkdir scripts
COPY job_configs job_configs/
COPY scripts/install-requirements.sh install-requirements.sh
COPY scripts/clone_downstream_repos.sh scripts/clone_downstream_repos.sh
COPY scripts/clone_upstream_repos.sh scripts/clone-upstream_repos.sh
COPY start_job.py scripts/start_job.py
RUN pip install -r requirements.txt
RUN apt-get update && apt-get install -y --no-install-recommends \
        rsync

CMD [ "python", "./branch-comparator/cdswsetup.py" ]
