Skip to content

Commit 1ead7d0

Browse files
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
1 parent 7c2f0d4 commit 1ead7d0

File tree

4 files changed

+277
-0
lines changed

4 files changed

+277
-0
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
version: "3.8"
2+
3+
services:
4+
# -------------------------------------------------------------------------
5+
# Service 1: Database
6+
# -------------------------------------------------------------------------
7+
mysql:
8+
image: mysql:8.0
9+
command: --default-authentication-plugin=mysql_native_password
10+
restart: unless-stopped
11+
environment:
12+
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
13+
MYSQL_DATABASE: ${MAUTIC_DB_DATABASE}
14+
MYSQL_USER: ${MAUTIC_DB_USER}
15+
MYSQL_PASSWORD: ${MAUTIC_DB_PASSWORD}
16+
volumes:
17+
- mysql_data:/var/lib/mysql
18+
healthcheck:
19+
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
20+
interval: 10s
21+
timeout: 5s
22+
retries: 5
23+
24+
# -------------------------------------------------------------------------
25+
# Service 2: Mautic Web (The Leader)
26+
# -------------------------------------------------------------------------
27+
mautic:
28+
image: mautic/mautic:5.1.1-apache
29+
restart: unless-stopped
30+
depends_on:
31+
mysql:
32+
condition: service_healthy
33+
ports:
34+
- 80
35+
environment:
36+
- DOCKER_MAUTIC_ROLE=mautic_web
37+
- DOCKER_MAUTIC_RUN_MIGRATIONS=true
38+
- MAUTIC_DB_HOST=${MAUTIC_DB_HOST}
39+
- MAUTIC_DB_PORT=${MAUTIC_DB_PORT}
40+
- MAUTIC_DB_DATABASE=${MAUTIC_DB_DATABASE}
41+
- MAUTIC_DB_USER=${MAUTIC_DB_USER}
42+
- MAUTIC_DB_PASSWORD=${MAUTIC_DB_PASSWORD}
43+
- MAUTIC_URL=${MAUTIC_URL}
44+
- MAUTIC_TRUSTED_PROXIES=${MAUTIC_TRUSTED_PROXIES}
45+
- MAUTIC_MESSENGER_DSN_EMAIL=${MAUTIC_MESSENGER_DSN_EMAIL}
46+
- MAUTIC_MESSENGER_DSN_HIT=${MAUTIC_MESSENGER_DSN_HIT}
47+
- PHP_INI_DATE_TIMEZONE=${PHP_INI_DATE_TIMEZONE}
48+
- PHP_MEMORY_LIMIT=${PHP_MEMORY_LIMIT}
49+
volumes:
50+
- mautic_data:/var/www/html
51+
# AUTOMATION FIX 1: Force permissions to be correct on every start
52+
entrypoint: ["/bin/sh", "-c", "chown -R www-data:www-data /var/www/html && /entrypoint.sh apache2-foreground"]
53+
# AUTOMATION FIX 2: Check if the CONFIG FILE exists. If not, report 'unhealthy'.
54+
# This signals the other containers to keep waiting.
55+
healthcheck:
56+
test: ["CMD-SHELL", "test -f /var/www/html/config/local.php || exit 1"]
57+
interval: 10s
58+
timeout: 5s
59+
retries: 3
60+
start_period: 300s # Give you 5 mins to run the installer before marking failed
61+
62+
# -------------------------------------------------------------------------
63+
# Service 3: Mautic Cron (Waits for Install)
64+
# -------------------------------------------------------------------------
65+
mautic-cron:
66+
image: mautic/mautic:5.1.1-apache
67+
restart: unless-stopped
68+
depends_on:
69+
mautic:
70+
condition: service_healthy # AUTOMATION FIX 3: Do not start until config file exists
71+
environment:
72+
- DOCKER_MAUTIC_ROLE=mautic_cron
73+
- MAUTIC_DB_HOST=${MAUTIC_DB_HOST}
74+
- MAUTIC_DB_PORT=${MAUTIC_DB_PORT}
75+
- MAUTIC_DB_DATABASE=${MAUTIC_DB_DATABASE}
76+
- MAUTIC_DB_USER=${MAUTIC_DB_USER}
77+
- MAUTIC_DB_PASSWORD=${MAUTIC_DB_PASSWORD}
78+
- MAUTIC_URL=${MAUTIC_URL}
79+
- PHP_INI_DATE_TIMEZONE=${PHP_INI_DATE_TIMEZONE}
80+
volumes:
81+
- mautic_data:/var/www/html
82+
83+
# -------------------------------------------------------------------------
84+
# Service 4: Mautic Worker (Waits for Install)
85+
# -------------------------------------------------------------------------
86+
mautic-worker:
87+
image: mautic/mautic:5.1.1-apache
88+
restart: unless-stopped
89+
depends_on:
90+
mautic:
91+
condition: service_healthy # AUTOMATION FIX 3: Do not start until config file exists
92+
deploy:
93+
resources:
94+
limits:
95+
memory: 512M
96+
environment:
97+
- DOCKER_MAUTIC_ROLE=mautic_worker
98+
- DOCKER_MAUTIC_WORKERS_CONSUME_EMAIL=2
99+
- DOCKER_MAUTIC_WORKERS_CONSUME_HIT=2
100+
- DOCKER_MAUTIC_WORKERS_CONSUME_FAILED=2
101+
- MAUTIC_DB_HOST=${MAUTIC_DB_HOST}
102+
- MAUTIC_DB_PORT=${MAUTIC_DB_PORT}
103+
- MAUTIC_DB_DATABASE=${MAUTIC_DB_DATABASE}
104+
- MAUTIC_DB_USER=${MAUTIC_DB_USER}
105+
- MAUTIC_DB_PASSWORD=${MAUTIC_DB_PASSWORD}
106+
- MAUTIC_URL=${MAUTIC_URL}
107+
- MAUTIC_MESSENGER_DSN_EMAIL=${MAUTIC_MESSENGER_DSN_EMAIL}
108+
- MAUTIC_MESSENGER_DSN_HIT=${MAUTIC_MESSENGER_DSN_HIT}
109+
- PHP_INI_DATE_TIMEZONE=${PHP_INI_DATE_TIMEZONE}
110+
volumes:
111+
- mautic_data:/var/www/html
112+
113+
# -------------------------------------------------------------------------
114+
# Service 5: phpMyAdmin
115+
# -------------------------------------------------------------------------
116+
phpmyadmin:
117+
image: phpmyadmin/phpmyadmin
118+
restart: unless-stopped
119+
depends_on:
120+
mysql:
121+
condition: service_healthy
122+
environment:
123+
PMA_HOST: mysql
124+
PMA_PORT: 3306
125+
UPLOAD_LIMIT: 64M
126+
ports:
127+
- 80
128+
129+
volumes:
130+
mysql_data:
131+
mautic_data:

