Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .docker/.mautic_env
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# use this file for environment variables that can be used.
# see https://docs.mautic.org/en/7.x/

MAUTIC_DB_HOST="${MYSQL_HOST}"
MAUTIC_DB_PORT="${MYSQL_PORT}"
MAUTIC_DB_DATABASE="${MYSQL_DATABASE}"
MAUTIC_DB_USER="${MYSQL_USER}"
MAUTIC_DB_PASSWORD="${MYSQL_PASSWORD}"

MAUTIC_MESSENGER_DSN_EMAIL="doctrine://default"
MAUTIC_MESSENGER_DSN_HIT="doctrine://default"

MAUTIC_AUTO_INSTALL="false"
MAUTIC_FORCE_INSTALL="false"
MAUTIC_SITE_URL="http://localhost"
MAUTIC_ADMIN_FIRSTNAME="Admin"
MAUTIC_ADMIN_LASTNAME="Mautic"
MAUTIC_ADMIN_USERNAME="admin"
MAUTIC_ADMIN_EMAIL="admin@example.com"
MAUTIC_ADMIN_PASSWORD="ChangeMe123!"
4 changes: 2 additions & 2 deletions .docker/Dockerfile.apache
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.1-apache
FROM php:8.3-apache

LABEL vendor="Mautic"
LABEL maintainer="LibreCode coop"
Expand Down Expand Up @@ -62,7 +62,7 @@ ENV DOCKER_MAUTIC_WORKERS_CONSUME_EMAIL=2 \

# Install NVM
ENV NVM_DIR=/usr/local/nvm \
NODE_VERSION=20.18.1
NODE_VERSION=25.2.1
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# hadolint ignore=SC1091
RUN mkdir -p /usr/local/nvm && \
Expand Down
4 changes: 2 additions & 2 deletions .docker/Dockerfile.fpm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.1-fpm
FROM php:8.3-fpm

LABEL vendor="Mautic"
LABEL maintainer="LibreCode coop"
Expand Down Expand Up @@ -56,7 +56,7 @@ ENV DOCKER_MAUTIC_WORKERS_CONSUME_EMAIL=2 \

# Install NVM
ENV NVM_DIR=/usr/local/nvm \
NODE_VERSION=20.18.1
NODE_VERSION=25.2.1
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# hadolint ignore=SC1091
RUN mkdir -p /usr/local/nvm && \
Expand Down
2 changes: 1 addition & 1 deletion .docker/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ elif [ "$DOCKER_MAUTIC_ROLE" = "mautic_web" ]; then
nvm use default

cd /var/www || { echo "Directory not found /var/www"; exit 1; }
COMPOSER_ALLOW_SUPERUSER=1 COMPOSER_PROCESS_TIMEOUT=10000 composer create-project mautic/recommended-project:"${MAUTIC_VERSION:-5.x-dev}" html --no-interaction
COMPOSER_ALLOW_SUPERUSER=1 COMPOSER_PROCESS_TIMEOUT=10000 composer create-project mautic/recommended-project:"${MAUTIC_VERSION:-7.x-dev}" html --no-interaction
chown -R www-data: html
cd html || { echo "Directory not found /var/www/html"; exit 1; }
rm -rf var/cache/js
Expand Down
96 changes: 92 additions & 4 deletions .docker/scripts/entrypoint_mautic_web.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,65 @@
#!/bin/bash

chown -R www-data:www-data /var/www/html/config /var/www/html/var/logs /var/www/html/docroot/media
set -e

# wait untill the db is fully up before proceeding
prepare_install_dirs() {
mkdir -p /var/www/html/var/cache /var/www/html/var/logs
chown -R www-data:www-data /var/www/html/config /var/www/html/var /var/www/html/docroot/media
}

prepare_install_dirs

