-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
77 lines (65 loc) · 3.1 KB
/
Copy pathDockerfile
File metadata and controls
77 lines (65 loc) · 3.1 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
# WordPress with Nginx + PHP-FPM
#
# Base: PHP 8.3 FPM on Debian Bookworm
# Architecture: Nginx + PHP-FPM managed by Supervisor (single container)
#
# Why not Apache? Nginx + PHP-FPM provides:
# - Better performance and lower memory usage
# - Easier rate limiting and security configurations
# - More efficient handling of static files
#
FROM php:8.3-fpm-bookworm
# Install system dependencies and required libraries
# nginx: Web server
# supervisor: Process manager for nginx + php-fpm
# mysql-client/redis-tools: For healthchecks and debugging
RUN apt-get update && apt-get install -y \
libicu-dev libzip-dev libpng-dev libjpeg62-turbo-dev \
libfreetype6-dev libmagickwand-dev \
nginx supervisor curl \
default-mysql-client redis-tools \
&& rm -rf /var/lib/apt/lists/*
# Install PHP extensions required by WordPress and common plugins
# gd: Image manipulation, intl: Internationalization
# mysqli/pdo_mysql: Database, opcache: Performance
# zip: Plugin/theme uploads, bcmath: E-commerce calculations
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd intl mysqli opcache exif zip sockets pdo_mysql bcmath
# Install Redis extension with igbinary for efficient object serialization
# This reduces memory usage and improves cache performance
RUN pecl install igbinary-3.2.15 redis-6.0.2 \
&& docker-php-ext-enable igbinary redis \
&& rm -rf /tmp/pear
# Install ImageMagick for advanced image processing
# Used by plugins for thumbnails, watermarks, etc.
RUN pecl install imagick \
&& docker-php-ext-enable imagick \
&& rm -rf /tmp/pear
# Install WP-CLI for command-line WordPress management
# Used in entrypoint script for automated setup
RUN curl -o /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
&& chmod +x /usr/local/bin/wp
# Create required runtime directories
RUN mkdir -p /var/www/html /var/log/nginx /var/log/php-fpm /var/log/supervisor \
/run/nginx /run/php
RUN chown -R www-data:www-data /var/www/html /var/log/nginx \
/var/log/php-fpm /run/nginx /run/php
# Copy all configuration files
# See config/ directory for individual file documentation
COPY config/php/custom.ini /usr/local/etc/php/conf.d/custom.ini
COPY config/php/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
COPY config/php/www.conf /usr/local/etc/php-fpm.d/www.conf
COPY config/nginx/nginx.conf /etc/nginx/nginx.conf
COPY config/nginx/default.conf /etc/nginx/conf.d/default.conf
COPY config/supervisor/supervisord.conf /etc/supervisord.conf
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN rm -f /etc/nginx/sites-enabled/default \
&& chmod +x /usr/local/bin/docker-entrypoint.sh
WORKDIR /var/www/html
EXPOSE 80
HEALTHCHECK --interval=10s --timeout=5s --start-period=40s --retries=3 \
CMD curl -f http://localhost/health || exit 1
# Entrypoint downloads WordPress, creates wp-config.php, and handles migrations
# Supervisor then starts both nginx and php-fpm as managed processes
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]