# Dockerfile for the code-coverage build job
#
ARG BASE_IMAGE
ARG pyspark_base=$BASE_IMAGE

FROM ${pyspark_base} as builder
ARG build_root=/build/nsx-pace/pace/infraclassification

# change user to allow tool install for buidler
USER root

# install build tools in container
RUN apt-get update && apt-get -y install make && \
    apt-get autoremove -y && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# setup build root dir
COPY . ${build_root}

WORKDIR ${build_root}

# install requirements
RUN pip3 install -r requirements.txt

# Protos are built from metrics/protobuf/generate_proto_bindings.sh in the outer makefile, and copied \
# into the build context already by making proto-cache a dep of the outer makefile, so just call test here

# RUN make test -- this will build the proto-cache and then run tests
ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION="python"
ENV FILTER_TO_COMMON_PORTS="true"
ENV PARTITIONS_PER_CORE="2"
ENV K8S_CAPACITY_CHECK_ENABLED="true"
ENV EXECUTOR_INSTANCES="2"
ENV EXECUTOR_CORES="2"

# run the test coverage
CMD make test-coverage-html HTML_REPORT_OUT=/tmp/report