mautic_site_url="${MAUTIC_SITE_URL:-http://localhost}"
mautic_admin_firstname="${MAUTIC_ADMIN_FIRSTNAME:-Admin}"
mautic_admin_lastname="${MAUTIC_ADMIN_LASTNAME:-Mautic}"
mautic_admin_username="${MAUTIC_ADMIN_USERNAME:-admin}"
mautic_admin_email="${MAUTIC_ADMIN_EMAIL:-admin@example.com}"
mautic_admin_password="${MAUTIC_ADMIN_PASSWORD:-ChangeMe123!}"
mautic_db_table_prefix="${MAUTIC_DB_TABLE_PREFIX:-}"
mautic_db_backup_tables="${MAUTIC_DB_BACKUP_TABLES:-true}"
mautic_db_backup_prefix="${MAUTIC_DB_BACKUP_PREFIX:-bak_}"
mautic_force_install="${MAUTIC_FORCE_INSTALL:-false}"

install_mautic() {
local mautic_db_name="${MAUTIC_DB_DATABASE:-${MAUTIC_DB_NAME:-mautic}}"
local cmd

printf -v cmd 'php /var/www/html/bin/console mautic:install %q --force --db_driver=pdo_mysql --db_host=%q --db_port=%q --db_name=%q --db_user=%q --db_password=%q --db_table_prefix=%q --db_backup_tables=%q --db_backup_prefix=%q --admin_firstname=%q --admin_lastname=%q --admin_username=%q --admin_email=%q --admin_password=%q' \
"$mautic_site_url" \
"$MAUTIC_DB_HOST" \
"$MAUTIC_DB_PORT" \
"$mautic_db_name" \
"$MAUTIC_DB_USER" \
"$MAUTIC_DB_PASSWORD" \
"$mautic_db_table_prefix" \
"$mautic_db_backup_tables" \
"$mautic_db_backup_prefix" \
"$mautic_admin_firstname" \
"$mautic_admin_lastname" \
"$mautic_admin_username" \
"$mautic_admin_email" \
"$mautic_admin_password"

su -s /bin/bash www-data -c "$cmd"
}

install_mautic_plugins() {
su -s /bin/bash www-data -c 'php /var/www/html/bin/console mautic:plugins:install'
}

mautic_is_installed() {
# shellcheck disable=SC2016
php -r 'if (!file_exists("/var/www/html/config/local.php")) { exit(1); } include "/var/www/html/config/local.php"; exit(isset($parameters["db_driver"], $parameters["site_url"]) ? 0 : 1);'
}

# wait until the db is fully up before proceeding
while [[ $(mysqladmin --host="$MAUTIC_DB_HOST" --port="$MAUTIC_DB_PORT" --user="$MAUTIC_DB_USER" --password="$MAUTIC_DB_PASSWORD" ping) != "mysqld is alive" ]]; do
sleep 1
done

# generate a local config file if it doesn't exist.
# This is needed to ensure the db credentials can be prefilled in the UI, as env vars aren't taken into account.
if [ ! -f /var/www/html/config/local.php ]; then

su -s /bin/bash www-data -c 'touch /var/www/html/config/local.php'

