Overview
Mautic is an open-source marketing automation platform deployed as part of the Mondo Open Platform Service (MOPS). This documentation covers the deployment, configuration, and management of Mautic using Docker Compose with Traefik as a reverse proxy.
Service Details
Component | Value |
---|
URL | https://outreach.trymondo.com |
Image | mautic/mautic:5.2.4-apache |
Containers | mautic_web, mautic_cron, mautic_worker, mautic_db |
Database | MySQL 8.0 |
Networks | traefik-net, mautic-net |
Architecture
Mautic is deployed as a multi-container application with the following components:
┌─────────────┐
│ Traefik │
└──────┬──────┘
│ HTTPS
▼
┌─────────────┐ ┌──────────────┐
│ Mautic Cron │◄────▶│ Mautic Web │
└─────────────┘ └──────┬───────┘
▲ │
│ ▼
│ ┌──────────────┐
└─────────────┤ MySQL DB │
└──────────────┘
▲
┌─────────────┐ │
│Mautic Worker│◄────────────┘
└─────────────┘
- Mautic Web: Main application container serving the UI and API
- Mautic Cron: Runs scheduled tasks for email campaigns, etc.
- Mautic Worker: Processes queue jobs like email sending
- MySQL Database: Stores all Mautic data
Prerequisites
- Docker Engine (24.0+)
- Docker Compose v2
- Traefik reverse proxy configured and running
- External networks:
traefik-net
and mautic-net
- DNS configured for
outreach.trymondo.com
Deployment Configuration
Directory Structure
/opt/apps/mautic/
├── docker-compose.yml # Main configuration file
├── docker-compose.override.yml # Resource limits
├── .mautic.env # Mautic configuration
├── .env # Database credentials
├── mautic/
│ ├── config/ # Configuration files
│ ├── logs/ # Log files
│ └── media/ # Uploads
└── cron/ # Cron job configuration
Environment Variables
Create a .env
file with the following variables:
MYSQL_ROOT_PASSWORD=secure_root_password
MYSQL_DATABASE=mautic
MYSQL_USER=mautic_user
MYSQL_PASSWORD=secure_user_password
MAUTIC_PORT=8001
DOCKER_MAUTIC_LOAD_TEST_DATA=false
DOCKER_MAUTIC_RUN_MIGRATIONS=true
Create a .mautic.env
file with additional Mautic-specific configurations (not shown in the provided files).
Docker Compose Configuration
x-mautic-volumes: &mautic-volumes
- ./mautic/config:/var/www/html/config:z
- ./mautic/logs:/var/www/html/var/logs:z
- ./mautic/media/files:/var/www/html/docroot/media/files:z
- ./mautic/media/images:/var/www/html/docroot/media/images:z
- ./cron:/opt/mautic/cron:z
- mautic-docroot:/var/www/html/docroot:z
services:
db:
image: mysql:8.0
container_name: mautic_db
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_DATABASE=${MYSQL_DATABASE}
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
volumes:
- mysql-data:/var/lib/mysql
healthcheck:
test: mysqladmin --user=$$MYSQL_USER --password=$$MYSQL_PASSWORD ping
start_period: 5s
interval: 5s
timeout: 5s
retries: 10
networks:
- mautic-net
restart: unless-stopped
mautic_web:
image: mautic/mautic:5.2.4-apache
links:
- db:mysql
ports:
- ${MAUTIC_PORT:-8001}:80
volumes: *mautic-volumes
container_name: mautic_web
environment:
- DOCKER_MAUTIC_LOAD_TEST_DATA=${DOCKER_MAUTIC_LOAD_TEST_DATA}
- DOCKER_MAUTIC_RUN_MIGRATIONS=${DOCKER_MAUTIC_RUN_MIGRATIONS}
env_file:
- .mautic.env
healthcheck:
test: curl http://localhost
start_period: 5s
interval: 5s
timeout: 5s
retries: 100
depends_on:
db:
condition: service_healthy
networks:
- traefik-net
- mautic-net
labels:
- 'traefik.enable=true'
- 'traefik.http.routers.mautic.rule=Host(`outreach.trymondo.com`)'
- 'traefik.http.routers.mautic.entrypoints=websecure'
- 'traefik.http.routers.mautic.tls=true'
- 'traefik.http.routers.mautic.tls.certresolver=production'
- 'traefik.http.services.mautic.loadbalancer.server.scheme=http'
- 'traefik.http.services.mautic.loadbalancer.server.port=80'
- 'traefik.http.routers.mautic.middlewares=cors@file,secureHeaders@file'
restart: unless-stopped
mautic_cron:
image: mautic/mautic:5.2.4-apache
links:
- db:mysql
volumes: *mautic-volumes
container_name: mautic_cron
environment:
- DOCKER_MAUTIC_ROLE=mautic_cron
env_file:
- .mautic.env
depends_on:
mautic_web:
condition: service_healthy
networks:
- mautic-net
restart: unless-stopped
mautic_worker:
image: mautic/mautic:5.2.4-apache
links:
- db:mysql
volumes: *mautic-volumes
container_name: mautic_worker
environment:
- DOCKER_MAUTIC_ROLE=mautic_worker
env_file:
- .mautic.env
depends_on:
mautic_web:
condition: service_healthy
networks:
- mautic-net
restart: unless-stopped
volumes:
mysql-data:
mautic-docroot:
networks:
traefik-net:
external: true
mautic-net:
external: true
Resource Limits (Optional)
For improved stability, add resource constraints using a docker-compose.override.yml
file:
services:
db:
deploy:
resources:
limits:
memory: 512M
cpus: '0.2'
mautic_web:
deploy:
resources:
limits:
memory: 384M
cpus: '0.5'
mautic_cron:
deploy:
resources:
limits:
memory: 320M
cpus: '0.2'
mautic_worker:
deploy:
resources:
limits:
memory: 512M
cpus: '0.3'
Network Configuration
Before deployment, ensure the required networks exist:
# Create external networks if they don't exist
docker network create mautic-net
docker network create traefik-net
Deployment Instructions
-
Create the deployment directory structure:
mkdir -p /opt/apps/mautic/{mautic/{config,logs,media/{files,images}},cron}
-
Create the configuration files:
touch /opt/apps/mautic/.env
touch /opt/apps/mautic/.mautic.env
nano /opt/apps/mautic/docker-compose.yml
nano /opt/apps/mautic/docker-compose.override.yml
-
Add appropriate content to the .env
and .mautic.env
files
-
Deploy the service:
cd /opt/apps/mautic
docker compose up -d
-
Verify the services are running:
Traefik Integration
Mautic is configured with the following Traefik settings:
- Host Rule:
outreach.trymondo.com
- Entrypoint: websecure (HTTPS)
- TLS: Enabled with production certificate resolver
- Backend Port: 80
- Middlewares: CORS and secure headers
Webflow Integration
Mautic can be integrated with Webflow forms using JavaScript tracking. Add the following code to your Webflow site:
document.addEventListener('DOMContentLoaded', function () {
const form = document.getElementById('leadForm');
const emailField = document.getElementById('Email-7');
const firstNameField = document.getElementById('First-Name');
const lastNameField = document.getElementById('Last-Name');
form.addEventListener('submit', function (event) {
const email = emailField.value;
const firstName = firstNameField.value;
const lastName = lastNameField.value;
// Identify contact in Mautic
mt('send', 'pageview', {
email: email,
firstname: firstName,
lastname: lastName,
});
// Let the form submit normally
setTimeout(function () {
form.submit();
}, 300); // short delay to ensure tracking call completes
});
});
Maintenance
Backup Strategy
Back up Mautic regularly:
# Stop the services
docker compose stop
# Backup the database
docker compose exec db mysqldump -u root -p${MYSQL_ROOT_PASSWORD} ${MYSQL_DATABASE} > mautic_backup_$(date +%Y%m%d).sql
# Backup volumes
tar -czf mautic_data_backup_$(date +%Y%m%d).tar.gz -C /opt/apps/mautic mautic
# Restart the services
docker compose start
Updates
To update Mautic:
-
Update the image tag in docker-compose.yml
-
Apply the update:
cd /opt/apps/mautic
docker compose pull
docker compose up -d
-
Check logs for any issues:
Always back up your data before updating Mautic to a new version.
Troubleshooting
Database Connection Issues
If Mautic can’t connect to the database:
-
Verify MySQL container is running:
-
Check database logs:
-
Verify credentials in .env
file match what Mautic is using
Email Configuration Problems
If emails are not being sent:
-
Check worker logs:
docker compose logs mautic_worker
-
Verify SMTP settings in Mautic’s configuration
-
Ensure the worker container has proper network access to the SMTP server
Web Interface Not Accessible
If you can’t access the Mautic interface:
-
Check container health:
-
Verify Traefik routing:
docker compose logs mautic_web | grep -i "traefik"
-
Check for any error logs:
docker compose logs mautic_web
For improved performance:
- Increase Memory Limits: Adjust values in
docker-compose.override.yml
if needed
- Database Tuning: Consider adding MySQL configuration for better performance
- Caching: Enable Redis if needed for larger installations
Additional Resources
Integration Examples
Example of embedding a Mautic form on a website:
<script type="text/javascript">
(function (w, d, t, u, n, a, m) {
w['MauticTrackingObject'] = n;
(w[n] =
w[n] ||
function () {
(w[n].q = w[n].q || []).push(arguments);
}),
(a = d.createElement(t)),
(m = d.getElementsByTagName(t)[0]);
a.async = 1;
a.src = u;
m.parentNode.insertBefore(a, m);
})(window, document, 'script', 'https://outreach.trymondo.com/mtc.js', 'mt');
mt('send', 'pageview');
</script>
<form
id="mauticform_webformlead"
data-mautic-form="webformlead"
method="post"
action="https://outreach.trymondo.com/form/submit?formId=1"
>
<div class="mauticform-page-wrapper">
<div class="mauticform-row">
<label for="mauticform_input_webformlead_email">Email</label>
<input
id="mauticform_input_webformlead_email"
name="mauticform[email]"
type="email"
required="required"
/>
</div>
<div class="mauticform-row">
<button type="submit" name="mauticform[submit]">Submit</button>
</div>
</div>
</form>