docker-compose.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. services:
  2. app:
  3. build:
  4. context: .
  5. container_name: mailhub-app
  6. restart: unless-stopped
  7. env_file:
  8. - .env
  9. environment:
  10. PORT: 3000
  11. DATA_DIR: /data
  12. POSTFIX_LOG_FILE: /data/postfix-logs/mail.log
  13. MAIL_ACCESS_BACKEND: dovecot
  14. MAILDIR_ROOT: /data/maildir
  15. UV_THREADPOOL_SIZE: ${UV_THREADPOOL_SIZE:-2}
  16. DOVECOT_AUTH_ENABLED: "true"
  17. DOVECOT_AUTH_HOST: 0.0.0.0
  18. DOVECOT_AUTH_PORT: 3001
  19. DOVECOT_AUTH_SECRET_FILE: /run/secrets/dovecot_auth_secret
  20. WEBMAIL_SSO_URL: ${WEBMAIL_SSO_URL:-}
  21. WEBMAIL_SSO_SECRET_FILE: /data/secrets/webmail_sso_secret
  22. WEBMAIL_SSO_TICKET_TTL_SECONDS: ${WEBMAIL_SSO_TICKET_TTL_SECONDS:-60}
  23. WEBMAIL_SSO_CREDENTIAL_TTL_SECONDS: ${WEBMAIL_SSO_CREDENTIAL_TTL_SECONDS:-43200}
  24. ports:
  25. - "127.0.0.1:${APP_PORT:-3025}:3000"
  26. - "${SUBMISSION_BIND:-0.0.0.0}:25:25"
  27. - "${SUBMISSION_BIND:-0.0.0.0}:465:465"
  28. - "${SUBMISSION_BIND:-0.0.0.0}:587:587"
  29. - "${SUBMISSION_BIND:-0.0.0.0}:${SUBMISSION_ALT_PORT:-2525}:2525"
  30. expose:
  31. - "3001"
  32. volumes:
  33. - ./data:/data
  34. - ./certs:/certs:ro
  35. secrets:
  36. - dovecot_auth_secret
  37. networks:
  38. - mailhub
  39. - dovecot_internal
  40. depends_on:
  41. postfix:
  42. condition: service_started
  43. healthcheck:
  44. test: ["CMD", "node", "-e", "fetch('http://127.0.0.1:3000/healthz').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"]
  45. interval: 30s
  46. timeout: 5s
  47. retries: 4
  48. start_period: 120s
  49. dovecot:
  50. image: dovecot/dovecot:2.4.4
  51. container_name: mailhub-dovecot
  52. restart: unless-stopped
  53. hostname: ${MAIL_HOSTNAME:-mailhub.local}
  54. environment:
  55. SUBMISSION_TLS_CERT: ${SUBMISSION_TLS_CERT:-/certs/mailhub.example.com.crt}
  56. SUBMISSION_TLS_KEY: ${SUBMISSION_TLS_KEY:-/certs/mailhub.example.com.key}
  57. ports:
  58. - "${IMAP_BIND:-0.0.0.0}:143:31143"
  59. - "${IMAP_BIND:-0.0.0.0}:993:31993"
  60. - "${POP3_BIND:-0.0.0.0}:110:31110"
  61. - "${POP3_BIND:-0.0.0.0}:995:31995"
  62. volumes:
  63. - ./data/maildir:/srv/vmail
  64. - ./certs:/certs:ro
  65. - ./docker/dovecot/auth.conf:/etc/dovecot/conf.d/auth.conf:ro
  66. - ./docker/dovecot/ssl.conf:/etc/dovecot/conf.d/ssl.conf:ro
  67. - ./docker/dovecot/mailhub.conf:/etc/dovecot/conf.d/zz-mailhub.conf:ro
  68. - ./docker/dovecot/auth.lua:/etc/dovecot/auth.lua:ro
  69. secrets:
  70. - dovecot_auth_secret
  71. networks:
  72. - dovecot_internal
  73. - dovecot_public
  74. depends_on:
  75. app:
  76. condition: service_healthy
  77. read_only: true
  78. tmpfs:
  79. - /tmp:mode=1777
  80. - /run/dovecot:mode=1777
  81. security_opt:
  82. - no-new-privileges:true
  83. healthcheck:
  84. test: ["CMD-SHELL", "test -r /run/secrets/dovecot_auth_secret && test -s /run/secrets/dovecot_auth_secret && test -w /srv/vmail && doveadm service status imap-login pop3-login"]
  85. interval: 30s
  86. timeout: 5s
  87. retries: 3
  88. start_period: 15s
  89. postfix:
  90. build:
  91. context: ./docker/postfix
  92. container_name: mailhub-postfix
  93. restart: unless-stopped
  94. env_file:
  95. - .env
  96. environment:
  97. POSTFIX_LOG_FILE: /var/log/mailhub/mail.log
  98. hostname: ${MAIL_HOSTNAME:-mailhub.local}
  99. volumes:
  100. - ./data/postfix-logs:/var/log/mailhub
  101. networks:
  102. - mailhub
  103. healthcheck:
  104. test: ["CMD-SHELL", "postfix status >/dev/null 2>&1 || exit 1"]
  105. interval: 30s
  106. timeout: 5s
  107. retries: 3
  108. start_period: 20s
  109. secrets:
  110. dovecot_auth_secret:
  111. file: ./data/secrets/dovecot_auth_secret
  112. networks:
  113. mailhub:
  114. dovecot_internal:
  115. internal: true
  116. dovecot_public: