-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (49 loc) · 2.56 KB
/
Dockerfile
File metadata and controls
57 lines (49 loc) · 2.56 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
ARG PHP_VERSION=latest
FROM wordpress:${PHP_VERSION}
ENV XDEBUG_PORT_V2=9000
ENV XDEBUG_PORT_V3=9003
# Install only essential dependencies for PHP extensions
RUN apt-get update && apt-get install -y --no-install-recommends \
libicu-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install only the required PHP extensions: Intl and Redis
RUN docker-php-ext-install intl \
&& pecl install redis \
&& docker-php-ext-enable redis
# Install and configure Xdebug
RUN yes | pecl install xdebug && \
echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini && \
if php -v | grep -q "PHP 7"; then \
# Xdebug 2.x configuration for PHP 7
echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/xdebug.ini && \
echo "xdebug.remote_connect_back=1" >> /usr/local/etc/php/conf.d/xdebug.ini && \
echo "xdebug.remote_port=${XDEBUG_PORT_V2}" >> /usr/local/etc/php/conf.d/xdebug.ini && \
echo "xdebug.remote_handler=dbgp" >> /usr/local/etc/php/conf.d/xdebug.ini && \
echo "xdebug.remote_mode=req" >> /usr/local/etc/php/conf.d/xdebug.ini && \
echo "xdebug.remote_autostart=false" >> /usr/local/etc/php/conf.d/xdebug.ini; \
else \
# Xdebug 3.x configuration for PHP 8+
echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/xdebug.ini && \
echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/xdebug.ini && \
echo "xdebug.client_port=${XDEBUG_PORT_V3}" >> /usr/local/etc/php/conf.d/xdebug.ini && \
echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/xdebug.ini && \
echo "xdebug.discover_client_host=true" >> /usr/local/etc/php/conf.d/xdebug.ini; \
fi
# Configure php.ini settings for WordPress development
RUN { \
echo 'upload_max_filesize = 64M'; \
echo 'post_max_size = 64M'; \
echo 'memory_limit = 256M'; \
echo 'max_execution_time = 300'; \
} > /usr/local/etc/php/conf.d/wordpress-recommended.ini
# Install wp-cli for WordPress command line operations and create a wrapper script that includes --allow-root
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
chmod +x wp-cli.phar && \
mv wp-cli.phar /usr/local/bin/wp-orig && \
echo '#!/bin/bash' > /usr/local/bin/wp-cli-wrapper && \
echo 'exec wp-orig --allow-root "$@"' >> /usr/local/bin/wp-cli-wrapper && \
chmod +x /usr/local/bin/wp-cli-wrapper && \
ln -s /usr/local/bin/wp-cli-wrapper /usr/local/bin/wp
EXPOSE 9000
EXPOSE 9003