smtprelay

This commit is contained in:
Daniel Berteaud 2023-08-24 19:50:26 +02:00
commit 9855500b7b
2 changed files with 70 additions and 0 deletions

View File

@ -0,0 +1,27 @@
FROM golang:alpine AS build
ARG GOARCH="amd64"
ARG SMTPRELAY_VERSION=1.10.0 \
SMTPRELAY_LISTEN=0.0.0.0:25
RUN set -eux &&\
apk --no-cache upgrade &&\
apk --no-cache add git libcap &&\
cd /tmp &&\
git clone --depth 1 --branch v${SMTPRELAY_VERSION} https://github.com/decke/smtprelay.git &&\
cd smtprelay &&\
go build -v -o smtprelay &&\
setcap cap_net_bind_service=+ep ./smtprelay &&\
chmod +x ./smtprelay
FROM danielberteaud/alpine
MAINTAINER Daniel Berteaud <dbd@ehtrace.com>
RUN set -eux &&\
apk --no-cache upgrade &&\
apk --no-cache add tini
COPY --from=build /tmp/smtprelay/smtprelay /usr/local/bin/
ENTRYPOINT ["tini", "--", "/entrypoint.sh"]
CMD ["smtprelay"]

43
smtprelay.nomad.hcl Normal file
View File

@ -0,0 +1,43 @@
job "smtp-relay" {
datacenters = [[ .nomad.datacenters | toJSON ]]
group "smtp-relay" {
network {
mode = "bridge"
}
service {
name = "smtp-relay[[ .env.suffix ]]"
port = 25
connect {
sidecar_service {}
sidecar_task {
[[ template "common/resources.tpl" .mail.relay.resources ]]
}
}
}
task "smtprelay" {
driver = [[ .mail.relay.driver | toJSON ]]
config {
image = [[ .mail.relay.image | toJSON ]]
}
env {
SMTPRELAY_REMOTES = "[[ .mail.relay.remote.protocol ]]://
[[- if and (has .mail.relay.remote "user") (has .mail.relay.remote "password") ]]
[[- .mail.relay.remote.user ]]:[[ urlquery .mail.relay.remote.password ]]@
[[- end ]][[ .mail.relay.remote.host ]]:[[ .mail.relay.remote.port ]]"
[[- if has .mail.relay "allowed_senders" ]]
SMTPRELAY_ALLOWED_SENDER = "[[ .mail.relay.allowed_sender ]]"
[[- end ]]
[[ template "common/env.tpl" .mail.relay.env ]]
}
resources
}
}
}