From 1ead7d06a4d3b2fe1c7a1e8ab11147b602f6d118 Mon Sep 17 00:00:00 2001 From: Christus Vincent Date: Thu, 8 Jan 2026 03:11:03 +0800 Subject: [PATCH] Dokploy Deployment for Mautic 5 (#564) * first draft * second * try 3 * 4 * Update docker-compose.yml * Update template.toml * Enhance healthchecks and service dependencies in Docker Compose Updated healthcheck configurations for Mautic and MySQL services to improve service reliability. Added conditions to ensure services wait for dependencies to be healthy before starting. * Update Mautic docker-compose with health checks and roles --- blueprints/mautic/docker-compose.yml | 131 +++++++++++++++++++++++++++ blueprints/mautic/mautic.svg | 76 ++++++++++++++++ blueprints/mautic/template.toml | 52 +++++++++++ meta.json | 18 ++++ 4 files changed, 277 insertions(+) create mode 100644 blueprints/mautic/docker-compose.yml create mode 100644 blueprints/mautic/mautic.svg create mode 100644 blueprints/mautic/template.toml diff --git a/blueprints/mautic/docker-compose.yml b/blueprints/mautic/docker-compose.yml new file mode 100644 index 00000000..223ea7ee --- /dev/null +++ b/blueprints/mautic/docker-compose.yml @@ -0,0 +1,131 @@ +version: "3.8" + +services: + # ------------------------------------------------------------------------- + # Service 1: Database + # ------------------------------------------------------------------------- + mysql: + image: mysql:8.0 + command: --default-authentication-plugin=mysql_native_password + restart: unless-stopped + environment: + MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} + MYSQL_DATABASE: ${MAUTIC_DB_DATABASE} + MYSQL_USER: ${MAUTIC_DB_USER} + MYSQL_PASSWORD: ${MAUTIC_DB_PASSWORD} + volumes: + - mysql_data:/var/lib/mysql + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] + interval: 10s + timeout: 5s + retries: 5 + + # ------------------------------------------------------------------------- + # Service 2: Mautic Web (The Leader) + # ------------------------------------------------------------------------- + mautic: + image: mautic/mautic:5.1.1-apache + restart: unless-stopped + depends_on: + mysql: + condition: service_healthy + ports: + - 80 + environment: + - DOCKER_MAUTIC_ROLE=mautic_web + - DOCKER_MAUTIC_RUN_MIGRATIONS=true + - MAUTIC_DB_HOST=${MAUTIC_DB_HOST} + - MAUTIC_DB_PORT=${MAUTIC_DB_PORT} + - MAUTIC_DB_DATABASE=${MAUTIC_DB_DATABASE} + - MAUTIC_DB_USER=${MAUTIC_DB_USER} + - MAUTIC_DB_PASSWORD=${MAUTIC_DB_PASSWORD} + - MAUTIC_URL=${MAUTIC_URL} + - MAUTIC_TRUSTED_PROXIES=${MAUTIC_TRUSTED_PROXIES} + - MAUTIC_MESSENGER_DSN_EMAIL=${MAUTIC_MESSENGER_DSN_EMAIL} + - MAUTIC_MESSENGER_DSN_HIT=${MAUTIC_MESSENGER_DSN_HIT} + - PHP_INI_DATE_TIMEZONE=${PHP_INI_DATE_TIMEZONE} + - PHP_MEMORY_LIMIT=${PHP_MEMORY_LIMIT} + volumes: + - mautic_data:/var/www/html + # AUTOMATION FIX 1: Force permissions to be correct on every start + entrypoint: ["/bin/sh", "-c", "chown -R www-data:www-data /var/www/html && /entrypoint.sh apache2-foreground"] + # AUTOMATION FIX 2: Check if the CONFIG FILE exists. If not, report 'unhealthy'. + # This signals the other containers to keep waiting. + healthcheck: + test: ["CMD-SHELL", "test -f /var/www/html/config/local.php || exit 1"] + interval: 10s + timeout: 5s + retries: 3 + start_period: 300s # Give you 5 mins to run the installer before marking failed + + # ------------------------------------------------------------------------- + # Service 3: Mautic Cron (Waits for Install) + # ------------------------------------------------------------------------- + mautic-cron: + image: mautic/mautic:5.1.1-apache + restart: unless-stopped + depends_on: + mautic: + condition: service_healthy # AUTOMATION FIX 3: Do not start until config file exists + environment: + - DOCKER_MAUTIC_ROLE=mautic_cron + - MAUTIC_DB_HOST=${MAUTIC_DB_HOST} + - MAUTIC_DB_PORT=${MAUTIC_DB_PORT} + - MAUTIC_DB_DATABASE=${MAUTIC_DB_DATABASE} + - MAUTIC_DB_USER=${MAUTIC_DB_USER} + - MAUTIC_DB_PASSWORD=${MAUTIC_DB_PASSWORD} + - MAUTIC_URL=${MAUTIC_URL} + - PHP_INI_DATE_TIMEZONE=${PHP_INI_DATE_TIMEZONE} + volumes: + - mautic_data:/var/www/html + + # ------------------------------------------------------------------------- + # Service 4: Mautic Worker (Waits for Install) + # ------------------------------------------------------------------------- + mautic-worker: + image: mautic/mautic:5.1.1-apache + restart: unless-stopped + depends_on: + mautic: + condition: service_healthy # AUTOMATION FIX 3: Do not start until config file exists + deploy: + resources: + limits: + memory: 512M + environment: + - DOCKER_MAUTIC_ROLE=mautic_worker + - DOCKER_MAUTIC_WORKERS_CONSUME_EMAIL=2 + - DOCKER_MAUTIC_WORKERS_CONSUME_HIT=2 + - DOCKER_MAUTIC_WORKERS_CONSUME_FAILED=2 + - MAUTIC_DB_HOST=${MAUTIC_DB_HOST} + - MAUTIC_DB_PORT=${MAUTIC_DB_PORT} + - MAUTIC_DB_DATABASE=${MAUTIC_DB_DATABASE} + - MAUTIC_DB_USER=${MAUTIC_DB_USER} + - MAUTIC_DB_PASSWORD=${MAUTIC_DB_PASSWORD} + - MAUTIC_URL=${MAUTIC_URL} + - MAUTIC_MESSENGER_DSN_EMAIL=${MAUTIC_MESSENGER_DSN_EMAIL} + - MAUTIC_MESSENGER_DSN_HIT=${MAUTIC_MESSENGER_DSN_HIT} + - PHP_INI_DATE_TIMEZONE=${PHP_INI_DATE_TIMEZONE} + volumes: + - mautic_data:/var/www/html + + # ------------------------------------------------------------------------- + # Service 5: phpMyAdmin + # ------------------------------------------------------------------------- + phpmyadmin: + image: phpmyadmin/phpmyadmin + restart: unless-stopped + depends_on: + mysql: + condition: service_healthy + environment: + PMA_HOST: mysql + PMA_PORT: 3306 + UPLOAD_LIMIT: 64M + ports: + - 80 + +volumes: + mysql_data: + mautic_data: diff --git a/blueprints/mautic/mautic.svg b/blueprints/mautic/mautic.svg new file mode 100644 index 00000000..3f5229ae --- /dev/null +++ b/blueprints/mautic/mautic.svg @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/blueprints/mautic/template.toml b/blueprints/mautic/template.toml new file mode 100644 index 00000000..eeb79eef --- /dev/null +++ b/blueprints/mautic/template.toml @@ -0,0 +1,52 @@ +[variables] +# Domain 1: For the main Mautic Application +mautic_domain = "${domain}" + +# Domain 2: For phpMyAdmin (Database Manager) +pma_domain = "${domain}" + +# Security: Random passwords +db_password = "${password:32}" +root_password = "${password:32}" + +[config] + +# --- Service 1: Mautic Web --- +[[config.domains]] +serviceName = "mautic" +port = 80 +host = "${mautic_domain}" +path = "/" + +# --- Service 2: phpMyAdmin --- +[[config.domains]] +serviceName = "phpmyadmin" +port = 80 +host = "${pma_domain}" +path = "/" + +# --- Shared Environment Variables --- +[config.env] + +# URL Configuration +MAUTIC_URL = "https://${mautic_domain}" + +# Database Connections +MAUTIC_DB_HOST = "mysql" +MAUTIC_DB_PORT = "3306" +MAUTIC_DB_DATABASE = "mautic" +MAUTIC_DB_USER = "mautic" +MAUTIC_DB_PASSWORD = "${db_password}" +MYSQL_ROOT_PASSWORD = "${root_password}" + +# Security & Proxy (JSON ARRAY FIXED) +# We use single quotes '...' so TOML treats the inner [...] as a string +MAUTIC_TRUSTED_PROXIES = '["0.0.0.0/0"]' + +# Queue Settings +MAUTIC_MESSENGER_DSN_EMAIL = "doctrine://default" +MAUTIC_MESSENGER_DSN_HIT = "doctrine://default" + +# PHP Settings +PHP_INI_DATE_TIMEZONE = "UTC" +PHP_MEMORY_LIMIT = "512M" \ No newline at end of file diff --git a/meta.json b/meta.json index 753d3f87..ffff0e0b 100644 --- a/meta.json +++ b/meta.json @@ -3734,6 +3734,24 @@ "self-hosted" ] }, + { + "id": "mautic", + "name": "Mautic", + "version": "5.1.1", + "description": "Mautic is the world's largest open-source marketing automation project. It allows you to automate the process of finding and nurturing contacts through landing pages and forms, sending email, text messages, web notifications, and tracking your contacts.", + "logo": "mautic.svg", + "links": { + "github": "https://github.com/mautic/mautic", + "website": "https://www.mautic.org/", + "docs": "https://docs.mautic.org/en" + }, + "tags": [ + "marketing", + "automation", + "email", + "crm" + ] + }, { "id": "maybe", "name": "Maybe",