Skip to content

Instantly share code, notes, and snippets.

@jordan8037310
Last active January 12, 2021 22:58
Show Gist options
  • Save jordan8037310/43214cff2ab3117592d0aafa1bc55cc0 to your computer and use it in GitHub Desktop.
Save jordan8037310/43214cff2ab3117592d0aafa1bc55cc0 to your computer and use it in GitHub Desktop.
Mautic LEMP Lando
name: mautic
recipe: lemp
config:
webroot: mautic
php: '7.2'
composer_version: '1.10.19'
database: mysql:5.7
xdebug: false
config:
vhosts: nginx-lando.conf
php: php7-fpm/php.ini
# Copy from .env.lando.dist to .env
env_file:
- .env
# Set a reachable management site ( User: guest, Pass: guest )
proxy:
rabbitmq:
- rabbit.lndo.site:15672
services:
# Mautic Appserver
appserver:
build:
- "composer -V"
- "composer global require hirak/prestissimo"
- "cd /app && rm -rf vendor/*"
- "cd /app && rm -rf bin/*"
- "cd /app && rm -rf mautic && mkdir mautic"
- "cd /app && composer install"
- "ln -s /logs /app/mautic/app/logs"
- "ln -s /cache /app/mautic/app/cache"
overrides:
environment:
PHP_IDE_CONFIG: "serverName=mautic.lndo.site"
# Other Environment variables included via .env
volumes:
- ./lando/cache:/cache
- ./lando/media:/mnt/media
- ./lando/logs:/logs
- ./lando/spool:/mnt/spool
- ./db-init:/tmp/db-init
build_as_root:
# - cd / && mkdir cache && chown -R www-data:dialout /cache && chmod -R g+rwX /cache
# - cd / && mkdir logs && chown -R www-data:dialout /logs && chmod -R g+rwX /logs
- apt-get update -y
- apt-get install -y libmcrypt-dev
- apt-get install -y zlib1g-dev
- apt-get install -y libwebp-dev
- apt-get install -y libjpeg62-turbo-dev
- apt-get install -y libpng-dev
- apt-get install -y libxpm-dev
- apt-get install -y libfreetype6-dev
- printf "\n" | pecl install mcrypt-1.0.1
# - pecl install mcrypt-1.0.1 -y
# - docker-php-ext-enable imap pdo pdo_mysql mcrypt bcmath zip redis
- docker-php-ext-configure gd --with-gd --with-webp-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-xpm-dir --with-freetype-dir
- docker-php-ext-install gd
database:
overrides:
volumes:
- ./db-init:/tmp/db-init
build_as_root:
- apt-get update -y
- apt-get install -y pv
# Setup RabbitMQ service using "compose"
rabbitmq:
type: compose
services:
# Grab RabbitMQ management image
image: "rabbitmq:3-management"
hostname: "rabbit"
# Start the server for RabbitMQ
command: rabbitmq-server
# Expose RabbitMQ Ports
ports:
- '15672:15672'
- '5672:5672'
# Link RabbitMQ Configs
volumes:
- rabbitmq-isolated.conf:/etc/rabbitmq/rabbitmq.config
labels:
NAME: "rabbitmq"
# Redis is used in order to store PHP Sessions
redis:
type: redis:5
persist: false
portforward: false
tooling:
php:
service: appserver
cmd: php
composer-build:
service: appserver
cmd:
- appserver: rm -rf ./mautic/vendor/* ./mautic/bin/*
- appserver: rm -rf ./mautic/*
- appserver: cd /app && composer install
- appserver: echo 'deny from all' > ./mautic/vendor/.htaccess
- appserver: rm -rf /cache/*
- appserver: php /app/mautic/app/console cache:clear --no-interaction --no-warmup -vvv --env=dev
cache-clear:
service: appserver
cmd:
- appserver: rm -rf /cache/*
- appserver: php /app/mautic/app/console cache:clear --no-interaction --no-warmup -vvv --env=dev
cache-warm:
service: appserver
cmd: php /app/mautic/app/console cache:warm --no-interaction --env=dev
post-mautic-update:
sevice: appserver
cmd:
- appserver: php /app/mautic/app/console doctrine:migrations:migrate --no-interaction
- appserver: php /app/mautic/app/console mautic:iplookup:download
cron-segment-update:
description: Firing typical Mautic cron tasks for local testing.
service: appserver
cmd: php /app/mautic/app/console mautic:segments:update --env=dev
cron-campaigns-rebuild:
descrption: To keep campaigns updated with applicable contacts.
service: appserver
cmd: php /app/mautic/app/console mautic:campaigns:rebuild --env=dev
cron-campaigns-update:
description: Update campaigns.
service: appserver
cmd: php /app/mautic/app/console mautic:campaigns:update --env=dev
cron-campaigns-trigger:
description: To execute campaigns events.
service: appserver
cmd: php /app/mautic/app/console mautic:campaigns:trigger --env=dev
cron-messages-send:
description: To send frequency rules rescheduled marketing campaign messages.
service: appserver
cmd: php /app/mautic/app/console mautic:messages:send --env=dev
cron-emails-send:
description: Process Email Queue
service: appserver
cmd: php /app/mautic/app/console mautic:emails:send --time-limit 60 --env=dev
cron-email-fetch:
description: Fetch and process Monitored Email.
service: appserver
cmd: php /app/mautic/app/console mautic:email:fetch --env=dev
cron-hubspot-push:
description: Push HubSpot Activity to Lead Contacts.
service: appserver
cmd: php /app/mautic/app/console mautic:integration:pushleadactivity --integration=Hubspot --env=dev
cron-hubspot-fetch:
description: Fetch HubSpot Contacts.
service: appserver
cmd: php /app/mautic/app/console mautic:integration:fetchleads --integration=Hubspot --env=dev
cron-webhook:
description: Send webhook payloads.
service: appserver
cmd: php /app/mautic/app/console mautic:webhooks:process --env=dev
phpunit:
service: appserver
cmd: /app/mautic/bin/phpunit
test:
service: appserver
description: Run Tests Locally
cmd:
- appserver: php /app/mautic/app/console doctrine:database:drop --force --no-interaction --env=test
- appserver: php /app/mautic/app/console doctrine:database:create --no-interaction --env=test
- appserver: php /app/mautic/app/console mautic:install:data --force --env=test
- appserver: php /app/mautic/app/console doctrine:migrations:version --add --all --no-interaction --env=test
- appserver: php /app/mautic/app/console cache:clear --no-interaction --no-warmup -vvv
- appserver: cd /app/mautic && /app/mautic/bin/codecept run --env=test
# @TODO - Use the following command as an alias of root composer testing
# - appserver: composer test
# Set up command "Lando rabbit" for basic RabbitMQ commands
rabbit:
service: rabbitmq
# User must be root to prevent erlang cookie error
user: root
cmd: rabbitmqctl
# Setup command "lando rabbit-ip" to get the ip address
rabbit-ip:
service: rabbitmq
cmd:
- rabbitmq: echo -e "\n\e[36mRABBITMQ IP ADDRESS:\e[32m"
- rabbitmq: hostname -i | cut -d' ' -f1
# Development Tools
reset-admin-pw:
service: database
cmd: /app/scripts/reset_admin_password.sh
pull-live-db:
service: database
cmd: /app/scripts/pull_live_db.sh
events:
# Shows IP address on 'lando start'
post-start:
- rabbitmq: echo -e "\n\e[36mRABBITMQ IP ADDRESS:\e[32m"
- rabbitmq: hostname -i | cut -d' ' -f1
post-db-import:
- database: /app/scripts/reset_admin_password.sh
- appserver: rm -rf /cache/* && echo "Clearing cache."
- appserver: php /app/mautic/app/console doctrine:migrations:migrate --no-interaction && echo "Running doctrine migrations."
- appserver: php /app/mautic/app/console cache:clear --no-interaction --no-warmup -vvv && echo "Warming cache."
# @TODO - before running tests locally take a backup of the working database as a snapshot
# pre-test:
# - database:
server {
# Copied Server Configuration from Lando
# ref: https://github.com/lando/lando/edit/master/plugins/lando-recipes/recipes/drupal8/default.conf.tpl
listen 80 default_server;
listen 443 ssl;
server_name localhost;
ssl_certificate /certs/cert.crt;
ssl_certificate_key /certs/cert.key;
ssl_verify_client off;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
port_in_redirect off;
client_max_body_size 100M;
root "{{LANDO_WEBROOT}}";
#############################################
# Symfony.conf Mautic Parity for K8s builds
#############################################
rewrite ^/(vendor|translations|build)/.* /index.php break;
# @TODO - Rewrite the index.php to remove it from the path
# redirect index.php to root
# rewrite ^/index.php/(.*) /$1 permanent;
location / {
try_files $uri /index.php$is_args$args;
}
# Deny everything else in /app folder except Assets folder in bundles
location ~ /app/bundles/.*/Assets/ {
allow all;
access_log off;
}
location ~ /app/ { deny all; }
# Deny everything else in /addons or /plugins folder except Assets folder in bundles
location ~ /(addons|plugins)/.*/Assets/ {
allow all;
access_log off;
}
# Deny all php files in themes folder
location ~* ^/themes/(.*)\.php {
deny all;
}
# Don't log favicon
location = /favicon.ico {
log_not_found off;
access_log off;
}
# Don't log robots
location = /robots.txt {
access_log off;
log_not_found off;
}
# Deny yml, twig, markdown, init file access
location ~* /(.*)\.(?:markdown|md|twig|yaml|yml|ht|htaccess|ini)$ {
deny all;
access_log off;
log_not_found off;
}
# Deny all attempts to access hidden files/folders such as .htaccess, .htpasswd, .DS_Store (Mac), etc...
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
# Deny all grunt, composer files
location ~* (Gruntfile|package|composer)\.(js|json|lock)$ {
deny all;
access_log off;
log_not_found off;
}
# Deny index_dev.php
location ~* (index_dev)\.php$ {
deny all;
access_log off;
log_not_found off;
}
# Deny all upgrade paths
location ~* (upgrade|upgrade_v3)\.php$ {
deny all;
access_log off;
log_not_found off;
}
# This section slightly differs from symfony.conf
location ~ ^/(index|server)\.php(/|$) {
#index index.php
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
include fastcgi.conf;
#try_files $uri = 404;
#fastcgi_index index.php;
# Block httpoxy attacks. See https://httpoxy.org/.
fastcgi_param HTTP_PROXY "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param PATH_INFO $fastcgi_path_info;
#fastcgi_param QUERY_STRING $query_string;
fastcgi_intercept_errors on;
# lando
fastcgi_pass fpm:9000;
# fastcgi_param HTTPS off;
}
}
; Cloudflare upload limits are at 100M by default, support that level for heavy CSV imports primarily.
post_max_size = 100M
upload_max_filesize = 100M
; Session lifespan of 3 hours.
session.gc_maxlifetime = 10800
;; extension=redis.so
cgi.fix_pathinfo = 0;
[opcache]
opcache.enable = On
opcache.enable_cli = On
opcache.file_cache = "/tmp/opcache"
opcache.validate_timestamps = On
opcache.revalidate_freq = 300
opcache.memory_consumption = 256
; Cloudflare will timeout at 60 seconds, this limit will be automatically superseded by Mautic as needed.
max_execution_time = 60
; Rather high limit for Mautic in production.
memory_limit = 512M
; Disable functions that could be dangerous to this application in K8s.
disable_functions = exec,system,passthru,shell_exec
[apc]
; APCu-BC no longer needed.
apc.enabled = On
apc.enable_cli = On
apc.shm_size = 256M
apc.writable = "/tmp/apc"
;; session.save_handler = redis
;; session.save_path = "tcp://${REDIS_HOST}:${REDIS_PORT}?auth=${REDIS_PASSWORD}"
;; session.save_path = "tcp://${REDIS_HOST}:${REDIS_PORT}"
; Limit Extensions
; Enable this on Lando for Local Development
security.limit_extensions =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment