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

Use docker template file #97

Open
wants to merge 9 commits into
base: master
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
83 changes: 83 additions & 0 deletions Dockerfile-debian.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
FROM php:7.1-%%VARIANT%%

LABEL vendor="Mautic"
LABEL maintainer="Luiz Eduardo Oliveira Fonseca <[email protected]>"

# Install PHP extensions
RUN set -ex; \
apt-get update && apt-get install --no-install-recommends -y \
cron \
git \
wget \
sudo \
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/*; \
docker-php-ext-configure imap --with-imap --with-imap-ssl --with-kerberos; \
docker-php-ext-configure opcache --enable-opcache; \
docker-php-ext-install \
imap \
intl \
mbstring \
mcrypt \
mysqli \
pdo_mysql \
zip \
opcache \
bcmath \
; \
docker-php-ext-enable \
imap \
intl \
mbstring \
mcrypt \
mysqli \
pdo_mysql \
zip \
opcache \
bcmath \
;

# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer

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

# Define Mautic version and expected SHA1 signature
ENV MAUTIC_VERSION=%%VERSION%% \
MAUTIC_SHA1=%%VERSION_SHA1%% \
MAUTIC_RUN_CRON_JOBS=true \
MAUTIC_DB_USER=root \
MAUTIC_DB_NAME=mautic

# Download package and extract to web volume
RUN set -ex; \
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 docker-entrypoint.sh /entrypoint.sh
COPY makeconfig.php makedb.php /
COPY mautic.crontab /etc/cron.d/mautic
COPY mautic-php.ini /usr/local/etc/php/conf.d/mautic-php.ini
%%VARIANT_EXTRAS%%

# Apply necessary permissions
RUN ["chmod", "+x", "/entrypoint.sh"]
ENTRYPOINT ["/entrypoint.sh"]

CMD ["%%CMD%%"]
93 changes: 55 additions & 38 deletions apache/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,48 @@ LABEL vendor="Mautic"
LABEL maintainer="Luiz Eduardo Oliveira Fonseca <[email protected]>"

# Install PHP extensions
RUN apt-get update && apt-get install --no-install-recommends -y \
cron \
git \
wget \
sudo \
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-configure opcache --enable-opcache \
&& docker-php-ext-install imap intl mbstring mcrypt mysqli pdo_mysql zip opcache bcmath\
&& docker-php-ext-enable imap intl mbstring mcrypt mysqli pdo_mysql zip opcache bcmath
RUN set -ex; \
apt-get update && apt-get install --no-install-recommends -y \
cron \
git \
wget \
sudo \
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/*; \
docker-php-ext-configure imap --with-imap --with-imap-ssl --with-kerberos; \
docker-php-ext-configure opcache --enable-opcache; \
docker-php-ext-install \
imap \
intl \
mbstring \
mcrypt \
mysqli \
pdo_mysql \
zip \
opcache \
bcmath \
; \
docker-php-ext-enable \
imap \
intl \
mbstring \
mcrypt \
mysqli \
pdo_mysql \
zip \
opcache \
bcmath \
;

# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
Expand All @@ -33,15 +54,11 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin -
VOLUME /var/www/html

# Define Mautic version and expected SHA1 signature
ENV MAUTIC_VERSION 2.15.2
ENV MAUTIC_SHA1 4452818b3a806b7eaac9fe507717564229da5fef

# 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
ENV MAUTIC_VERSION=2.15.2 \
MAUTIC_SHA1=4452818b3a806b7eaac9fe507717564229da5fef \
MAUTIC_RUN_CRON_JOBS=true \
MAUTIC_DB_USER=root \
MAUTIC_DB_NAME=mautic

# Setting PHP properties
ENV PHP_INI_DATE_TIMEZONE='UTC' \
Expand All @@ -50,17 +67,17 @@ ENV PHP_INI_DATE_TIMEZONE='UTC' \
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 set -ex; \
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 docker-entrypoint.sh /entrypoint.sh
COPY makeconfig.php /makeconfig.php
COPY makedb.php /makedb.php
COPY makeconfig.php makedb.php /
COPY mautic.crontab /etc/cron.d/mautic
RUN chmod 644 /etc/cron.d/mautic

Expand Down
94 changes: 56 additions & 38 deletions fpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,48 @@ LABEL vendor="Mautic"
LABEL maintainer="Luiz Eduardo Oliveira Fonseca <[email protected]>"

# Install PHP extensions
RUN apt-get update && apt-get install --no-install-recommends -y \
cron \
git \
wget \
sudo \
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-configure opcache --enable-opcache \
&& docker-php-ext-install imap intl mbstring mcrypt mysqli pdo_mysql zip opcache bcmath \
&& docker-php-ext-enable imap intl mbstring mcrypt mysqli pdo_mysql zip opcache bcmath
RUN set -ex; \
apt-get update && apt-get install --no-install-recommends -y \
cron \
git \
wget \
sudo \
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/*; \
docker-php-ext-configure imap --with-imap --with-imap-ssl --with-kerberos; \
docker-php-ext-configure opcache --enable-opcache; \
docker-php-ext-install \
imap \
intl \
mbstring \
mcrypt \
mysqli \
pdo_mysql \
zip \
opcache \
bcmath \
; \
docker-php-ext-enable \
imap \
intl \
mbstring \
mcrypt \
mysqli \
pdo_mysql \
zip \
opcache \
bcmath \
;

# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
Expand All @@ -33,15 +54,11 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin -
VOLUME /var/www/html

# Define Mautic version and expected SHA1 signature
ENV MAUTIC_VERSION 2.15.2
ENV MAUTIC_SHA1 4452818b3a806b7eaac9fe507717564229da5fef

# 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
ENV MAUTIC_VERSION=2.15.2 \
MAUTIC_SHA1=4452818b3a806b7eaac9fe507717564229da5fef \
MAUTIC_RUN_CRON_JOBS=true \
MAUTIC_DB_USER=root \
MAUTIC_DB_NAME=mautic

# Setting PHP properties
ENV PHP_INI_DATE_TIMEZONE='UTC' \
Expand All @@ -50,20 +67,21 @@ ENV PHP_INI_DATE_TIMEZONE='UTC' \
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 set -ex; \
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 docker-entrypoint.sh /entrypoint.sh
COPY makeconfig.php /makeconfig.php
COPY makedb.php /makedb.php
COPY makeconfig.php makedb.php /
COPY mautic.crontab /etc/cron.d/mautic
RUN chmod 644 /etc/cron.d/mautic


# Apply necessary permissions
RUN ["chmod", "+x", "/entrypoint.sh"]
ENTRYPOINT ["/entrypoint.sh"]
Expand Down
59 changes: 47 additions & 12 deletions update.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,59 @@
#!/bin/bash
set -e

current="$(curl https://api.github.com/repos/mautic/mautic/releases/latest -s | jq -r .name)"
declare -A cmd=(
[apache]='apache2-foreground'
[fpm]='php-fpm'
[fpm-alpine]='php-fpm'
)

declare -A extras=(
[apache]='\n# Enable Apache Rewrite Module\nRUN a2enmod rewrite'
[fpm]=''
[fpm-alpine]=''
)

declare -A base=(
[apache]='debian'
[fpm]='debian'
[fpm-alpine]='alpine'
)

variants=(
apache
fpm
)

echo "get current version"
current=$( curl -fsSL 'https://api.github.com/repos/mautic/mautic/tags' |tac|tac| \
grep -oE '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+' | \
sort -urV | \
head -n 1 )

# TODO - Expose SHA signatures for the packages somewhere
wget -O mautic.zip https://github.com/mautic/mautic/releases/download/$current/$current.zip
echo "get current SHA signature"
curl -o mautic.zip -SL https://github.com/mautic/mautic/releases/download/$current/$current.zip
sha1="$(sha1sum mautic.zip | sed -r 's/ .*//')"

for variant in apache fpm; do
(
set -x
echo "update docker images"
for variant in "${variants[@]}"; do
dir="$variant"
echo "generating $current-$variant"

template="Dockerfile-${base[$variant]}.template"
cp $template "$dir/Dockerfile"

sed -ri '
s/^(ENV MAUTIC_VERSION) .*/\1 '"$current"'/;
s/^(ENV MAUTIC_SHA1) .*/\1 '"$sha1"'/;
' "$variant/Dockerfile"
sed -E -i'' -e '
s/%%VARIANT%%/'"$variant"'/;
s/%%VARIANT_EXTRAS%%/'"${extras[$variant]}"'/;
s/%%VERSION%%/'"$current"'/;
s/%%VERSION_SHA1%%/'"$sha1"'/;
s/%%CMD%%/'"${cmd[$variant]}"'/;
' "$dir/Dockerfile"

# To make management easier, we use these files for all variants
cp common/* "$variant"/
)
# To make management easier, we use these files for all variants
cp common/* "$dir"/
done

echo "remove mautic.zip"
rm mautic.zip