15 Commits

Author SHA1 Message Date
689402c8e9 add scan in ci
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2025-03-27 16:24:23 +01:00
4f9a333219 new alpine base
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2025-03-27 16:13:30 +01:00
f205858c30 alpine approach completed
All checks were successful
ci/woodpecker/tag/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-12-11 11:32:47 +01:00
9f65b7690e alpine approach
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-12-11 10:55:34 +01:00
724e94afb6 reduce debug output
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-12-10 16:46:07 +01:00
fd5d006c33 documentation
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-12-10 16:43:49 +01:00
e8f66cd354 documentation
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-12-10 16:42:35 +01:00
93801d7577 documentation
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-12-10 16:40:17 +01:00
62a301cc58 two destinations
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-12-10 14:32:50 +01:00
ae2a789c3c quay fix
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-12-10 14:30:58 +01:00
1b6adce9dc quay fix
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline failed
2024-12-10 14:29:54 +01:00
4db1560da2 quay fix
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline failed
2024-12-10 14:27:03 +01:00
2d71d0d42c quay fix
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline failed
2024-12-10 14:13:55 +01:00
ab7eb0a3f0 quay fix
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline failed
2024-12-10 14:00:50 +01:00
e9f0a2a898 quay fix
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline failed
2024-12-10 13:58:55 +01:00
9 changed files with 164 additions and 60 deletions

View File

@ -13,12 +13,14 @@ steps:
dockerfile: Dockerfile
when:
- event: [push, tag]
public_build:
build:
image: plugins/kaniko
settings:
repo: wollud1969/exim-docker
repo: quay.io/wollud1969/exim-docker
registry: quay.io
tags: latest,${CI_COMMIT_SHA},${CI_COMMIT_TAG}
tags:
- latest
- ${CI_COMMIT_TAG}
username:
from_secret: quay_username
password:
@ -26,3 +28,38 @@ steps:
dockerfile: Dockerfile
when:
- event: [tag]
scan:
image: quay.io/wollud1969/woodpecker-helper:0.5.1
environment:
TRIVY_TOKEN:
from_secret: trivy_token
TRIVY_URL:
from_secret: trivy_url
DTRACK_API_KEY:
from_secret: dtrack_api_key
DTRACK_API_URL:
from_secret: dtrack_api_url
commands:
- HOME=/home/`id -nu`
- IMAGE=quay.io/wollud1969/exim-docker:$CI_COMMIT_TAG
- |
trivy image \
--server $TRIVY_URL \
--token $TRIVY_TOKEN \
--format cyclonedx \
--scanners license \
--output /tmp/sbom.xml \
$IMAGE
- cat /tmp/sbom.xml
- |
curl -X "POST" \
-H "Content-Type: multipart/form-data" \
-H "X-Api-Key: $DTRACK_API_KEY" \
-F "autoCreate=true" \
-F "projectName=$CI_REPO" \
-F "projectVersion=$CI_COMMIT_TAG" \
-F "bom=@/tmp/sbom.xml"\
"$DTRACK_API_URL/api/v1/bom"
when:
- event: [tag]

View File

@ -1,4 +1,4 @@
FROM debian:bookworm
FROM alpine:3.21.3
LABEL Maintainer="Wolfgang Hottgenroth <woho@hottis.de>"
LABEL ImageName=""
@ -7,23 +7,15 @@ LABEL ImageName=""
ENV LOCALMAILNAME=""
# smarthost to send mail to
ENV SMARTHOST=""
# recipient addresses for root aliases, separate multiple addresses by space
ENV ROOT=""
# ip addresses or networks to allow for relaying, separate multiple ones by semicolon
ENV RELAYNETS=""
RUN \
apt update && \
apt upgrade -y --autoremove && \
apt install -y exim4-daemon-light ca-certificates curl && \
rm -rf /var/lib/apt/lists/*
RUN apk add --no-cache exim bash
COPY update-exim4.conf.tmpl /etc/exim4/
COPY aliases.tmpl /etc/exim4/
COPY adjust-config.sh /etc/exim4/
COPY start.sh /etc/exim4/
COPY exim.conf.tmpl /etc/exim
COPY start.sh /etc/exim
WORKDIR /etc/exim4
WORKDIR /etc/exim
EXPOSE 25

View File

@ -1,15 +0,0 @@
#!/bin/bash
cat update-exim4.conf.tmpl \
| sed -e 's/%HOSTNAME%/'$HOSTNAME'/' \
-e 's#%RELAYNETS%#'$RELAYNETS'#' \
-e 's/%LOCALMAILNAME%/'$LOCALMAILNAME'/' \
-e 's/%SMARTHOST%/'$SMARTHOST'/' \
> update-exim4.conf.conf
cat aliases.tmpl \
| sed -e 's/%ROOT%/'"$ROOT"'/' \
> ../aliases && \
newaliases
/usr/sbin/update-exim4.conf -v

View File

@ -1,14 +0,0 @@
mailer-daemon: postmaster
postmaster: root
nobody: root
hostmaster: root
usenet: root
news: root
webmaster: root
www: root
ftp: root
abuse: root
noc: root
security: root
root: %ROOT%

26
examples/start-mailer.sh Normal file
View File

@ -0,0 +1,26 @@
#!/bin/bash
IMAGE=quay.io/wollud1969/exim-docker:0.0.9
MAILER_NETWORK=mailer-network
docker network inspect $MAILER_NETWORK > /dev/null || docker network create $MAILER_NETWORK
if [ "$RELAYNETS" = "" ]; then
RELAYNETS=`docker network inspect $MAILER_NETWORK --format '{{ (index .IPAM.Config 0).Subnet }}'`
fi
docker run \
-d \
-e SMARTHOST=smarthost.example.com \
-e LOCALMAILNAME=example.com \
-e RELAYNETS=$RELAYNETS \
-e ROOT=root@example.com \
--network $MAILER_NETWORK \
--name mailer \
--restart always \
$IMAGE

28
exim.conf.tmpl Normal file
View File

@ -0,0 +1,28 @@
primary_hostname = %HOSTNAME%
qualify_domain = %LOCALMAILNAME%
acl_smtp_rcpt = acl_check_rcpt
begin routers
smarthost_route:
driver = manualroute
domains = *
transport = smarthost_smtp
route_list = * %SMARTHOST%
begin transports
smarthost_smtp:
driver = smtp
port = 25
multi_domain
begin acl
acl_check_rcpt:
accept
hosts = %RELAYNETS%
deny
message = "Relaying denied"
begin rewrite
*@* ${1}@${qualify_domain} Ffrs

56
readme.md Normal file
View File

@ -0,0 +1,56 @@
# EXIM4 from Debian in a container
This image can be used to deploy an MTA in a container and connect it to a smarthost to provide the
option to send mail from other containers without the need to configure the smarthost in each of them.
## Configuration
Four environment variables are used to configure the container:
* `SMARTHOST`: The is the name of the smarthost. exim within this container will send all mail to this smarthost for further delivery. Make sure the smarthost accepts mail from this container without authentication.
* `LOCALMAILNAME`: The domain name which shall be used as the domain part of the sender address in every outgoing mail.
* `RELAYNETS`: Networks exim in this container accepts for relaying. Separate multiple networks by semicolon.
* `ROOT`: Addresses to forward root mail to. Separate multiple addresses by space.
## Deployment
Typically, don't expose the smtp port of this container to the default network of your Docker installation, otherwise it conflicts with a local MTA on the machine and it would be visible outside of the machine. Create a dedicated docker network, use that one as the default network for this container and connect other containers to that network. Afterwards, you can use the name of this container as smarthost address in the other containers.
## Example start script
```
#!/bin/bash
IMAGE=quay.io/wollud1969/exim-docker:0.0.9
MAILER_NETWORK=mailer-network
docker network create $MAILER_NETWORK || echo "mailer-network already exists"
if [ "$RELAYNETS" = "" ]; then
RELAYNETS=`docker network inspect $MAILER_NETWORK --format '{{ (index .IPAM.Config 0).Subnet }}'`
fi
docker run \
-d \
-e SMARTHOST=smarthost.example.com \
-e LOCALMAILNAME=krohne.com \
-e RELAYNETS=$RELAYNETS \
-e ROOT=root@example.com \
--network $MAILER_NETWORK \
--name mailer \
--restart always \
$IMAGE
```
## Usage in other containers
Connect other containers to the mailer network:
```
docker network connect mailer-network name_of_other_container
```
Now you can use the name of the mailer container, here `mailer` as smarthost name in that other container.

View File

@ -1,5 +1,13 @@
#!/bin/bash
./adjust-config.sh
rm exim.conf
cat exim.conf.tmpl \
| sed -e 's/%HOSTNAME%/'$HOSTNAME'/' \
-e 's#%RELAYNETS%#'$RELAYNETS'#' \
-e 's/%LOCALMAILNAME%/'$LOCALMAILNAME'/' \
-e 's/%SMARTHOST%/'$SMARTHOST'/' \
> exim.conf
exim -bd -q15m -v

View File

@ -1,14 +0,0 @@
dc_eximconfig_configtype='satellite'
dc_other_hostnames='%HOSTNAME%'
dc_local_interfaces='0.0.0.0'
dc_readhost='%LOCALMAILNAME%'
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets='%RELAYNETS%'
dc_smarthost='%SMARTHOST%'
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname='true'
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'