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 packages
# WORKDIR /var/monitoring
# RUN python3 -m pip install --upgrade pip setuptools wheel pip-tools
# 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/. .
# COPY common/logger.py .

# # set listen port
# ENV PORT=7070
# EXPOSE 7070

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

# 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

# set listen port
ENV PORT=7070
EXPOSE 7070

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