From 6705e065418fb149cd3eca5a665caf89b2e7ee74 Mon Sep 17 00:00:00 2001 From: vincent Date: Sun, 1 Oct 2023 19:30:23 +0200 Subject: [PATCH] create docker-mailserver job --- nomad-job/dockermailserver.nomad | 161 +++++++++++++++++++++++++++++++ nomad-job/traefik-ingress.nomad | 23 ++++- nomad-job/traefik-local.nomad | 20 +++- 3 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 nomad-job/dockermailserver.nomad diff --git a/nomad-job/dockermailserver.nomad b/nomad-job/dockermailserver.nomad new file mode 100644 index 0000000..c45ae72 --- /dev/null +++ b/nomad-job/dockermailserver.nomad @@ -0,0 +1,161 @@ +job "dockermailserver" { + datacenters = ["hetzner"] + priority = 90 + type = "service" + meta { + forcedeploy = "0" + } + constraint { + attribute = "${attr.cpu.arch}" + value = "amd64" + } + + group "dockermailserver" { + network { + mode = "host" + port "smtp" { + to = 25 + } + port "imap" { + to = 10993 + } + port "esmtp" { + to = 465 + } + } + service { + name = "smtp" + port = "smtp" + tags = [ + "traefik.enable=true", + "traefik.tcp.routers.smtp.service=smtp", + "traefik.tcp.routers.smtp.entrypoints=smtp", + "traefik.tcp.routers.smtp.rule=HostSNI(`*`)", + "traefik.tcp.routers.smtp.tls.passthrough=true", + "traefik.tcp.routers.smtp.tls=false", + "traefik.tcp.services.smtp.loadbalancer.proxyProtocol.version=1", + ] + check { + name = "smtp_probe" + type = "tcp" + interval = "20s" + timeout = "2s" + } + } + service { + name = "esmtp" + port = "esmtp" + tags = [ + "traefik.enable=true", + "traefik.tcp.routers.esmtp.service=esmtp", + "traefik.tcp.routers.esmtp.entrypoints=esmtp", + "traefik.tcp.routers.esmtp.rule=HostSNI(`*`)", + "traefik.tcp.routers.esmtp.tls.passthrough=true", + "traefik.tcp.services.esmtp.loadbalancer.proxyProtocol.version=1", + ] + check { + name = "esmtp_probe" + type = "tcp" + interval = "20s" + timeout = "2s" + } + } + service { + name = "imap" + port = "imap" + tags = [ + "traefik.enable=true", + "traefik.tcp.routers.imap.service=imap", + "traefik.tcp.routers.imap.entrypoints=imap", + "traefik.tcp.routers.imap.rule=HostSNI(`*`)", + "traefik.tcp.routers.imap.tls.passthrough=true", + "traefik.tcp.services.imap.loadbalancer.proxyProtocol.version=2", + ] + check { + name = "imap_probe" + type = "tcp" + interval = "20s" + timeout = "2s" + } + } + service { + name = "certmail" + tags =[ + "traefik.enable=true", + "traefik.http.routers.certmail.tls.domains[0].sans=mail.ducamps.eu", + "traefik.http.routers.certmail.tls.certresolver=myresolver", + ] + } + + # vault{ + # policies= ["policy_name"] + # + #} + task "server" { + driver = "docker" + config { + image = "ghcr.io/docker-mailserver/docker-mailserver:edge" + ports = ["smtp", "esmtp", "imap"] + volumes = [ + "/mnt/diskstation/nomad/dms/mail-data:/var/mail", + "/mnt/diskstation/nomad/dms/mail-state:/var/mail-state", + "/mnt/diskstation/nomad/dms/mail-logs:/var/log/mail", + "/mnt/diskstation/nomad/dms/config:/tmp/docker-mailserver", + "/etc/localtime:/etc/localtime", + "local/postfix-main.cf:/tmp/docker-mailserver/postfix-main.cf", + "local/postfix-master.cf:/tmp/docker-mailserver/postfix-master.cf", + "local/dovecot.cf:/tmp/docker-mailserver/dovecot.cf", + "/mnt/diskstation/nomad/traefik/acme.json:/etc/letsencrypt/acme.json" + ] + } + + env { + OVERRIDE_HOSTNAME = "mail.ducamps.eu" + DMS_VMAIL_UID = 1000000 + DMS_VMAIL_GID = 100 + SSL_TYPE= "letsencrypt" + SSL_DOMAIN= "mail.ducamps.eu" + LOG_LEVEL="debug" + } + template { + data = <