Skip to content

Commit

Permalink
more wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mollux committed Jan 5, 2024
1 parent ecd3849 commit b9443fe
Show file tree
Hide file tree
Showing 17 changed files with 267 additions and 650 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ on:

env:
REGISTRY: ghcr.io
IMAGE_NAME: mollux/docker-mautic
IMAGE_NAME: mollux/docker-mautic #${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
strategy:
matrix:
mautic_version: [4.x-dev, 5.x-dev]
mautic_version: [5.x-dev]
image_type: [apache, fpm]
permissions:
contents: read
packages: write
Expand All @@ -33,10 +34,10 @@ jobs:
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
file: new_version/Dockerfile
file: ${{ matrix.image_type }}/Dockerfile
context: .
build-args: |
MAUTIC_VERSION=${{ matrix.mautic_version }}
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.mautic_version }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.mautic_version }}-${{ matrix.image_type }}
labels: ${{ steps.meta.outputs.labels }}
121 changes: 65 additions & 56 deletions apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
FROM php:7.4-apache
FROM php:8.1-apache as builder

LABEL vendor="Mautic"
LABEL maintainer="Mautic core team <>"

LABEL maintainer="Luiz Eduardo Oliveira Fonseca <luiz@powertic.com>"
# Define Mautic version by package tag
ARG MAUTIC_VERSION=5.x-dev

# Install PHP extensions
RUN apt-get update && apt-get install --no-install-recommends -y \
ca-certificates \
build-essential \
software-properties-common \
cron \
git \
htop \
wget \
dos2unix \
curl \
libcurl4-gnutls-dev \
sudo \
libc-client-dev \
libkrb5-dev \
libmcrypt-dev \
Expand All @@ -39,75 +35,88 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
libicu-dev \
libfreetype6-dev \
libonig-dev \
librabbitmq-dev \
unzip \
nano \
zip \
mariadb-client \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/* \
&& rm /etc/cron.daily/*
nodejs \
npm

RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl && \
docker-php-ext-install imap && \
docker-php-ext-enable imap
RUN curl -L -o /tmp/amqp.tar.gz "https://github.com/php-amqp/php-amqp/archive/refs/tags/v2.1.1.tar.gz" \
&& mkdir -p /usr/src/php/ext/amqp \
&& tar -C /usr/src/php/ext/amqp -zxvf /tmp/amqp.tar.gz --strip 1 \
&& rm /tmp/amqp.tar.gz

RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install gd \
&& docker-php-ext-configure imap --with-kerberos --with-imap-ssl \
&& docker-php-ext-configure opcache --enable-opcache \
&& docker-php-ext-install intl mbstring mysqli curl pdo_mysql zip opcache bcmath gd sockets exif \
&& docker-php-ext-enable intl mbstring mysqli curl pdo_mysql zip opcache bcmath gd sockets exif
&& docker-php-ext-install intl mbstring mysqli curl pdo_mysql zip bcmath sockets exif amqp gd imap opcache \
&& docker-php-ext-enable intl mbstring mysqli curl pdo_mysql zip bcmath sockets exif amqp gd imap opcache

# 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
RUN echo "memory_limit = -1" > /usr/local/etc/php/php.ini

# Define Mautic version and expected SHA1 signature
ENV MAUTIC_VERSION 4.4.9
ENV MAUTIC_SHA1 1f7d5461f40e7e023b022d31be73fbd11804b09b
RUN cd /opt && \
composer create-project mautic/recommended-project:${MAUTIC_VERSION} mautic --no-interaction && \
rm -rf /opt/mautic/var/cache/js && \
find /opt/mautic/node_modules -mindepth 1 -maxdepth 1 -not \( -name 'jquery' -or -name 'vimeo-froogaloop2' \) | xargs rm -rf

# By default enable cron jobs
ENV MAUTIC_RUN_CRON_JOBS true
FROM php:8.1-apache

# By default disable automatic migrations
ENV MAUTIC_RUN_MIGRATIONS false
COPY --from=builder /usr/local/lib/php/extensions /usr/local/lib/php/extensions
COPY --from=builder /usr/local/etc/php/conf.d/ /usr/local/etc/php/conf.d/

# Setting an Default database user for Mysql
ENV MAUTIC_DB_USER root
COPY --from=builder --chown=www-data:www-data /opt/mautic /var/www/html

# Setting an Default database name for Mysql
ENV MAUTIC_DB_NAME mautic

# Set up mysql port
ENV MAUTIC_DB_PORT 3306
# Install PHP extensions requirements and other dependencies
RUN apt-get update && apt-get install --no-install-recommends -y \
unzip libwebp-dev libzip-dev libfreetype6-dev libjpeg62-turbo-dev libpng-dev libc-client-dev librabbitmq4 \
mariadb-client supervisor cron \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/* \
&& rm /etc/cron.daily/*

# 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

# Copy init scripts and custom .htaccess
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
ENV PHP_INI_VALUE_DATE_TIMEZONE='UTC' \
PHP_INI_VALUE_MEMORY_LIMIT=512M \
PHP_INI_VALUE_UPLOAD_MAX_FILESIZE=512M \
PHP_INI_VALUE_POST_MAX_FILESIZE=512M \
PHP_INI_VALUE_MAX_EXECUTION_TIME=300

COPY ./common/php.ini /usr/local/etc/php/php.ini

ENV APACHE_DOCUMENT_ROOT=/var/www/html/docroot

RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf

# Enable Apache Rewrite Module
RUN a2enmod rewrite

COPY ./common/docker-entrypoint.sh /entrypoint.sh
COPY ./common/entrypoint_mautic_web.sh /entrypoint_mautic_web.sh
COPY ./common/entrypoint_mautic_cron.sh /entrypoint_mautic_cron.sh
COPY ./common/entrypoint_mautic_worker.sh /entrypoint_mautic_worker.sh

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

# Setting worker env vars
ENV MAUTIC_WORKERS_CONSUME_EMAIL=2 \
MAUTIC_WORKERS_CONSUME_HIT=2 \
MAUTIC_WORKERS_CONSUME_FAILED=2

COPY ./common/supervisord.conf /etc/supervisor/conf.d/supervisord.conf

# Define Mautic volumes to persist data
VOLUME /var/www/html/config
VOLUME /var/www/html/var/logs
VOLUME /var/www/html/docroot/media

WORKDIR /var/www/html/docroot

ENV MAUTIC_ROLE=mautic_web

ENTRYPOINT ["/entrypoint.sh"]

CMD ["apache2-foreground"]
Loading

0 comments on commit b9443fe

Please sign in to comment.