Move Mailcow copy hook into image behind MAILCOW_ENABLED #3

Merged
MHE merged 1 commit from evaluate-dockerfile-version-variables into main 2026-11-01 12:45:03 +01:00
Owner

What changed

  • The Mailcow certificate copy hook is now baked into the image as /usr/local/bin/mailcow-hook.sh instead of being mounted at runtime via POST_HOOK. The POST_HOOK variable is removed.
  • MAILCOW_ENABLED (true/false, default false) controls whether the hook runs. Any other value exits before the poll loop.
  • With false, the container only dumps PEM files and becomes ready after the first successful dump. SSH keys and the DNS token are not read.
  • With true, after a changed dump the hook copies the SMTP certificate to Mailcow over pinned SSH, updates the existing _25._tcp. TLSA record (Cloudflare or deSEC, DNSSEC-checked), and restarts postfix-mailcow, dovecot-mailcow, and nginx-mailcow. Remote certificates are backed up and rolled back on failure.
  • .dockerignore allows mailcow-hook.sh; the Dockerfile copies and marks it executable.
  • README documents the new variables, secret paths, and the compose example (no post-hook mount, MAILCOW_ENABLED: "false").
  • Adds .openso/memory/mailcow-hook.md recording the image-specific decision.

Why

The Mailcow hook previously lived in docker-templates and was mounted at runtime, which meant each deployment had to ship and keep in sync its own copy. Baking it into the image makes behaviour versioned with the image, and the explicit MAILCOW_ENABLED switch keeps dump-only deployments free of SSH and DNS secrets by default.

## What changed - The Mailcow certificate copy hook is now baked into the image as `/usr/local/bin/mailcow-hook.sh` instead of being mounted at runtime via `POST_HOOK`. The `POST_HOOK` variable is removed. - `MAILCOW_ENABLED` (`true`/`false`, default `false`) controls whether the hook runs. Any other value exits before the poll loop. - With `false`, the container only dumps PEM files and becomes ready after the first successful dump. SSH keys and the DNS token are not read. - With `true`, after a changed dump the hook copies the SMTP certificate to Mailcow over pinned SSH, updates the existing `_25._tcp.` TLSA record (Cloudflare or deSEC, DNSSEC-checked), and restarts `postfix-mailcow`, `dovecot-mailcow`, and `nginx-mailcow`. Remote certificates are backed up and rolled back on failure. - `.dockerignore` allows `mailcow-hook.sh`; the Dockerfile copies and marks it executable. - README documents the new variables, secret paths, and the compose example (no post-hook mount, `MAILCOW_ENABLED: "false"`). - Adds `.openso/memory/mailcow-hook.md` recording the image-specific decision. ## Why The Mailcow hook previously lived in `docker-templates` and was mounted at runtime, which meant each deployment had to ship and keep in sync its own copy. Baking it into the image makes behaviour versioned with the image, and the explicit `MAILCOW_ENABLED` switch keeps dump-only deployments free of SSH and DNS secrets by default.
Add Mailcow certificate hook and make it opt-in via MAILCOW_ENABLED
All checks were successful
ci / compose (pull_request) Successful in 13s
ci / shellcheck (pull_request) Successful in 3s
ci / conventions (pull_request) Successful in 2s
ci / image (pull_request) Successful in 32s
675882bd1e
MHE merged commit bddab8a314 into main 2026-11-01 12:45:03 +01:00
MHE deleted branch evaluate-dockerfile-version-variables 2026-11-01 13:52:17 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
openso/traefik-certs-dumper!3
No description provided.