blueprints/mautic/mautic.svg

Lines changed: 76 additions & 0 deletions
Loading

blueprints/mautic/template.toml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
[variables]
2+
# Domain 1: For the main Mautic Application
3+
mautic_domain = "${domain}"
4+
5+
# Domain 2: For phpMyAdmin (Database Manager)
6+
pma_domain = "${domain}"
7+
8+
# Security: Random passwords
9+
db_password = "${password:32}"
10+
root_password = "${password:32}"
11+
12+
[config]
13+
14+
# --- Service 1: Mautic Web ---
15+
[[config.domains]]
16+
serviceName = "mautic"
17+
port = 80
18+
host = "${mautic_domain}"
19+
path = "/"
20+
21+
# --- Service 2: phpMyAdmin ---
22+
[[config.domains]]
23+
serviceName = "phpmyadmin"
24+
port = 80
25+
host = "${pma_domain}"
26+
path = "/"
27+
28+
# --- Shared Environment Variables ---
29+
[config.env]
30+
31+
# URL Configuration
32+
MAUTIC_URL = "https://${mautic_domain}"
33+
34+
# Database Connections
35+
MAUTIC_DB_HOST = "mysql"
36+
MAUTIC_DB_PORT = "3306"
37+
MAUTIC_DB_DATABASE = "mautic"
38+
MAUTIC_DB_USER = "mautic"
39+
MAUTIC_DB_PASSWORD = "${db_password}"
40+
MYSQL_ROOT_PASSWORD = "${root_password}"
41+
42+
# Security & Proxy (JSON ARRAY FIXED)
43+
# We use single quotes '...' so TOML treats the inner [...] as a string
44+
MAUTIC_TRUSTED_PROXIES = '["0.0.0.0/0"]'
45+
46+
# Queue Settings
47+
MAUTIC_MESSENGER_DSN_EMAIL = "doctrine://default"
48+
MAUTIC_MESSENGER_DSN_HIT = "doctrine://default"
49+
50+
# PHP Settings
51+
PHP_INI_DATE_TIMEZONE = "UTC"
52+
PHP_MEMORY_LIMIT = "512M"

meta.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3734,6 +3734,24 @@
37343734
"self-hosted"
37353735
]
37363736
},
3737+
{
3738+
"id": "mautic",
3739+
"name": "Mautic",
3740+
"version": "5.1.1",
3741+
"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.",
3742+
"logo": "mautic.svg",
3743+
"links": {
3744+
"github": "https://github.com/mautic/mautic",
3745+
"website": "https://www.mautic.org/",
3746+
"docs": "https://docs.mautic.org/en"
3747+
},
3748+
"tags": [
3749+
"marketing",
3750+
"automation",
3751+
"email",
3752+
"crm"
3753+
]
3754+
},
37373755
{
37383756
"id": "maybe",
37393757
"name": "Maybe",

0 commit comments

Comments
 (0)