ARG OS_TAG=18.04
FROM ubuntu:${OS_TAG} as builder

ARG OS_TAG
ARG BUILD_TYPE=release
ARG DEBIAN_FRONTEND=noninteractive

MAINTAINER Brenden Blanco <bblanco@gmail.com>

RUN apt-get -qq update && \
    apt-get -y install pbuilder aptitude

COPY ./ /root/bcc

WORKDIR /root/bcc

RUN /usr/lib/pbuilder/pbuilder-satisfydepends && \
    ./scripts/build-deb.sh ${BUILD_TYPE}

FROM ubuntu:${OS_TAG}

COPY --from=builder /root/bcc/*.deb /root/bcc/

RUN \
  apt-get update -y && \
  DEBIAN_FRONTEND=noninteractive apt-get install -y python python3 python3-pip binutils libelf1 kmod  && \
  if [ ${OS_TAG} = "18.04" ];then \
    apt-get -y install python-pip && \
    pip install dnslib cachetools ; \
  fi ; \
  pip3 install dnslib cachetools  && \
  dpkg -i /root/bcc/*.deb