Commit 6bd27739 authored by Tim's avatar Tim
Browse files

Initial commit

parents
Pipeline #90 failed with stages
FROM php:7.1-fpm
# Install PHP extensions
RUN apt-get update && apt-get install --no-install-recommends -y \
cron \
git \
wget \
libc-client-dev \
libicu-dev \
libkrb5-dev \
libmcrypt-dev \
libssl-dev \
libz-dev \
unzip \
zip \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/* \
&& rm /etc/cron.daily/*
RUN docker-php-ext-configure imap --with-imap --with-imap-ssl --with-kerberos \
&& docker-php-ext-install imap intl mbstring mcrypt mysqli pdo_mysql zip \
&& docker-php-ext-enable imap intl mbstring mcrypt mysqli pdo_mysql zip
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
# Define Mautic version and expected SHA1 signature
ENV MAUTIC_VERSION 2.15.0
ENV MAUTIC_SHA1 b07bd42bb092cc96785d2541b33700b55f74ece7
# By default enable cron jobs
ENV MAUTIC_RUN_CRON_JOBS true
# Setting an root user for test
ENV MAUTIC_DB_USER root
ENV MAUTIC_DB_NAME mautic
# 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
# Copy init scripts and custom .htaccess
COPY makeconfig.php /makeconfig.php
COPY makedb.php /makedb.php
COPY mautic.crontab /etc/cron.d/mautic
COPY mautic-php.ini /usr/local/etc/php/conf.d/mautic-php.ini
COPY paths_local.php /usr/src/mautic/app/config/
COPY parameters_local.php /usr/src/mautic/app/config/
COPY local.php /usr/src/mautic/app/config/
RUN chown -R www-data:www-data /usr/src/mautic
# RUN chown -R www-data:www-data /data
# Put all Mautic instance config files into one directory
# RUN mkdir -p /data/cache/prod
# RUN mkdir -p /data/config
# RUN mkdir -p /data/themes /data/idp /data/media/files /data/media/images /data/plugins
RUN mkdir -p /var/log/mautic && \
chown www-data:www-data /var/log/mautic
COPY entrypoint.sh /entrypoint.sh
RUN ["chmod", "+x", "/entrypoint.sh"]
WORKDIR /usr/src/mautic
# Apply necessary permissions
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]
#!/bin/sh
set -eu
# version_greater A B returns whether A > B
version_greater() {
[ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 -k3,3 | head -n 1)" != "$1" ]
}
image_version="${MAUTIC_VERSION}"
if [ -f /data/config/version ]; then
installed_version="$(awk '$1' /data/config/version)"
if version_greater "$installed_version" "$image_version"; then
echo "Can't start Mautic because the version of the data ($installed_version) is higher than the docker image version ($image_version) and downgrading is not supported. Are you sure you have pulled the newest image version?"
exit 1
fi
if version_greater "$image_version" "$installed_version"; then
echo "Upgrading mautic from $installed_version ..."
php /usr/src/mautic/app/console mautic:update:apply --no-interaction
echo ${MAUTIC_VERSION} > /data/config/version
else
echo "Initializing mautic $image_version ..."
fi
else
echo "New mautic instance"
echo "starting mautic installation"
echo "Creating folder structure, you should mount /data as a volume if you want to persist your install"
mkdir -p /data/cache/prod /data/config /data/themes /data/idp /data/media/files /data/media/images /data/plugins
php /makedb.php "$MAUTIC_DB_HOST" "$MAUTIC_DB_USER" "$MAUTIC_DB_PASSWORD" "$MAUTIC_DB_NAME"
php /usr/src/mautic/app/console mautic:install:data --no-interaction --force
echo ${MAUTIC_VERSION} > /data/config/version
chown -R www-data:www-data /data
fi
exec "$@"
<?php
$parameters = array(
'db_driver' => 'pdo_mysql',
'install_source' => 'Docker',
'db_host' => getenv('MAUTIC_DB_HOST') ?: "mysql",
'db_name' => getenv('MAUTIC_DB_NAME') ?: "mautic",
'db_user' => getenv('MAUTIC_DB_USER') ?: "mautic",
'db_password' => getenv('MAUTIC_DB_PASSWORD'),
'trusted_proxies' => array(
'0' => getenv('MAUTIC_TRUSTED_PROXIES'),
),
'db_table_prefix' => getenv('MAUTIC_DB_TABLES_PREFIX') ?: null,
'db_port' => getenv('MAUTIC_DB_USER') ?: 3306,
'db_backup_tables' => getenv('MAUTIC_DB_BACKUP_TABLES') ?: 1,
'db_backup_prefix' => getenv('MAUTIC_DB_MAUTIC_BACKUP_PREFIX') ?: "bak_",
'db_server_version' => getenv('MAUTIC_DB_VERSION'),
'mailer_from_name' => getenv('MAILER_FROM_NAME'),
'mailer_from_email' => getenv('MAILER_FROM_EMAIL'),
'mailer_transport' => getenv('MAILER_TRANSPORT') ?: "mail",
'mailer_host' => getenv('MAILER_HOST'),
'mailer_port' => getenv('MAILER_PORT'),
'mailer_user' => getenv('MAILER_USER'),
'mailer_password' => getenv('MAILER_PASSWORD'),
'mailer_encryption' => getenv('MAILER_ENCRYPTION'),
'mailer_auth_mode' => getenv('MAILER_AUTH_MODE'),
'mailer_spool_type' => getenv('MAILER_SPOOL_TYPE') ?: 'memory',
'mailer_spool_path' => getenv('MAILER_SPOOL_PATH') ?: '%kernel.root_dir%/spool',
'secret_key' => getenv('SECRET_KEY'),
'site_url' => getenv('MAUTIC_URL'),
);
<?php
$stderr = fopen('php://stderr', 'w');
fwrite($stderr, "\nWriting initial Mautic config\n");
$parameters = array(
'db_driver' => 'pdo_mysql',
'install_source' => 'Docker'
);
if(array_key_exists('MAUTIC_DB_HOST', $_ENV)) {
// Figure out if we have a port in the database host string
if (strpos($_ENV['MAUTIC_DB_HOST'], ':') !== false) {
list($host, $port) = explode(':', $_ENV['MAUTIC_DB_HOST'], 2);
$parameters['db_port'] = $port;
}
else {
$host = $_ENV['MAUTIC_DB_HOST'];
}
$parameters['db_host'] = $host;
}
if(array_key_exists('MAUTIC_DB_NAME', $_ENV)) {
$parameters['db_name'] = $_ENV['MAUTIC_DB_NAME'];
}
if(array_key_exists('MAUTIC_DB_USER', $_ENV)) {
$parameters['db_user'] = $_ENV['MAUTIC_DB_USER'];
}
if(array_key_exists('MAUTIC_DB_PASSWORD', $_ENV)) {
$parameters['db_password'] = $_ENV['MAUTIC_DB_PASSWORD'];
}
if(array_key_exists('MAUTIC_TRUSTED_PROXIES', $_ENV)) {
$proxies = explode(',', $_ENV['MAUTIC_TRUSTED_PROXIES']);
$parameters['trusted_proxies'] = $proxies;
}
$path = '/var/www/html/app/config/local.php';
$rendered = "<?php\n\$parameters = ".var_export($parameters, true).";\n";
$status = file_put_contents($path, $rendered);
if ($status === false) {
fwrite($stderr, "\nCould not write configuration file to $path, you can create this file with the following contents:\n\n$rendered\n");
}
<?php
// Args: 0 => makedb.php, 1 => "$MAUTIC_DB_HOST", 2 => "$MAUTIC_DB_USER", 3 => "$MAUTIC_DB_PASSWORD", 4 => "$MAUTIC_DB_NAME"
$stderr = fopen('php://stderr', 'w');
fwrite($stderr, "\nEnsuring Mautic database is present\n");
if (strpos($argv[1], ':') !== false)
{
list($host, $port) = explode(':', $argv[1], 2);
}
else
{
$host = $argv[1];
$port = 3306;
}
$maxTries = 10;
do
{
$mysql = new mysqli($host, $argv[2], $argv[3], '', (int) $port);
if ($mysql->connect_error)
{
fwrite($stderr, "\nMySQL Connection Error: ({$mysql->connect_errno}) {$mysql->connect_error}\n");
--$maxTries;
if ($maxTries <= 0)
{
exit(1);
}
sleep(3);
}
}
while ($mysql->connect_error);
if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($argv[4]) . '`'))
{
fwrite($stderr, "\nMySQL 'CREATE DATABASE' Error: " . $mysql->error . "\n");
$mysql->close();
exit(1);
}
fwrite($stderr, "\nMySQL Database Created\n");
$mysql->close();
always_populate_raw_post_data = -1
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
8,23,38,52 * * * * www-data php /var/www/html/app/console mautic:segments:update > /var/log/cron.pipe 2>&1
*/5 * * * * www-data php /var/www/html/app/console mautic:import > /var/log/cron.pipe 2>&1
5,20,35,50 * * * * www-data php /var/www/html/app/console mautic:campaigns:rebuild > /var/log/cron.pipe 2>&1
2,17,32,47 * * * * www-data php /var/www/html/app/console mautic:campaigns:trigger > /var/log/cron.pipe 2>&1
0,15,30,45 * * * * www-data php /var/www/html/app/console mautic:messages:send > /var/log/cron.pipe 2>&1
0,15,30,45 * * * * www-data php /var/www/html/app/console mautic:emails:send > /var/log/cron.pipe 2>&1
0,15,30,45 * * * * www-data php /var/www/html/app/console mautic:email:fetch > /var/log/cron.pipe 2>&1
0,15,30,45 * * * * www-data php /var/www/html/app/console mautic:social:monitoring > /var/log/cron.pipe 2>&1
0,15,30,45 * * * * www-data php /var/www/html/app/console mautic:webhooks:process > /var/log/cron.pipe 2>&1
0,15,30,45 * * * * www-data php /var/www/html/app/console mautic:broadcasts:send > /var/log/cron.pipe 2>&1
* 1 * * * www-data php /var/www/html/app/console mautic:maintenance:cleanup --days-old=365 > /var/log/cron.pipe 2>&1
0 4 15 * * www-data php /var/www/html/app/console mautic:iplookup:download > /var/log/cron.pipe 2>&1
*/5 * * * * www-data php /var/www/html/app/console mautic:reports:scheduler > /var/log/cron.pipe 2>&1
# download geoip db on start if it does not exist
@reboot www-data [[ "$(ls -A /var/www/html/app/cache/ip_data 2>/dev/null)" ]] || php /var/www/html/app/console mautic:iplookup:download > /var/log/cron.pipe 2>&1
<?php
$parameters = array(
'debug' => true,
'log_path' => '/var/log/mautic',
'image_path' => '/media/images',
'upload_dir' => '/data/media/files',
'mailer_spool_path' => '/data/spool',
'cache_path' => '/data/cache'
);
<?php
$paths['local_config'] = '/usr/src/mautic/app/config/local.php';
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment