FROM python:3-slim

RUN apt-get --yes --quiet --quiet update && \
    apt-get --yes --quiet --quiet install wget g++ && \
    rm -rf /var/lib/apt/lists/*

# show python logs as they occur
ENV PYTHONUNBUFFERED=0

# download the grpc health probe
RUN GRPC_HEALTH_PROBE_VERSION=v0.2.0 && \
    wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
    chmod +x /bin/grpc_health_probe

# Get generic Python packages
RUN python3 -m pip install --upgrade pip setuptools wheel pip-tools

# Set working directory
WORKDIR /var/teraflow

# Create module sub-folders
RUN mkdir -p /var/teraflow/monitoring
RUN mkdir -p /var/teraflow/common

# Get Python packages per module
COPY monitoring/requirements.in requirements.in
RUN pip-compile --output-file=requirements.txt requirements.in
RUN python3 -m pip install -r requirements.txt

# add files into working directory
COPY monitoring/. monitoring
COPY common/logger.py common

# define variables for the influxdb
# ARG user
# ARG pass
# ARG db
# ARG hostname
# ENV INFLUXDB_HOSTNAME=$hostname
# ENV INFLUXDB_USER=$user
# ENV INFLUXDB_PASSWORD=$pass
# ENV INFLUXDB_DATABASE=$db

# set listen port
ENV PORT=7070
EXPOSE 7070

#RUN pytest --junitxml=report.xml
ENTRYPOINT ["pytest", "--junitxml=/opt/results/report.xml"]