FROM node:10-slim
RUN npm i -g npm
RUN apt update && apt -y install git python make g++ libcap2-bin wget dirmngr sudo && apt clean
RUN wget -O- https://rspamd.com/apt-stable/gpg.key | apt-key add -
RUN echo "deb [arch=amd64] http://rspamd.com/apt-stable/ stretch main" > /etc/apt/sources.list.d/rspamd.list
RUN echo "deb-src [arch=amd64] http://rspamd.com/apt-stable/ stretch main" >> /etc/apt/sources.list.d/rspamd.list
RUN apt update
RUN apt --no-install-recommends install -y rspamd
RUN setcap 'cap_net_bind_service=+ep' /usr/local/bin/node
RUN git clone https://github.com/nodemailer/wildduck /wildduck
RUN git clone https://github.com/zone-eu/zone-mta-template /wildduck-mta
RUN git clone https://github.com/haraka/Haraka /haraka
RUN chown -R node.node /wildduck /wildduck-mta /haraka
RUN adduser node sudo
RUN echo "%sudo ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/sudo
USER node
WORKDIR /wildduck
RUN npm i --production
WORKDIR /wildduck-mta
RUN npm i --production
RUN npm i -S zonemta-wildduck zonemta-limiter
WORKDIR /haraka
RUN npm i
RUN npm i -S haraka-plugin-wildduck haraka-plugin-rspamd haraka-plugin-limit haraka-plugin-karma haraka-plugin-redis
