-
-
Notifications
You must be signed in to change notification settings - Fork 344
Expand file tree
/
Copy pathDockerfile
More file actions
154 lines (122 loc) · 5.08 KB
/
Dockerfile
File metadata and controls
154 lines (122 loc) · 5.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# Define base image verison
ARG BASE_TAG=8.3-apache-bookworm
FROM php:${BASE_TAG} AS builder
# Copy everything from common for building
COPY ./common/ /common/
# Install dependencies
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install --no-install-recommends -y \
build-essential \
ca-certificates \
curl \
git \
unzip \
&& curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g npm@latest
# PHP extensions install script
ARG IPE_VERSION=2.9.28
ARG IPE_SHA256=2f5970453effac47cfcceafd6103948d78b566c2fb922a8ff639fe249db74aa7
RUN curl -fsSL \
https://github.com/mlocati/docker-php-extension-installer/releases/download/${IPE_VERSION}/install-php-extensions \
-o /usr/local/bin/install-php-extensions && \
echo "${IPE_SHA256} /usr/local/bin/install-php-extensions" | sha256sum -c - && \
chmod +x /usr/local/bin/install-php-extensions
RUN install-php-extensions 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
RUN echo "memory_limit = -1" > /usr/local/etc/php/php.ini
# Define Mautic version by package tag
ARG MAUTIC_VERSION=7.x-dev
RUN cd /opt && \
COMPOSER_ALLOW_SUPERUSER=1 COMPOSER_PROCESS_TIMEOUT=10000 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
FROM php:${BASE_TAG}
LABEL vendor="Mautic"
LABEL maintainer="Mautic core team <>"
# Define Mautic volumes to persist data
VOLUME /var/www/html/config
VOLUME /var/www/html/var/logs
VOLUME /var/www/html/docroot/media/files
VOLUME /var/www/html/docroot/media/images
# Setting PHP properties
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
# Setting worker env vars
ENV DOCKER_MAUTIC_WORKERS_CONSUME_EMAIL=2 \
DOCKER_MAUTIC_WORKERS_CONSUME_HIT=2 \
DOCKER_MAUTIC_WORKERS_CONSUME_FAILED=2
ENV DOCKER_MAUTIC_ROLE=mautic_web \
DOCKER_MAUTIC_RUN_MIGRATIONS=false \
DOCKER_MAUTIC_LOAD_TEST_DATA=false
# Debug flag for startup scripts
ENV DEBUG=false
# Flavour of the image, apache or fpm
ARG FLAVOUR=apache
ENV FLAVOUR=${FLAVOUR}
ENV APACHE_DOCUMENT_ROOT=/var/www/html/docroot
# Copy php settings and extensions from builder
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/
# Copy php.ini from templates
COPY --from=builder /common/templates/php.ini /usr/local/etc/php/php.ini
COPY --from=builder --chown=www-data:www-data /opt/mautic /var/www/html
# Copy all files needed for startup
COPY --from=builder --chmod=755 /common/startup/ /startup/
COPY --from=builder --chown=www-data:www-data --chmod=755 /common/templates/ /templates/
COPY --from=builder --chmod=755 /common/docker-entrypoint.sh /entrypoint.sh
COPY --from=builder --chmod=755 /common/entrypoint_mautic_web.sh /entrypoint_mautic_web.sh
COPY --from=builder --chmod=755 /common/entrypoint_mautic_cron.sh /entrypoint_mautic_cron.sh
COPY --from=builder --chmod=755 /common/entrypoint_mautic_worker.sh /entrypoint_mautic_worker.sh
# Copy supervisord configuration for workers
COPY --from=builder /common/templates/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Install composer
COPY --from=builder /usr/bin/composer /usr/bin/composer
# Install PHP extensions requirements and other dependencies
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install --no-install-recommends -y \
cron \
git \
libavif15 \
librabbitmq4 \
libfreetype6 \
libjpeg62-turbo \
libpng16-16 \
libwebp7 \
libc-client2007e \
libxpm4 \
libzip4 \
mariadb-client \
supervisor \
unzip \
&& if [ "$FLAVOUR" = "fpm" ]; then \
apt-get install --no-install-recommends -y libfcgi-bin ; \
fi \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& rm /etc/cron.daily/*
# Install Node.JS
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
apt-get install -y nodejs && \
npm install -g npm@latest
# Rebuild web assets
RUN cd /var/www/html && \
npm install && \
php bin/console mautic:assets:generate && \
php bin/console cache:clear
RUN if [ "$FLAVOUR" = "apache" ]; then \
sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf \
&& sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf \
&& a2enmod rewrite; \
fi
# Set correct ownership for Mautic var folder
RUN chown -R www-data:www-data /var/www/html/var/
WORKDIR /var/www/html/docroot
ENTRYPOINT ["/entrypoint.sh"]