mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
docker: Reduce Docker image layers
This patch halves the Docker image layers by following the best practice of grouping some of the related commands together. https://github.com/albertito/chasquid/pull/68 Amended-by: Alberto Bertogli <albertito@blitiri.com.ar> Adjusted commit message, adjust comment location.
This commit is contained in:
committed by
Alberto Bertogli
parent
3ff26fa145
commit
68ba0d2600
@@ -11,8 +11,8 @@
|
|||||||
FROM golang:latest AS build
|
FROM golang:latest AS build
|
||||||
WORKDIR /go/src/blitiri.com.ar/go/chasquid
|
WORKDIR /go/src/blitiri.com.ar/go/chasquid
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN go get -d ./...
|
RUN go get -d ./... && \
|
||||||
RUN go install ./...
|
go install ./...
|
||||||
|
|
||||||
# Create the image.
|
# Create the image.
|
||||||
FROM debian:stable
|
FROM debian:stable
|
||||||
@@ -23,19 +23,16 @@ ENV DEBIAN_FRONTEND=noninteractive
|
|||||||
|
|
||||||
# Install the packages we need.
|
# Install the packages we need.
|
||||||
# This includes chasquid, which sets up good defaults.
|
# This includes chasquid, which sets up good defaults.
|
||||||
RUN apt-get update -q
|
RUN apt-get update -q && \
|
||||||
RUN apt-get install -y -q \
|
apt-get install -y -q \
|
||||||
chasquid \
|
chasquid \
|
||||||
dovecot-lmtpd dovecot-imapd dovecot-pop3d \
|
dovecot-lmtpd dovecot-imapd dovecot-pop3d \
|
||||||
dovecot-sieve dovecot-managesieved \
|
dovecot-sieve dovecot-managesieved \
|
||||||
acl libcap2-bin sudo certbot
|
acl libcap2-bin sudo certbot
|
||||||
|
|
||||||
# Copy the binaries. This overrides the debian packages with the ones we just
|
# Copy the binaries. This overrides the debian packages with the ones we just
|
||||||
# built above.
|
# built above.
|
||||||
COPY --from=build /go/bin/chasquid /usr/bin/
|
COPY --from=build /go/bin/chasquid /go/bin/chasquid-util /go/bin/smtp-check /go/bin/mda-lmtp /usr/bin/
|
||||||
COPY --from=build /go/bin/chasquid-util /usr/bin/
|
|
||||||
COPY --from=build /go/bin/smtp-check /usr/bin/
|
|
||||||
COPY --from=build /go/bin/mda-lmtp /usr/bin/
|
|
||||||
|
|
||||||
# Let chasquid bind privileged ports, so we can run it as its own user.
|
# Let chasquid bind privileged ports, so we can run it as its own user.
|
||||||
RUN setcap CAP_NET_BIND_SERVICE=+eip /usr/bin/chasquid
|
RUN setcap CAP_NET_BIND_SERVICE=+eip /usr/bin/chasquid
|
||||||
@@ -45,8 +42,7 @@ COPY docker/dovecot.conf /etc/dovecot/dovecot.conf
|
|||||||
COPY docker/chasquid.conf /etc/chasquid/chasquid.conf
|
COPY docker/chasquid.conf /etc/chasquid/chasquid.conf
|
||||||
|
|
||||||
# Copy utility scripts.
|
# Copy utility scripts.
|
||||||
COPY docker/add-user.sh /
|
COPY docker/add-user.sh docker/entrypoint.sh /
|
||||||
COPY docker/entrypoint.sh /
|
|
||||||
|
|
||||||
# chasquid: SMTP, submission, submission+tls.
|
# chasquid: SMTP, submission, submission+tls.
|
||||||
EXPOSE 25 465 587
|
EXPOSE 25 465 587
|
||||||
@@ -62,15 +58,14 @@ EXPOSE 80 443
|
|||||||
VOLUME /data
|
VOLUME /data
|
||||||
|
|
||||||
# Put some directories where we expect persistent user data into /data.
|
# Put some directories where we expect persistent user data into /data.
|
||||||
RUN rmdir /etc/chasquid/domains/
|
|
||||||
RUN ln -sf /data/chasquid/domains/ /etc/chasquid/domains
|
|
||||||
RUN rm -rf /etc/letsencrypt/
|
|
||||||
RUN ln -sf /data/letsencrypt/ /etc/letsencrypt
|
|
||||||
|
|
||||||
# Give the chasquid user access to the necessary configuration.
|
# Give the chasquid user access to the necessary configuration.
|
||||||
RUN setfacl -R -m u:chasquid:rX /etc/chasquid/
|
RUN rmdir /etc/chasquid/domains/ && \
|
||||||
RUN mv /etc/chasquid/certs/ /etc/chasquid/certs-orig
|
ln -sf /data/chasquid/domains/ /etc/chasquid/domains && \
|
||||||
RUN ln -s /etc/letsencrypt/live/ /etc/chasquid/certs
|
rm -rf /etc/letsencrypt/ && \
|
||||||
|
ln -sf /data/letsencrypt/ /etc/letsencrypt && \
|
||||||
|
setfacl -R -m u:chasquid:rX /etc/chasquid/ && \
|
||||||
|
mv /etc/chasquid/certs/ /etc/chasquid/certs-orig && \
|
||||||
|
ln -s /etc/letsencrypt/live/ /etc/chasquid/certs
|
||||||
|
|
||||||
|
|
||||||
# NOTE: Set AUTO_CERTS="example.com example.org" to automatically obtain and
|
# NOTE: Set AUTO_CERTS="example.com example.org" to automatically obtain and
|
||||||
|
|||||||
Reference in New Issue
Block a user