# Before launching mox, run the quickstart to create config files for running as
# user the mox user (create it on the host system first, e.g. "useradd -d $PWD mox"):
#
#	mkdir config data web
# 	docker-compose run mox mox quickstart you@yourdomain.example $(id -u mox)
#
# note: if you are running quickstart on a different machine than you will deploy
# mox to, use the "quickstart -hostname ..." flag.
#
# After following the quickstart instructions you can start mox:
#
# 	docker-compose up
#
#
# If you want to run "mox localserve", you could start it like this:
#
#	docker run \
#		-p 127.0.0.1:25:1025 \
#		-p 127.0.0.1:465:1465 \
#		-p 127.0.0.1:587:1587 \
#		-p 127.0.0.1:993:1993 \
#		-p 127.0.0.1:143:1143 \
#		-p 127.0.0.1:443:1443 \
#		-p 127.0.0.1:80:1080 \
#		r.xmox.nl/mox:latest mox localserve -ip 0.0.0.0
#
# The -ip flag ensures connections to the published ports make it to mox, and it
# prevents listening on ::1 (IPv6 is not enabled in docker by default).

version: '3.7'
services:
  mox:
    # Replace "latest" with the version you want to run, see https://r.xmox.nl/r/mox/.
    # Include the @sha256:... digest to ensure you get the listed image.
    image: r.xmox.nl/mox:latest
    environment:
      - MOX_DOCKER=yes # Quickstart won't try to write systemd service file.
    # Mox needs host networking because it needs access to the IPs of the
    # machine, and the IPs of incoming connections for spam filtering.
    network_mode: 'host'
    volumes:
      - ./config:/mox/config
      - ./data:/mox/data
      # web is optional but recommended to bind in, useful for serving static files with
      # the webserver.
      - ./web:/mox/web
    working_dir: /mox
    restart: on-failure
    healthcheck:
      test: netstat -nlt | grep ':25 '
      interval: 1s
      timeout: 1s
      retries: 10