cat <<'EOF' > /var/www/html/config/local.php
Expand All @@ -29,11 +78,50 @@ $parameters = array(
EOF
fi

if [ "$mautic_force_install" = "true" ]; then
rm -f /var/www/html/config/local.php
fi

prepare_install_dirs

if [ "$MAUTIC_AUTO_INSTALL" = "true" ] && [ -f /var/www/html/config/local.php ]; then
if ! mautic_is_installed; then
rm -f /var/www/html/config/local.php
fi
fi

if [ "$MAUTIC_AUTO_INSTALL" = "true" ] && [ ! -f /var/www/html/config/local.php ]; then
MAUTIC_SITE_URL="$mautic_site_url" \
MAUTIC_ADMIN_FIRSTNAME="$mautic_admin_firstname" \
MAUTIC_ADMIN_LASTNAME="$mautic_admin_lastname" \
MAUTIC_ADMIN_USERNAME="$mautic_admin_username" \
MAUTIC_ADMIN_EMAIL="$mautic_admin_email" \
MAUTIC_ADMIN_PASSWORD="$mautic_admin_password" \
MAUTIC_DB_TABLE_PREFIX="$mautic_db_table_prefix" \
MAUTIC_DB_BACKUP_TABLES="$mautic_db_backup_tables" \
MAUTIC_DB_BACKUP_PREFIX="$mautic_db_backup_prefix" \
install_mautic

install_mautic_plugins
fi

# prepare mautic with test data
if [ "$DOCKER_MAUTIC_LOAD_TEST_DATA" = "true" ]; then
su -s /bin/bash www-data -c 'php /var/www/html/bin/console doctrine:migrations:sync-metadata-storage'
# mautic installation with dummy password and email, as the next step (doctrine:fixtures:load) will overwrite those
su -s /bin/bash www-data -c 'php /var/www/html/bin/console mautic:install --force --admin_email willchange@mautic.org --admin_password willchange http://localhost'
if ! mautic_is_installed; then
MAUTIC_SITE_URL="$mautic_site_url" \
MAUTIC_ADMIN_FIRSTNAME="$mautic_admin_firstname" \
MAUTIC_ADMIN_LASTNAME="$mautic_admin_lastname" \
MAUTIC_ADMIN_USERNAME="$mautic_admin_username" \
MAUTIC_ADMIN_EMAIL="$mautic_admin_email" \
MAUTIC_ADMIN_PASSWORD="$mautic_admin_password" \
MAUTIC_DB_TABLE_PREFIX="$mautic_db_table_prefix" \
MAUTIC_DB_BACKUP_TABLES="$mautic_db_backup_tables" \
MAUTIC_DB_BACKUP_PREFIX="$mautic_db_backup_prefix" \
install_mautic
fi
install_mautic_plugins
su -s /bin/bash www-data -c 'php /var/www/html/bin/console doctrine:fixtures:load -n'
fi

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ on:
required: true
overwrite_latest_major:
type: boolean
description: "Overwrite latest major tag (e.g.`5`). This should only be checked if you're releasing the latest release."
description: "Overwrite latest major tag (e.g.`7`). This should only be checked if you're releasing the latest release."
overwrite_latest_minor:
type: boolean
description: "Overwrite latest minor tag (e.g.`5.0`). This should only be checked if you're releasing the latest release within the minor release."
description: "Overwrite latest minor tag (e.g.`7.0`). This should only be checked if you're releasing the latest release within the minor release."
tag_as_latest:
type: boolean
description: "Tag this release as latest"
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "volumes/mautic/docroot/plugins/MauticCrmBundle"]
path = volumes/mautic/docroot/plugins/MauticCrmBundle
url = https://github.com/mautomic-com/mautic-crm-bundle.git
branch = main
57 changes: 48 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# Mautic Docker image and examples

> [!NOTE]
> _This version refers to Docker images and examples for Mautic 5. If you would like information about older versions, see https://github.com/mautic/docker-mautic/tree/mautic4._
> _This version refers to Docker images and examples for Mautic 7. If you would like information about older versions, see https://github.com/mautic/docker-mautic/tree/mautic4._

> [!NOTE]
> This fork was made to make possible use xdebug

If you want the CRM plugin submodule checked out on clone, use:

```bash
git clone --recurse-submodules https://github.com/LibreCodeCoop/mautic-docker.git
```

## Versions

all Mautic 5 Docker images follow the following naming stategy.
all Mautic 7 Docker images follow the following naming stategy.

`<major.minor.patch>-<variant>`

Expand All @@ -18,9 +24,9 @@ There are some defaults if parts are omitted:

some examples:

* `5-apache`: latest stable version of Mautic 5 of the `apache` variant
* `5.0-fpm`: latest version in the 5.0 minor release in the `fpm` variant
* `5.0.3-apache`: specific point release of the `apache` variant
* `7-apache`: latest stable version of Mautic 7 of the `apache` variant
* `7.0-fpm`: latest version in the 7.0 minor release in the `fpm` variant
* `7.0.3-apache`: specific point release of the `apache` variant

## Variants

Expand Down Expand Up @@ -73,8 +79,8 @@ The `examples` folder contains examples of `docker-compose` setups that use the
You can build your own images easily using the `docker build` command in the root of this directory:

```
docker build . -f Dockerfile.apache -t librecodecoop/mautic:5-apache
docker build . -f Dockerfile.fpm -t librecodecoop/mautic:5-fpm
docker build . -f Dockerfile.apache -t librecodecoop/mautic:7-apache
docker build . -f Dockerfile.fpm -t librecodecoop/mautic:7-fpm
```

