Commit 36ca9436 authored by nimrod's avatar nimrod
Browse files

Accumulation of work.

Basically, just what I did since the last commit. Includes the Exim4
SMTP server.
parent 5064da85
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ repos:
    rev: v2.3.0
    hooks:
      - id: check-added-large-files
      - id: check-executables-have-shebangs
      - id: check-merge-conflict
      - id: detect-private-key
      - id: trailing-whitespace
@@ -20,17 +19,13 @@ repos:
      - id: proselint
        types: [plain-text]
        exclude: LICENSE
  - repo: https://www.shore.co.il/git/shell-pre-commit/
    rev: v0.6.0
    hooks:
      - id: shell-lint
      - id: shellcheck
  - repo: https://www.shore.co.il/git/docker-pre-commit
    rev: v0.3.0
    hooks:
      - id: hadolint
      - id: docker-compose
      - id: hadolint
  - repo: https://github.com/Yelp/detect-secrets
    rev: v0.13.0
    hooks:
      - id: detect-secrets
        exclude: \.diff$
+1 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ FROM debian:buster-slim
# hadolint ignore=DL3008
RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
        ca-certificates \
        clamav-daemon \
        clamav-freshclam \
        netcat-openbsd \
+61 −8
Original line number Diff line number Diff line
@@ -6,29 +6,43 @@ services:
    build:
      context: dovecot/
    environment:
      LDAP_BASEDN: &ldap_basedn 'dc=nowhere,dc=com'
      LDAP_URIS: &ldap_uris ldap://slapd
      LDAP_BASEDN: &ldap_basedn |-
        ${LDAP_BASE_DN:-ou=People,dc=shore,dc=co,dc=il}
      LDAP_URIS: &ldap_uris '${LDAP_URIS:-ldapi:///}'
      TLS_CERT_FILE: &tls_cert_file /var/ssl/mail.crt
      TLS_KEY_FILE: &tls_key_file /var/ssl/mail.key
    hostname: &imap_hostname imap.shore.co.il
    networks:
      default:
        aliases:
          - *imap_hostname
    ports:
      - 993:993
    restart: always
    volumes:
      - _run_slapd:/run/slapd
      - _run_dovecot:/run/dovecot
      - mail:/var/mail
      - /var/ssl:/var/ssl:ro

  clamd:
    build:
      cache_from:
        - adarnimrod/clamd
      # cache_from:
      #   - adarnimrod/clamd
      context: clamd/
    image: adarnimrod/clamd
    # image: adarnimrod/clamd
    restart: always
    volumes:
      - _run_clamav:/run/clamav
      - spool:/var/spool/exim4

  spamd:
    build:
      cache_from:
        - adarnimrod/spamd
      # cache_from:
      #   - adarnimrod/spamd
      context: spamd/
    image: adarnimrod/spamd
    # image: adarnimrod/spamd
    restart: always
    volumes:
      - _run_spamd:/run/spamd
      - mail:/var/mail:ro
@@ -37,19 +51,58 @@ services:
  crond:
    build:
      context: crond/
    restart: always
    volumes:
      - /run/docker.sock:/run/docker.sock

  smtp:
    build:
      context: exim4/
    environment:
      # CLAMD_ADDRESS: clamd 3310
      LDAP_URIS: *ldap_uris
      LDAP_BASEDN: *ldap_basedn
      # LMTP_ADDRESS: /run/dovecot/lmtp
      DOMAIN: &domain "${DOMAIN:-shore.co.il}"
      MAILNAME: &mailname "${MAILNAME:-smtp}.${DOMAIN:-shore.co.il}"
      ROOT_ALIAS: "${ROOT_ALIAS:-nimrod}"
      # SPAMD_ADDRESS: /run/spamd/spamd.sock
      TLS_CERT_FILE: *tls_cert_file
      TLS_KEY_FILE: *tls_key_file
      DKIM_KEY_FILE: /var/ssl/dkim.key
      DKIM_SELECTOR: host01
    hostname: *mailname
    networks:
      default:
        aliases:
          - *mailname
    ports:
      - '25:25'
      - 587:587
    restart: always
    volumes:
      - _run_slapd:/run/slapd
      - _run_clamav:/run/clamav
      - _run_dovecot:/run/dovecot
      - _run_spamd:/run/spamd
      - spool:/var/spool/exim4
      - /var/ssl:/var/ssl:ro

volumes:
  _run_spamd:
  _run_clamav:
    name: run_clamav
  _run_dovecot:
  mail:
    labels:
      snapshot: 'true'
  spool:
  sa_learn:
    labels:
      snapshot: 'true'
  _run_slapd:
    external: true
    name: run_slapd

networks:
  default:
+2 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ RUN apt-get update && \
        ssl-cert \
        time \
    && \
    install -d -m 777 -o mail -g mail /var/lib/dovecot/sieve.d && \
    rm -rf /tmp/* /var/tmp/* /var/lib/apt/lists/* /var/cache/apt/archives/*
COPY --from=delete_to_trash /dovecot_deleted_to_trash/lib_deleted_to_trash_plugin.so /usr/lib/dovecot/modules/
COPY --from=delete_to_trash /dovecot_deleted_to_trash/95-deleted_to_trash_plugin.conf /etc/dovecot/conf.d/
@@ -32,4 +33,4 @@ VOLUME /run/dovecot
EXPOSE 993 25
ENTRYPOINT [ "/entrypoint" ]
CMD [ "dovecot", "-F" ]
HEALTHCHECK CMD doveadm service status || exit 1
HEALTHCHECK --start-period=5m CMD doveadm service status || exit 1
+3 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ set -eux
install -d -m 755 -o dovecot -g root /var/run/dovecot
install -d -m 775 -o root -g dovecot /var/mail
install -d -m 775 -o root -g dovecot /run/dovecot
time openssl dhparam -out /usr/share/dovecot/dh.pem 4096
time openssl dhparam -out /usr/share/dovecot/dh.pem 2048
DEBIAN_FRONTEND=noninteractive time make-ssl-cert generate-default-snakeoil --force-overwrite

# I don't know why environment variables aren't expanded and I'm too interested
@@ -12,5 +12,7 @@ DEBIAN_FRONTEND=noninteractive time make-ssl-cert generate-default-snakeoil --fo

sed -i "s@%{env:LDAP_URIS}@$LDAP_URIS@g" /etc/dovecot/dovecot-ldap.conf.ext
sed -i "s@%{env:LDAP_BASEDN}@$LDAP_BASEDN@g" /etc/dovecot/dovecot-ldap.conf.ext
sed -i "s@/etc/ssl/private/ssl-cert-snakeoil.key@$TLS_KEY_FILE@g" /etc/dovecot/conf.d/10-ssl.conf
sed -i "s@/etc/ssl/certs/ssl-cert-snakeoil.pem@$TLS_CERT_FILE@g" /etc/dovecot/conf.d/10-ssl.conf

eval exec "$@"
Loading