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
