-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile.dev
103 lines (93 loc) · 3.22 KB
/
Dockerfile.dev
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
FROM php:8.2-apache-bookworm
# set the www-data uid to our own uid, so that we do not clobber drupal
# permissions when mounting docker-compose volumes.
ARG UID
ARG GID
RUN usermod -u ${UID} www-data
RUN usermod -g ${GID} www-data
# Copy the zscaler root CA into the container and add it to the list of OpenSSL
# root certificates.
COPY zscaler-root.pem /etc/ssl/certs/zscaler-root.pem
# Rebuild the CA cache. Otherwise the prior step is useless.
RUN c_rehash
# Tell PHP where to look for CAs. I dunno why it doesn't look here by default.
RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
RUN echo "openssl.capath=/etc/ssl/certs/" >> /usr/local/etc/php/php.ini
# install the PHP extensions we need
RUN set -eux; \
\
if command -v a2enmod; then \
a2enmod rewrite headers; \
fi; \
\
savedAptMark="$(apt-mark showmanual)"; \
\
apt-get update; \
apt-get install -y --no-install-recommends \
default-mysql-client \
libfreetype6-dev \
libjpeg-dev \
libpng-dev \
libpq-dev \
libwebp-dev \
libzip-dev \
; \
# xdebug is being pinned to 3.2.2 because of an issue with Drupal 10.2, see: https://git.drupalcode.org/project/drupal/-/merge_requests/5774
pecl install xdebug-3.2.2; \
docker-php-ext-enable xdebug; \
\
docker-php-ext-configure gd \
--with-freetype \
--with-jpeg=/usr \
--with-webp \
; \
\
docker-php-ext-install -j "$(nproc)" \
gd \
pdo_mysql \
pdo_pgsql \
zip \
; \
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
apt-mark auto '.*' > /dev/null; \
apt-mark manual $savedAptMark; \
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \
| sort -u \
| xargs -r dpkg-query -S \
| cut -d: -f1 \
| sort -u \
| xargs -rt apt-mark manual; \
\
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
rm -rf /var/lib/apt/lists/*
COPY --from=composer:lts /usr/bin/composer /usr/local/bin/
# Copy in our composer files to start with.
COPY composer.json /opt/drupal/composer.json
COPY composer.lock /opt/drupal/composer.lock
WORKDIR /opt/drupal
RUN set -eux; \
export COMPOSER_HOME="$(mktemp -d)"; \
composer install --dev; \
chown -R www-data:www-data web/sites web/modules web/themes; \
rmdir /var/www/html; \
ln -sf /opt/drupal/web /var/www/html; \
# delete composer cache
rm -rf "$COMPOSER_HOME"
# set recommended PHP.ini settings
# see https://secure.php.net/manual/en/opcache.installation.php
RUN { \
echo 'opcache.revalidate_freq=60'; \
echo 'xdebug.mode=coverage,develop,debug'; \
# echo 'xdebug.mode=coverage,develop,debug,profile'; \
# echo 'xdebug.output_dir=/opt/drupal/web/config/profiling'; \
echo 'xdebug.client_port=9003'; \
echo 'xdebug.start_with_request=yes'; \
echo 'xdebug.client_host=host.docker.internal'; \
# Only log critical configuration errors. This way we don't see a flood of
# messages about the debugger not being able to connect when we don't have a
# listener running yet.
echo 'xdebug.log_level=0'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini
ENV PATH=${PATH}:/opt/drupal/vendor/bin
# vim:set ft=dockerfile: