Skip to content

Commit c483fff

Browse files
committed
fix(doc): document bare-metal to docker and back better
1 parent 538f1f0 commit c483fff

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

docker-compose.override.yaml.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ services:
1414

1515
# - ./data/mail:/home/vmail
1616
## Or mount from an existing bare-metal install.
17+
## Service user UIDs differ between native and Docker installs. On first
18+
## start the container fixes /etc/dkimkeys and /home/vmail ownership
19+
## automatically. Switching back to native requires a manual chown:
20+
## chown -R vmail:vmail /home/vmail
21+
## chown -R opendkim:opendkim /etc/dkimkeys
1722
# - /home/vmail:/home/vmail
23+
# - /etc/dkimkeys:/etc/dkimkeys
24+
# - /var/lib/acme:/var/lib/acme
1825

1926
## Mount your own chatmail.ini (skips auto-generation):
2027
# - ./chatmail.ini:/etc/chatmail/chatmail.ini

scripts/chatmail-init.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export CHATMAIL_INI="${CHATMAIL_INI:-/etc/chatmail/chatmail.ini}"
66
CMDEPLOY=/opt/cmdeploy/bin/cmdeploy
77

88
if [ -z "$MAIL_DOMAIN" ]; then
9-
echo "ERROR: Environment variable 'MAIL_DOMAIN' must be set!" >&2
9+
echo "[ERROR] Environment variable 'MAIL_DOMAIN' must be set!" >&2
1010
exit 1
1111
fi
1212

@@ -16,6 +16,7 @@ if [ ! -f /etc/dkimkeys/opendkim.private ]; then
1616
fi
1717
# Fix ownership for bind-mounted keys (host opendkim UID may differ from container)
1818
chown -R opendkim:opendkim /etc/dkimkeys
19+
echo "[INFO] Fixing /etc/dkimkeys ownership"
1920

2021
# Create chatmail.ini, skip if mounted
2122
mkdir -p "$(dirname "$CHATMAIL_INI")"
@@ -45,6 +46,13 @@ fi
4546
mkdir -p "/home/vmail/mail/${MAIL_DOMAIN}"
4647
chown vmail:vmail "/home/vmail/mail/${MAIL_DOMAIN}"
4748

49+
# Fix ownership for bind-mounted mail store (host vmail UID may differ from container).
50+
# Only recurse when the top-level dir is mis-owned, can be slow on large mailstores.
51+
if [ "$(stat -c %U /home/vmail 2>/dev/null)" != "vmail" ]; then
52+
echo "[INFO] Fixing /home/vmail ownership"
53+
chown -R vmail:vmail /home/vmail
54+
fi
55+
4856
# --- Deploy fingerprint: skip cmdeploy run if nothing changed ---
4957
# On restart with identical image+config, systemd already brings up all
5058
# enabled services only configure+activate are needed here.

0 commit comments

Comments
 (0)