Ensemble des services de KAZ
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

114 lines
5.2 KiB

# tow stage building
# 1) install compiler and compile filter
# 2) copy filter and install postfix
# Doxkerfile patern from https://vsupalov.com/cache-docker-build-dependencies-without-volume-mounting/
FROM docker.io/mailserver/docker-mailserver:11.3.1 as intermediate_postfix
########################################
# APT local cache
# work around because COPY failed if no source file
COPY .dummy .apt-mirror-confi[g] .proxy-confi[g] /
RUN cp /.proxy-config /etc/profile.d/proxy.sh 2> /dev/null || true
RUN if [ -f /.apt-mirror-config ] ; then . /.apt-mirror-config && sed -i \
-e "s/deb.debian.org/${APT_MIRROR_DEBIAN}/g" \
-e "s/security.debian.org/${APT_MIRROR_DEBIAN_SECURITY}/g" \
-e "s/archive.ubuntu.com/${APT_MIRROR_UBUNTU}/g" \
-e "s/security.ubuntu.com/${APT_MIRROR_UBUNTU_SECURITY}/g" \
/etc/apt/sources.list; fi
########################################
RUN apt-get update
RUN apt-get -y autoremove
RUN apt-get install -y locales locales-all
RUN sed -i '/fr_FR.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
ENV LC_ALL fr_FR.UTF-8
ENV LANG fr_FR.UTF-8
ENV LANGUAGE fr_FR:fr
RUN update-locale LANG=fr_FR.UTF-8
RUN apt-get -y install rsyslog apt-utils apg gawk altermime
RUN apt-get -y install libboost-program-options-dev libboost-system-dev libboost-filesystem-dev libcurl4-gnutls-dev
#RUN apt-get -y install emacs elpa-php-mode
RUN apt-get -y install vim nano mailutils bsd-mailx procps dos2unix
# creation du user filter,son repertoire home, copie des fichiers
RUN mkdir /home/filter ; useradd -d /home/filter filter ; chown filter /home/filter
########## >>> ce qui suit va être jetté
RUN apt-get install -y --fix-missing doxygen dos2unix git \
build-essential make g++ libboost-program-options-dev libboost-system-dev libboost-filesystem-dev libcurl4-gnutls-dev libssl-dev
WORKDIR /home/
RUN git clone https://git.kaz.bzh/KAZ/depollueur.git
WORKDIR /home/depollueur/
RUN make
########## <<< on ne garde que le répertoire ci-dessous
RUN cp build/out/* /home/filter/
RUN cp src/bash/* /home/filter/
##########################################################################
# ###################################################################### #
# # # #
# # On jette tous ce qui est au-dessus pour ne garder que /home/filter # #
# # # #
# ###################################################################### #
##########################################################################
FROM docker.io/mailserver/docker-mailserver:11.3.1
########################################
# APT local cache
# work around because COPY failed if no source file
COPY .dummy .apt-mirror-confi[g] .proxy-confi[g] /
RUN cp /.proxy-config /etc/profile.d/proxy.sh 2> /dev/null || true
RUN if [ -f /.apt-mirror-config ] ; then . /.apt-mirror-config && sed -i \
-e "s/deb.debian.org/${APT_MIRROR_DEBIAN}/g" \
-e "s/security.debian.org/${APT_MIRROR_DEBIAN_SECURITY}/g" \
-e "s/archive.ubuntu.com/${APT_MIRROR_UBUNTU}/g" \
-e "s/security.ubuntu.com/${APT_MIRROR_UBUNTU_SECURITY}/g" \
/etc/apt/sources.list; fi
########################################
RUN apt-get update
RUN apt-get -y autoremove
RUN apt-get install -y locales locales-all
RUN sed -i '/fr_FR.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
ENV LC_ALL fr_FR.UTF-8
ENV LANG fr_FR.UTF-8
ENV LANGUAGE fr_FR:fr
RUN update-locale LANG=fr_FR.UTF-8
RUN apt-get -y install rsyslog apt-utils apg gawk altermime
RUN apt-get -y install libboost-program-options-dev libboost-system-dev libboost-filesystem-dev libcurl4-gnutls-dev
#RUN apt-get -y install emacs elpa-php-mode
RUN apt-get -y install vim nano mailutils bsd-mailx procps dos2unix
# creation du user filter,son repertoire home, copie des fichiers
RUN mkdir /home/filter ; useradd -d /home/filter filter ; chown filter /home/filter
########## >>> On fait excatement la même chose que la première fois *
########## pour profiter du cahe des couche de docker
COPY --from=intermediate_postfix /home/filter /home/filter
########## <<< mais cette fois on n'installe pas le compilo
RUN chown filter /home/filter/*; chmod 755 /home/filter/*
# creation du repertoire filter et application des bons droits pour le filtre
RUN mkdir -p /var/log/mail; touch /var/log/mail/filter.log ; chown filter /var/log/mail/filter.log ; chmod 777 /var/log/mail/filter.log
RUN mkdir -p /var/spool/filter ; chmod 775 /var/spool/filter ; chown filter /var/spool/filter
RUN mkdir -p /var/log/mail/pb ; chmod a+rwx /var/log/mail/pb
RUN sed -i '5i/var/log/mail/filter.log' /etc/logrotate.d/rsyslog
# modif des fichiers de postfix
RUN cp /home/filter/master.cf.update /etc/postfix/master.cf
RUN sed -i -e 's/reject_rbl_client bl.spamcop.net$//g' /etc/postfix/main.cf
RUN awk -i inplace 'BEGIN {cp=0} /127.0.0.1:10025/ {cp=1} /content_filter=/ {if (cp) gsub("content_filter=.*", "content_filter=filter:dummy"); print $0; cp=0; next} {print}' /etc/postfix/master.cf
# pour le confort : modif du .bashrc de root
RUN sed -i 's/# alias/alias/g' /root/.bashrc
RUN /etc/init.d/postfix restart
RUN echo "#!/bin/bash" > /entrypoint.sh
RUN echo "/usr/bin/supervisord -c /etc/supervisor/supervisord.conf" >> /entrypoint.sh
RUN chmod u+x /entrypoint.sh
# HOTFIX DMARC
RUN chmod 777 /var/run/opendmarc/
ENTRYPOINT ["/entrypoint.sh"]