docker: use docker-compose.override.yaml for user customizations

The base docker-compose.yaml was checked into git and thus would get
overwritten on pull.
- docker-compose.yaml uses named volumes as safe defaults
- docker-compose.override.yaml (gitignored) holds user customizations
- Compose automatically merges both files
This commit is contained in:
j4n
2026-02-17 07:53:18 +01:00
parent 71bd0da51a
commit c22efeb74b
4 changed files with 51 additions and 19 deletions

1
.gitignore vendored
View File

@@ -168,4 +168,5 @@ chatmail.zone
# docker
/data/
/custom/
docker-compose.override.yaml
.env

View File

@@ -1,4 +1,6 @@
# Copy docker/example.env to .env and set MAIL_DOMAIN before starting.
# Base compose file — do not edit. Put customizations (data paths, extra
# volumes, env overrides) in docker-compose.override.yaml instead.
# See docker/docker-compose.override.yaml.example for a starting point.
#
# Security note: this container uses network_mode:host (chatmail needs many
# ports: 25, 53, 80, 143, 443, 465, 587, 993, 3340, 8443) and cgroup:host
@@ -32,18 +34,14 @@ services:
CHATMAIL_NOACME: ${CHATMAIL_NOACME:-}
network_mode: "host"
volumes:
## system
- /sys/fs/cgroup:/sys/fs/cgroup:rw # required for systemd
## system (required)
- /sys/fs/cgroup:/sys/fs/cgroup:rw
## data (defaults — override in docker-compose.override.yaml)
- chatmail-mail:/home
- chatmail-dkimkeys:/etc/dkimkeys
- chatmail-acme:/var/lib/acme
## data
- ./data/chatmail:/home
- ./data/chatmail-dkimkeys:/etc/dkimkeys
- ./data/chatmail-acme:/var/lib/acme
## optional overrides
# - ./chatmail.ini:/etc/chatmail/chatmail.ini # use your own config
# - ./custom/www:/opt/chatmail-www # custom website
## debug
# - ./docker/files/setup_chatmail_docker.sh:/setup_chatmail_docker.sh
# - ./docker/files/entrypoint.sh:/entrypoint.sh
volumes:
chatmail-mail:
chatmail-dkimkeys:
chatmail-acme:

View File

@@ -0,0 +1,29 @@
# Local overrides — copy to docker-compose.override.yaml in the repo root.
# Compose automatically merges this with docker-compose.yaml.
#
# cp docker/docker-compose.override.yaml.example docker-compose.override.yaml
#
# Volumes listed here are APPENDED to the base file's volumes.
# Scalar values (environment, image, etc.) are REPLACED.
services:
chatmail:
volumes:
## Data paths — bind-mount to host directories for easy access/backup.
## Uncomment and adjust paths as needed. These override the named
## volumes in the base docker-compose.yaml.
# - ./data/chatmail:/home
# - ./data/chatmail-dkimkeys:/etc/dkimkeys
# - ./data/chatmail-acme:/var/lib/acme
## Or mount mail storage from an existing bare-metal install:
# - /home/vmail:/home/vmail
## Mount your own chatmail.ini (skips auto-generation):
# - ./chatmail.ini:/etc/chatmail/chatmail.ini
## Custom website:
# - ./custom/www:/opt/chatmail-www
## Debug — mount scripts from the repo for live editing:
# - ./docker/files/setup_chatmail_docker.sh:/setup_chatmail_docker.sh
# - ./docker/files/entrypoint.sh:/entrypoint.sh

View File

@@ -74,6 +74,12 @@ If you are running from the cloned repo directory, just copy the env file:
```shell
cp ./docker/example.env .env
```
All local customizations (data paths, extra volumes, config mounts) go in `docker-compose.override.yaml`, which Compose merges automatically with the base file. Copy the example to get started:
```shell
cp docker/docker-compose.override.yaml.example docker-compose.override.yaml
```
2. Configure the `.env` file. Only `MAIL_DOMAIN` is required:
@@ -120,13 +126,12 @@ mkdir -p ./custom/www/src
nano ./custom/www/src/index.md
```
2. In `docker-compose.yaml`, uncomment or add the website volume mount:
2. Add the volume mount in `docker-compose.override.yaml`:
```yaml
services:
chatmail:
volumes:
...
- ./custom/www:/opt/chatmail-www
```
@@ -153,13 +158,12 @@ docker cp chatmail:/etc/chatmail/chatmail.ini ./chatmail.ini
2. Edit `chatmail.ini` as needed.
3. In `docker-compose.yaml`, uncomment or add the ini volume mount:
3. Add the volume mount in `docker-compose.override.yaml`:
```yaml
services:
chatmail:
volumes:
...
- ./chatmail.ini:/etc/chatmail/chatmail.ini
```