-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.benchmark
More file actions
92 lines (76 loc) · 2.32 KB
/
Dockerfile.benchmark
File metadata and controls
92 lines (76 loc) · 2.32 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
# Dockerfile for Express PHP Benchmarks
# Standardized environment for consistent performance testing
FROM php:8.4-cli
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libzip-dev \
zip \
unzip \
libicu-dev \
libonig-dev \
libxml2-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install PHP extensions
RUN docker-php-ext-install \
pdo \
pdo_mysql \
mysqli \
bcmath \
intl \
opcache \
zip \
mbstring \
xml
# Install PECL extensions
RUN pecl install redis apcu && \
docker-php-ext-enable redis apcu
# Configure OPcache for maximum performance
RUN { \
echo 'opcache.enable=1'; \
echo 'opcache.enable_cli=1'; \
echo 'opcache.memory_consumption=256'; \
echo 'opcache.interned_strings_buffer=16'; \
echo 'opcache.max_accelerated_files=20000'; \
echo 'opcache.validate_timestamps=0'; \
echo 'opcache.save_comments=0'; \
echo 'opcache.fast_shutdown=1'; \
echo 'opcache.jit_buffer_size=256M'; \
echo 'opcache.jit=1255'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini
# Configure APCu
RUN { \
echo 'apc.enable_cli=1'; \
echo 'apc.shm_size=256M'; \
} > /usr/local/etc/php/conf.d/apcu.ini
# Configure PHP for performance
RUN { \
echo 'memory_limit=1G'; \
echo 'max_execution_time=0'; \
echo 'date.timezone=UTC'; \
echo 'display_errors=Off'; \
echo 'error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT'; \
} > /usr/local/etc/php/conf.d/performance.ini
# Install Composer
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
# Set working directory
WORKDIR /app
# Copy composer files first for better caching
COPY composer.json composer.lock ./
# Install dependencies
RUN composer install --no-dev --optimize-autoloader --no-interaction --no-progress
# Copy application code
COPY . .
# Warm up OPcache by preloading files
RUN find src -name "*.php" -exec php -l {} \; > /dev/null 2>&1
# Create benchmark results directory
RUN mkdir -p /app/benchmarks/results
# Set environment variables for consistent benchmarking
ENV PHP_MEMORY_LIMIT=1G \
PHP_MAX_EXECUTION_TIME=0 \
BENCHMARK_ITERATIONS=10000 \
BENCHMARK_WARMUP=1000
# Default command
CMD ["php", "-d", "memory_limit=1G", "-d", "opcache.enable_cli=1", "benchmarks/run_all_benchmarks.php"]