Repository navigation
Expand file tree
/
Copy pathDockerfile.runtime
More file actions
142 lines (123 loc) · 4.65 KB
/
Copy pathDockerfile.runtime
File metadata and controls
142 lines (123 loc) · 4.65 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
# syntax=docker/dockerfile:1.7
ARG PHP_IMAGE=php:8.4.28-fpm-alpine@sha256:1c3d5f8dd7f56ae38dfaf33934c7d5f326d5291b611df1e3ea18a332d8ef9407
ARG COMPOSER_IMAGE=composer:2.10.1@sha256:7725eb4545c438629ae8bde3ef0bb9a5038ef566126ad878442a69007242d267
ARG REDIS_VERSION=6.3.0
# phpredis comes from the GitHub release tarball with a pinned checksum:
# pecl.php.net answered HTTP 500 under load on 2026-10-21.
ARG REDIS_SHA256=cb8f81df1a275599e4f8ddcfec7e1f65ed1953e6f5673649149fd680ebff4cad
FROM ${COMPOSER_IMAGE} AS composer
FROM ${PHP_IMAGE} AS builder
ARG REDIS_VERSION
ARG REDIS_SHA256
COPY --from=composer /usr/bin/composer /usr/local/bin/composer
RUN apk add --no-cache \
$PHPIZE_DEPS \
freetype-dev \
git \
icu-dev \
libjpeg-turbo-dev \
libpng-dev \
libzip-dev \
linux-headers \
patch \
unzip \
&& mkdir -p /usr/src/php/ext/redis \
&& curl -fsSL -o /tmp/phpredis.tar.gz https://github.com/phpredis/phpredis/archive/refs/tags/${REDIS_VERSION}.tar.gz \
&& echo "${REDIS_SHA256} /tmp/phpredis.tar.gz" | sha256sum -c - \
&& tar -xzf /tmp/phpredis.tar.gz --strip-components=1 -C /usr/src/php/ext/redis \
&& rm /tmp/phpredis.tar.gz \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j"$(getconf _NPROCESSORS_ONLN)" \
exif \
gd \
intl \
pdo_mysql \
zip \
redis \
&& docker-php-source delete
WORKDIR /app/data
COPY composer.json composer.lock ./
COPY patches ./patches
RUN composer install \
--no-dev \
--no-interaction \
--no-progress \
--no-scripts \
--prefer-dist
COPY . .
RUN composer install \
--no-dev \
--no-interaction \
--no-progress \
--optimize-autoloader \
--prefer-dist \
&& find web/modules/custom web/profiles -type f -name '*.php' -print0 \
| xargs -0 -r -n1 php -l \
&& for runtime_path in private web/sites/default/files; do \
test ! -e "$runtime_path" \
|| { echo "Runtime data path baked into image: $runtime_path" >&2; exit 1; }; \
done
FROM ${PHP_IMAGE} AS runtime
LABEL org.opencontainers.image.title="Mark-a-Spot Drupal runtime" \
org.opencontainers.image.description="Public Drupal runtime for self-hosted Mark-a-Spot deployments" \
org.opencontainers.image.licenses="GPL-2.0-or-later" \
org.opencontainers.image.source="https://github.com/markaspot/mark-a-spot"
RUN apk add --no-cache \
bash \
freetype \
icu-libs \
libjpeg-turbo \
libpng \
libxml2 \
libzip \
mariadb-client \
msmtp \
oniguruma \
su-exec \
&& ln -sf /usr/bin/msmtp /usr/sbin/sendmail \
&& addgroup -g 1000 app \
&& adduser -D -H -u 1000 -G app app
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 --from=builder /usr/local/bin/composer /usr/local/bin/composer
COPY --from=builder /app/data /app/data
COPY docker/runtime/settings.php /app/data/web/sites/default/settings.php
COPY docker/runtime/docker-entrypoint.sh /usr/local/bin/markaspot-entrypoint
# session.upload_progress.enabled=0 is the mitigation PHP recommends for
# CVE-2026-115560 (no patched release yet). Drupal's upload progress bar uses
# the PECL uploadprogress extension, not session upload progress, so turning
# it off changes nothing for the application.
RUN chmod 0755 /usr/local/bin/markaspot-entrypoint \
&& mkdir -p \
/app/data/private \
/app/data/tmp \
/app/data/web/sites/default/files \
&& chown -R app:app \
/app/data/private \
/app/data/tmp \
/app/data/web/sites/default/files \
&& sed -ri \
-e 's!^user = .*!user = app!' \
-e 's!^group = .*!group = app!' \
/usr/local/etc/php-fpm.d/www.conf \
&& { \
echo 'memory_limit=256M'; \
echo 'max_execution_time=600'; \
echo 'upload_max_filesize=64M'; \
echo 'post_max_size=64M'; \
echo 'opcache.enable=1'; \
echo 'opcache.enable_cli=1'; \
echo 'opcache.memory_consumption=128'; \
echo 'sendmail_path=/usr/bin/msmtp -t -C /tmp/msmtprc'; \
echo 'session.upload_progress.enabled=0'; \
} > /usr/local/etc/php/conf.d/zz-markaspot-runtime.ini
WORKDIR /app/data
ENV APP_ROOT=/app/data \
COMPOSER_ALLOW_SUPERUSER=1 \
MARKASPOT_MAIL_MODE=mailpit \
PATH="/app/data/vendor/bin:${PATH}"
EXPOSE 9000
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD php-fpm -t || exit 1
ENTRYPOINT ["markaspot-entrypoint"]
CMD ["php-fpm", "-F"]