Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mautic 4 stateless container #198

Open
wants to merge 9 commits into
base: mautic4
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ jobs:
- name: Build ${{ matrix.image }} image
uses: docker/build-push-action@v2
with:
context: ${{ matrix.image }}
file: ${{ matrix.image }}/Dockerfile
push: false
tags: mautic/mautic:v4-${{ matrix.image }}
39 changes: 36 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,20 @@ Setting Up Mautic:
-e MAUTIC_RUN_CRON_JOBS=true \
-p 8080:80 \
--net=mauticnet \
-v mautic_data:/var/www/html \
-v mautic_data:/data \
mautic/mautic:v3

This will run a basic Mautic on http://localhost:8080.

## Building your own containers

You can build your own containers easily using the docker build command in the root of this directory:

```
docker build . -f apache/Dockerfile -t mautic/mautic:v4-apache
docker build . -f fpm/Dockerfile -t mautic/mautic:v4-fpm
```

## Customizing Mautic Container

The following environment variables are also honored for configuring your Mautic instance:
Expand All @@ -102,6 +111,7 @@ If the `MAUTIC_DB_NAME` specified does not already exist on the given MySQL serv
### Mautic Options

- `-e MAUTIC_RUN_CRON_JOBS=...` (defaults to true - enabled) If set to true runs mautic cron jobs using included cron daemon
- `-e MAUTIC_RUN_MIGRATIONS=...` (defaults to false - disabled) If set to true runs database migrations automatically on startup.
- `-e MAUTIC_TRUSTED_PROXIES=...` (defaults to empty) If Mautic sits behind a reverse proxy, you can set a json array of CIDR network addresses here, and mautic will set those addresses as trusted proxies. You can use `["0.0.0.0/0"]` or See [documentation](http://symfony.com/doc/current/request/load_balancer_reverse_proxy.html)
- `-e MAUTIC_CRON_HUBSPOT=...` (defaults to empty) Enables mautic crons for Hubspot CRM integration
- `-e MAUTIC_CRON_SALESFORCE=...` (defaults to empty) Enables mautic crons for Salesforce integration
Expand All @@ -126,7 +136,7 @@ If the `MAUTIC_DB_NAME` specified does not already exist on the given MySQL serv

### Persistent Data Volumes

On first run Mautic is unpacked at `/var/www/html`. You need to attach a volume on this path to persist data.
Mautic stores the data needed to persisit at `/data` - You need to attach a volume to this path to persist data.

### Mautic Versioning

Expand All @@ -135,6 +145,29 @@ Mautic Docker has two ENV that you can specify an version do start your new cont
- `-e MAUTIC_VERSION` (Defaults to "3.0.0")
- `-e MAUTIC_SHA1` (Defalts to "ed4287367b8484aa146a1fa904b261ab30d9c6e7")

### Automated installation

If you wish your mautic instance to automatically run the installer when the container
is first started, provide the following environment variables:

- `-e MAUTIC_URL` The URL at which your mautic instance will be accessed
- `-e MAUTIC_ADMIN_EMAIL` The email address of your initial admin user
- `-e MAUTIC_ADMIN_PASSWORD` The password of your initial admin user

You can also optionally provide other installation variables:

- `-e MAUTIC_INSTALL_FORCE` If the URL used above is HTTP instead of HTTPS,
automated installation will fail. Set to true to allow this.
- `-e MAUTIC_ADMIN_USERNAME` The username of your initial admin user
- `-e MAUTIC_ADMIN_FIRSTNAME` The first name of your initial admin user
- `-e MAUTIC_ADMIN_LASTNAME` The last name of your initial admin user

### Mautic configuration

Additional configuration variables can be added to mautic's local config by prepending them with `MAUTIC_CONFIG_`. This will be re-applied every time the container is re-started, so can be used for external config management of mautic instances.

- `-e MAUTIC_CONFIG_DEBUG=1` Set debug=1 in `local.php`

## Accesing the Instance

Access your new Mautic on `http://localhost:8080` or `http://host-ip:8080` in a browser.
Expand Down Expand Up @@ -169,7 +202,7 @@ services:
container_name: mautic
image: mautic/mautic:v4-apache
volumes:
- mautic_data:/var/www/html
- mautic_data:/data
environment:
- MAUTIC_DB_HOST=database
- MAUTIC_DB_USER=root
Expand Down
33 changes: 22 additions & 11 deletions apache/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer

# Define Mautic volume to persist data
VOLUME /var/www/html
VOLUME /data

# Define Mautic version and expected SHA1 signature
ENV MAUTIC_VERSION 4.0.0-rc
Expand All @@ -70,31 +70,42 @@ ENV MAUTIC_SHA1 ded92ab7403f3c5c5ef0844b0933e0965502d7a5
# By default enable cron jobs
ENV MAUTIC_RUN_CRON_JOBS true

# By default disable automatic migrations
ENV MAUTIC_RUN_MIGRATIONS false

# Setting an Default database user for Mysql
ENV MAUTIC_DB_USER root

# Setting an Default database name for Mysql
ENV MAUTIC_DB_NAME mautic

# Set up mysql port
ENV MAUTIC_DB_PORT 3306

# Setting PHP properties
ENV PHP_INI_DATE_TIMEZONE='UTC' \
PHP_MEMORY_LIMIT=512M \
PHP_MAX_UPLOAD=512M \
PHP_MAX_EXECUTION_TIME=300

# Download package and extract to web volume
RUN curl -o mautic.zip -SL https://github.com/mautic/mautic/releases/download/${MAUTIC_VERSION}/${MAUTIC_VERSION}.zip \
&& echo "$MAUTIC_SHA1 *mautic.zip" | sha1sum -c - \
&& mkdir /usr/src/mautic \
&& unzip mautic.zip -d /usr/src/mautic \
&& rm mautic.zip \
&& chown -R www-data:www-data /usr/src/mautic
RUN curl -o /tmp/mautic.zip -SL https://github.com/mautic/mautic/releases/download/${MAUTIC_VERSION}/${MAUTIC_VERSION}.zip \
&& echo "$MAUTIC_SHA1 */tmp/mautic.zip" | sha1sum -c - \
&& rm -rf /var/www/html \
&& mkdir /var/www/html \
&& unzip /tmp/mautic.zip -d /var/www/html \
&& rm /tmp/mautic.zip \
&& chown -R www-data:www-data /var/www/html

# Drop in redirectors to volume
COPY common/paths_local.php /var/www/html/app/config/paths_local.php
COPY common/parameters_local.php /var/www/html/app/config/parameters_local.php

# Copy init scripts and custom .htaccess
COPY docker-entrypoint.sh /entrypoint.sh
COPY makeconfig.php /makeconfig.php
COPY makedb.php /makedb.php
COPY mautic.crontab /etc/cron.d/mautic
COPY common/docker-entrypoint.sh /entrypoint.sh
COPY common/makeconfig.php /makeconfig.php
COPY common/makedb.php /makedb.php
COPY common/mautic.crontab /etc/cron.d/mautic
RUN chmod 644 /etc/cron.d/mautic

# Enable Apache Rewrite Module
Expand Down
157 changes: 0 additions & 157 deletions apache/docker-entrypoint.sh

This file was deleted.

49 changes: 0 additions & 49 deletions apache/makeconfig.php

This file was deleted.

Loading