FROM buildpack-deps:xenial

RUN apt update -yqq && apt install -yqq software-properties-common unzip cmake

RUN apt install -yqq g++-4.8 libjson0-dev
RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50

ENV POCO_VERSION 1.6.1
ENV POCO_HOME /poco

WORKDIR ${POCO_HOME}
RUN curl -sL http://pocoproject.org/releases/poco-${POCO_VERSION}/poco-${POCO_VERSION}-all.tar.gz | tar xz --strip-components=1

RUN ./configure --no-tests --no-samples
RUN make --quiet PageCompiler-libexec XML-libexec JSON-libexec

ENV LD_LIBRARY_PATH ${POCO_HOME}/lib/Linux/x86_64

COPY benchmark.cpp benchmark.cpp

RUN g++-4.8 \
    -O3 \
    -DNDEBUG \
    -std=c++0x \
    -o \
    poco \
    benchmark.cpp \
    -I${POCO_HOME}/Foundation/include \
    -I${POCO_HOME}/Util/include \
    -I${POCO_HOME}/Net/include \
    -L${POCO_HOME}/lib/Linux/x86_64 \
    -lPocoNet \
    -lPocoUtil \
    -lPocoFoundation \
    -lPocoXML \
    -lPocoJSON

CMD ./poco 8080 $(nproc)
