mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
fix: Don't needlessly invalidate cache layers (#2197)
Recent `sedfile` addition moved all scripts section earlier into the Dockerfile so that `sedfile` could be used within the Dockerfile. However whenever a change is made to scripts which is most of the time for this project, building the Docker image for tests results in all layers after the scripts being invalidated, notably ClamAV, wasting storage of previous instances and increasing build time unnecessarily. This isn't as noticeable of an issue via the CI as we don't leverage any caching at present there, but for iterating on a local branch and testing, it can be quite the drawback. - `sedfile` is handled early in the Dockerfile still, while the scripts have been moved as far down as it made sense to. - `chmod` was split out into it's own RUN command as again it's unnecessary for the rest of it's prior RUN command group to be invalidated.
This commit is contained in:
parent
c851f5b6aa
commit
4db546d300
53
Dockerfile
53
Dockerfile
|
@ -83,16 +83,9 @@ RUN \
|
|||
rm -rf /var/lib/apt/lists/* && \
|
||||
c_rehash 2>&1
|
||||
|
||||
# -----------------------------------------------
|
||||
# --- Scripts -----------------------------------
|
||||
# -----------------------------------------------
|
||||
COPY ./target/bin/sedfile /usr/local/bin/sedfile
|
||||
|
||||
COPY \
|
||||
./target/bin/* \
|
||||
./target/scripts/*.sh \
|
||||
./target/scripts/startup/*.sh \
|
||||
./target/docker-configomat/configomat.sh \
|
||||
/usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/sedfile
|
||||
|
||||
# -----------------------------------------------
|
||||
# --- ClamAV & FeshClam -------------------------
|
||||
|
@ -145,23 +138,6 @@ RUN \
|
|||
sedfile -i -r 's/^(CRON)=0/\1=1/g' /etc/default/spamassassin && \
|
||||
sedfile -i -r 's/^\$INIT restart/supervisorctl restart amavis/g' /etc/spamassassin/sa-update-hooks.d/amavisd-new
|
||||
|
||||
# -----------------------------------------------
|
||||
# --- Miscellaneous -----------------------------
|
||||
# -----------------------------------------------
|
||||
|
||||
COPY \
|
||||
./VERSION /
|
||||
|
||||
RUN \
|
||||
chmod +x /usr/local/bin/* && \
|
||||
rm -rf /usr/share/locale/* && \
|
||||
rm -rf /usr/share/man/* && \
|
||||
rm -rf /usr/share/doc/* && \
|
||||
touch /var/log/auth.log && \
|
||||
update-locale && \
|
||||
rm /etc/postsrsd.secret && \
|
||||
rm /etc/cron.daily/00logwatch
|
||||
|
||||
# -----------------------------------------------
|
||||
# --- PostSRSD, Postgrey & Amavis ---------------
|
||||
# -----------------------------------------------
|
||||
|
@ -178,6 +154,7 @@ RUN \
|
|||
COPY target/amavis/conf.d/* /etc/amavis/conf.d/
|
||||
RUN \
|
||||
sedfile -i -r 's/#(@| \\%)bypass/\1bypass/g' /etc/amavis/conf.d/15-content_filter_mode && \
|
||||
# add users clamav and amavis to each others group
|
||||
adduser clamav amavis && \
|
||||
adduser amavis clamav && \
|
||||
# no syslog user in Debian compared to Ubuntu
|
||||
|
@ -282,6 +259,30 @@ COPY target/logwatch/maillog.conf /etc/logwatch/conf/logfiles/maillog.conf
|
|||
COPY target/supervisor/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
COPY target/supervisor/conf.d/* /etc/supervisor/conf.d/
|
||||
|
||||
# -----------------------------------------------
|
||||
# --- Scripts & Miscellaneous--------------------
|
||||
# -----------------------------------------------
|
||||
|
||||
RUN \
|
||||
rm -rf /usr/share/locale/* && \
|
||||
rm -rf /usr/share/man/* && \
|
||||
rm -rf /usr/share/doc/* && \
|
||||
touch /var/log/auth.log && \
|
||||
update-locale && \
|
||||
rm /etc/postsrsd.secret && \
|
||||
rm /etc/cron.daily/00logwatch
|
||||
|
||||
COPY ./VERSION /
|
||||
|
||||
COPY \
|
||||
./target/bin/* \
|
||||
./target/scripts/*.sh \
|
||||
./target/scripts/startup/*.sh \
|
||||
./target/docker-configomat/configomat.sh \
|
||||
/usr/local/bin/
|
||||
|
||||
RUN chmod +x /usr/local/bin/*
|
||||
|
||||
WORKDIR /
|
||||
|
||||
EXPOSE 25 587 143 465 993 110 995 4190
|
||||
|
|
Loading…
Reference in a new issue