FROM debian:stretch as builder

RUN apt-get update &&\
    apt-get install -y gcc g++ cmake libssl-dev libjsoncpp-dev libmilter-dev wget unzip &&\
    apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN wget https://git.rthoni.com/robin.thoni/milter-sasl/archive/v1.0.0.zip -O milter-sasl.zip &&\
    unzip milter-sasl.zip &&\
    cd milter-sasl &&\
    mkdir build && cd build &&\
    cmake .. && make

FROM debian:stretch

ADD https://raw.githubusercontent.com/docker-gcf/docker-gcf/v1.5.0/setup.sh /tmp/docker-utils-setup.sh
RUN sh /tmp/docker-utils-setup.sh
ENTRYPOINT ["gcf-entrypoint"]
CMD ["milter-sasl"]

RUN pkgs-install libjsoncpp1 libmilter1.0.1

COPY --from=builder /milter-sasl/build/src/milter-sasl /usr/local/bin/

COPY ./config /etc/salt/base/
