diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template new file mode 100644 index 00000000..647129b4 --- /dev/null +++ b/Dockerfile-debian.template @@ -0,0 +1,83 @@ +FROM php:7.1-%%VARIANT%% + +LABEL vendor="Mautic" +LABEL maintainer="Luiz Eduardo Oliveira Fonseca " + +# 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%%"] diff --git a/apache/Dockerfile b/apache/Dockerfile index 2d8ed73f..8e834b95 100644 --- a/apache/Dockerfile +++ b/apache/Dockerfile @@ -4,27 +4,48 @@ LABEL vendor="Mautic" LABEL maintainer="Luiz Eduardo Oliveira Fonseca " # 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 @@ -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' \ @@ -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 diff --git a/fpm/Dockerfile b/fpm/Dockerfile index 82a4e3f3..9eb27131 100644 --- a/fpm/Dockerfile +++ b/fpm/Dockerfile @@ -4,27 +4,48 @@ LABEL vendor="Mautic" LABEL maintainer="Luiz Eduardo Oliveira Fonseca " # 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 @@ -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' \ @@ -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"] diff --git a/update.sh b/update.sh index 9ab283a6..630666e0 100755 --- a/update.sh +++ b/update.sh @@ -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