## Persistent storage
Expand Down Expand Up @@ -119,6 +125,14 @@ You can get all available environments looking at a docker-compose.yml file that

- `DOCKER_MAUTIC_ROLE`: which role does the container has to perform.
Defaults to `mautic_web`, other supported values are `mautic_worker` and `mautic_cron`.
- `MAUTIC_AUTO_INSTALL`: when `true`, the web container runs `mautic:install` automatically on first boot.
Defaults to `false`.
- `MAUTIC_FORCE_INSTALL`: when `true`, the web container clears any partial local install state and runs `mautic:install` again.
Defaults to `false`.
- `MAUTIC_SITE_URL`: site URL passed to the installer.
Defaults to `http://localhost`.
- `MAUTIC_ADMIN_FIRSTNAME`, `MAUTIC_ADMIN_LASTNAME`, `MAUTIC_ADMIN_USERNAME`, `MAUTIC_ADMIN_EMAIL`, `MAUTIC_ADMIN_PASSWORD`: admin account fields used by the automated install.
Defaults are `Admin`, `Mautic`, `admin`, `admin@example.com`, and `ChangeMe123!`.
- `DOCKER_MAUTIC_LOAD_TEST_DATA`: should the test data be loaded on start or not.
Defaults to `false`, other supported value is `true`.
This variable is only usable when using the `web` role.
Expand All @@ -141,10 +155,35 @@ Technically, every setting of Mautic you can set via the UI or via the `local.ph
e.g. the `messenger_dsn_hit` can be set via the `MAUTIC_MESSENGER_DSN_HIT` environment variable.
See the general Mautic documentation for more info.

#### Automated installation

To install Mautic without using the browser installer, set `MAUTIC_AUTO_INSTALL=true` and provide the DB/admin variables through your environment or `.env` file.

Example:

```env
MAUTIC_AUTO_INSTALL=true
MAUTIC_FORCE_INSTALL=true
MAUTIC_SITE_URL=http://localhost
MAUTIC_ADMIN_FIRSTNAME=Admin
MAUTIC_ADMIN_LASTNAME=Mautic
MAUTIC_ADMIN_USERNAME=admin
MAUTIC_ADMIN_EMAIL=admin@example.com
MAUTIC_ADMIN_PASSWORD=ChangeMe123!
```

Use `MAUTIC_FORCE_INSTALL=true` on the first boot when you want to skip the browser installer entirely, or when you are reusing a volume that already contains a partial install state.

This repository also tracks the CRM bundle as a git submodule under `volumes/mautic/docroot/plugins/MauticCrmBundle`. If you clone the repository manually, initialize submodules before starting the stack:

```bash
git submodule update --init --recursive
```

### Customization

Currently this image has no easy way to extend Mautic (e.g. adding extra `composer` dependencies or installing extra plugins or themes).
This is an ongoing effort we hope to support in an upcoming 5.x release.
This is an ongoing effort we hope to support in an upcoming 7.x release.


For now, please build your own images based on the official ones to add the needed dependencies, plugins and themes.
Expand Down Expand Up @@ -184,4 +223,4 @@ You can also reach the Mautic community through its [online forums](https://www.

You are invited to contribute new features, fixes, or updates, large or small; we are always thrilled to receive pull requests, and do our best to process them as fast as we can.

Before you start to code, we recommend discussing your plans through a [GitHub issue](https://github.com/librecodecoop/mautic-docker/issues), especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give you feedback on your design, and help you find out if someone else is working on the same thing.
Before you start to code, we recommend discussing your plans through a [GitHub issue](https://github.com/librecodecoop/mautic-docker/issues), especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give you feedback on your design, and help you find out if someone else is working on the same thing.
20 changes: 16 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ x-mautic-volumes: &mautic-volumes
- ./volumes/cron:/opt/mautic/cron:z

x-mautic-environments: &mautic-environments
MAUTIC_VERSION: ${MAUTIC_VERSION:-5.x-dev}
MAUTIC_VERSION: ${MAUTIC_VERSION:-7.x-dev}
TZ: ${TZ:-CET}
HOST_UID: ${HOST_UID:-1000}
HOST_GID: ${HOST_GID:-1000}
Expand All @@ -12,14 +12,26 @@ x-mautic-environments: &mautic-environments
MAUTIC_DB_USER: ${MAUTIC_DB_USER:-mautic}
MAUTIC_DB_PASSWORD: ${MAUTIC_DB_PASSWORD:-mautic}
MAUTIC_DB_NAME: ${MAUTIC_DB_NAME:-mautic}
MAUTIC_DB_DATABASE: ${MAUTIC_DB_DATABASE:-mautic}
MAUTIC_DB_TABLE_PREFIX: ${MAUTIC_DB_TABLE_PREFIX:-}
MAUTIC_DB_BACKUP_TABLES: ${MAUTIC_DB_BACKUP_TABLES:-true}
MAUTIC_DB_BACKUP_PREFIX: ${MAUTIC_DB_BACKUP_PREFIX:-bak_}
MAUTIC_AUTO_INSTALL: ${MAUTIC_AUTO_INSTALL:-false}
MAUTIC_FORCE_INSTALL: ${MAUTIC_FORCE_INSTALL:-false}
MAUTIC_SITE_URL: ${MAUTIC_SITE_URL:-http://localhost}
MAUTIC_ADMIN_FIRSTNAME: ${MAUTIC_ADMIN_FIRSTNAME:-Admin}
MAUTIC_ADMIN_LASTNAME: ${MAUTIC_ADMIN_LASTNAME:-Mautic}
MAUTIC_ADMIN_USERNAME: ${MAUTIC_ADMIN_USERNAME:-admin}
MAUTIC_ADMIN_EMAIL: ${MAUTIC_ADMIN_EMAIL:-admin@example.com}
MAUTIC_ADMIN_PASSWORD: ${MAUTIC_ADMIN_PASSWORD:-ChangeMe123!}
MAUTIC_RUN_CRON_JOBS: ${MAUTIC_RUN_CRON_JOBS:-true}
XDEBUG_CONFIG: ${XDEBUG_CONFIG:-}
MAUTIC_MESSENGER_DSN_EMAIL: ${MAUTIC_MESSENGER_DSN_EMAIL:-doctrine://default}
MAUTIC_MESSENGER_DSN_HIT: ${MAUTIC_MESSENGER_DSN_HIT:-doctrine://default}

services:
mautic_web:
image: ghcr.io/librecodecoop/mautic:${MAUTIC_VERSION:-5.x-dev}-${IMAGE_TYPE:-apache}
image: ghcr.io/librecodecoop/mautic:${MAUTIC_VERSION:-7.x-dev}-${IMAGE_TYPE:-apache}
# build:
# context: .docker/
# dockerfile: Dockerfile.${IMAGE_TYPE:-apache}
Expand All @@ -37,7 +49,7 @@ services:
retries: 100

mautic_cron:
image: ghcr.io/librecodecoop/mautic:${MAUTIC_VERSION:-5.x-dev}-${IMAGE_TYPE:-apache}
image: ghcr.io/librecodecoop/mautic:${MAUTIC_VERSION:-7.x-dev}-${IMAGE_TYPE:-apache}
# build:
# context: .docker/
# dockerfile: Dockerfile.${IMAGE_TYPE:-apache}
Expand All @@ -51,7 +63,7 @@ services:
condition: service_healthy

mautic_worker:
image: ghcr.io/librecodecoop/mautic:${MAUTIC_VERSION:-5.x-dev}-${IMAGE_TYPE:-apache}
image: ghcr.io/librecodecoop/mautic:${MAUTIC_VERSION:-7.x-dev}-${IMAGE_TYPE:-apache}
# build:
# context: .docker/
# dockerfile: Dockerfile.${IMAGE_TYPE:-apache}
Expand Down
1 change: 1 addition & 0 deletions volumes/mautic/docroot/plugins/MauticCrmBundle
Submodule MauticCrmBundle added at 7d68d7
Loading