forked from serversideup/docker-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
182 lines (159 loc) 路 6.79 KB
/
Copy pathDockerfile
File metadata and controls
182 lines (159 loc) 路 6.79 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# check=skip=SecretsUsedInArgOrEnv
ARG BASE_OS_VERSION='bookworm'
ARG PHP_VERSION='8.5'
ARG PHP_VARIATION='fpm-apache'
ARG BASE_IMAGE="php:${PHP_VERSION}-fpm-${BASE_OS_VERSION}"
##########
# S6 Build
##########
FROM ${BASE_IMAGE} AS s6-build
ARG S6_DIR='/opt/s6/'
ARG S6_SRC_URL="https://github.com/just-containers/s6-overlay/releases/download"
# copy our scripts
COPY --chmod=755 src/common/ /
COPY --chmod=755 src/s6/ /
RUN docker-php-serversideup-s6-install
##########
# FPM-APACHE: Main Image
##########
FROM ${BASE_IMAGE}
ARG DEPENDENCY_PACKAGES_ALPINE='fcgi apache2 shadow'
ARG DEPENDENCY_PACKAGES_DEBIAN='libfcgi-bin apache2 procps zip'
ARG DEPENDENCY_PHP_EXTENSIONS='mysqli opcache pcntl pdo_mysql pdo_pgsql redis zip'
ARG REPOSITORY_BUILD_VERSION='dev'
LABEL org.opencontainers.image.title="serversideup/php (fpm-apache)" \
org.opencontainers.image.description="Supercharge your PHP experience. Based off the official PHP images, serversideup/php includes pre-configured PHP extensions and settings for enhanced performance and security. Optimized for Laravel and WordPress." \
org.opencontainers.image.url="https://serversideup.net/open-source/docker-php/" \
org.opencontainers.image.source="https://github.com/serversideup/docker-php" \
org.opencontainers.image.documentation="https://serversideup.net/open-source/docker-php/docs/" \
org.opencontainers.image.vendor="ServerSideUp" \
org.opencontainers.image.authors="Jay Rogers (@jaydrogers)" \
org.opencontainers.image.version="${REPOSITORY_BUILD_VERSION}" \
org.opencontainers.image.licenses="GPL-3.0-or-later"
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public \
APACHE_HTTP_PORT="8080" \
APACHE_HTTPS_PORT="8443" \
APACHE_START_SERVERS="2" \
APACHE_MIN_SPARE_THREADS="10" \
APACHE_MAX_SPARE_THREADS="75" \
APACHE_THREAD_LIMIT="64" \
APACHE_THREADS_PER_CHILD="25" \
APACHE_MAX_REQUEST_WORKERS="150" \
APACHE_MAX_CONNECTIONS_PER_CHILD="0" \
APACHE_REMOTE_IP_HEADER="CF-Connecting-IP" \
APACHE_RUN_USER="www-data" \
APACHE_RUN_GROUP="www-data" \
APP_BASE_DIR=/var/www/html \
COMPOSER_ALLOW_SUPERUSER=1 \
COMPOSER_HOME=/composer \
COMPOSER_MAX_PARALLEL_HTTP=24 \
DISABLE_DEFAULT_CONFIG=false \
HEALTHCHECK_PATH="/healthcheck" \
LOG_OUTPUT_LEVEL=warn \
PHP_DATE_TIMEZONE="UTC" \
PHP_DISPLAY_ERRORS=Off \
PHP_DISPLAY_STARTUP_ERRORS=Off \
PHP_ERROR_LOG="/dev/stderr" \
PHP_ERROR_REPORTING="22527" \
PHP_FPM_PM_CONTROL=ondemand \
PHP_FPM_PM_MAX_CHILDREN="20" \
PHP_FPM_PM_MAX_REQUESTS="0" \
PHP_FPM_PM_MAX_SPARE_SERVERS="3" \
PHP_FPM_PM_MIN_SPARE_SERVERS="1" \
PHP_FPM_PM_START_SERVERS="2" \
PHP_FPM_PM_STATUS_PATH="/status" \
PHP_FPM_POOL_NAME="www" \
PHP_FPM_PROCESS_CONTROL_TIMEOUT="10s" \
PHP_MAX_EXECUTION_TIME="99" \
PHP_MAX_INPUT_TIME="-1" \
PHP_MAX_INPUT_VARS="1000" \
PHP_MEMORY_LIMIT="256M" \
PHP_OPCACHE_ENABLE="0" \
PHP_OPCACHE_ENABLE_FILE_OVERRIDE="0" \
PHP_OPCACHE_FORCE_RESTART_TIMEOUT="180" \
PHP_OPCACHE_INTERNED_STRINGS_BUFFER="8" \
PHP_OPCACHE_JIT="off" \
PHP_OPCACHE_JIT_BUFFER_SIZE="0" \
PHP_OPCACHE_MAX_ACCELERATED_FILES="10000" \
PHP_OPCACHE_MEMORY_CONSUMPTION="128" \
PHP_OPCACHE_REVALIDATE_FREQ="2" \
PHP_OPCACHE_SAVE_COMMENTS="1" \
PHP_OPCACHE_VALIDATE_TIMESTAMPS="1" \
PHP_OPEN_BASEDIR="" \
PHP_POST_MAX_SIZE="100M" \
PHP_REALPATH_CACHE_TTL="120" \
PHP_SESSION_COOKIE_SECURE=false \
PHP_UPLOAD_MAX_FILE_SIZE="100M" \
PHP_ZEND_DETECT_UNICODE="" \
PHP_ZEND_MULTIBYTE="Off" \
S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
S6_KEEP_ENV=1 \
S6_VERBOSITY=1 \
SHOW_WELCOME_MESSAGE=true \
SSL_MODE=off \
SSL_CERTIFICATE_FILE=/etc/ssl/private/self-signed-web.crt \
SSL_PRIVATE_KEY_FILE=/etc/ssl/private/self-signed-web.key
# copy our scripts
COPY --chmod=755 src/common/ /
COPY --chmod=755 src/s6/ /
COPY --chmod=755 src/utilities-webservers/ /
# copy s6-overlay from s6-build
COPY --from=s6-build /opt/s6/ /
# copy php-fpm-healthcheck from s6-build
COPY --from=s6-build /usr/local/bin/php-fpm-healthcheck /usr/local/bin/php-fpm-healthcheck
# install pecl extensions, dependencies, and clean up
RUN docker-php-serversideup-dep-install-debian "${DEPENDENCY_PACKAGES_DEBIAN}" && \
docker-php-serversideup-install-php-ext-installer && \
\
# Ensure /var/www/ has the correct permissions
chown -R www-data:www-data /var/www && \
chmod -R 755 /var/www && \
\
# Set the image version
echo "${REPOSITORY_BUILD_VERSION}" > /etc/serversideup-php-version && \
\
# Make composer cache directory
mkdir -p "${COMPOSER_HOME}" && \
chown -R www-data:www-data "${COMPOSER_HOME}" && \
\
# Install default PHP extensions
install-php-extensions ${DEPENDENCY_PHP_EXTENSIONS} && \
\
# redirect logs to STDOUT and STERR
ln -sf /dev/stdout /var/log/apache2/access.log && \
ln -sf /dev/stdout /var/log/apache2/other_vhosts_access.log && \
ln -sf /dev/stderr /var/log/apache2/error.log && \
\
# enable Apache2 mods
a2enmod actions autoindex deflate headers http2 proxy proxy_fcgi remoteip rewrite setenvif ssl unique_id && \
\
# force Docker ENVs to handle the apache variables for the run user and group
echo "export APACHE_RUN_USER=${APACHE_RUN_USER}" >> /etc/apache2/envvars && \
echo "export APACHE_RUN_GROUP=${APACHE_RUN_GROUP}" >> /etc/apache2/envvars && \
\
# configure permissions on the webroot
chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $APP_BASE_DIR && \
# clear all php provided fpm configurations
rm -rf /usr/local/etc/php-fpm.d/*.conf && \
\
# clear all apache provided configurations
rm -rf /usr/share/doc/* /var/www/html/* /etc/apache2/sites-enabled/* /etc/apache2/sites-available/*
# Copy our apache configurations
COPY --chmod=755 src/variations/fpm-apache/etc/ /etc/
# copy our fpm configurations
COPY --chmod=755 src/php-fpm.d/ /
# install composer from Composer's official Docker image
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
RUN docker-php-serversideup-set-file-permissions --owner www-data:www-data --service apache
# Fix S6 Overlay issues with Big Cloud PaaS (https://github.com/serversideup/docker-php/pull/376#issuecomment-2179262427)
RUN chown -R www-data:www-data /run
USER www-data
EXPOSE 8080 8443
ENTRYPOINT ["docker-php-serversideup-entrypoint"]
# Set stop signal to SIGQUIT for a graceful shutdown instead of S6's preferred SIGTERM (https://github.com/just-containers/s6-overlay/issues/586)
STOPSIGNAL SIGQUIT
WORKDIR ${APP_BASE_DIR}
CMD ["/init"]
HEALTHCHECK --start-period=60s --start-interval=3s --interval=10s --timeout=3s --retries=3 \
CMD [ "sh", "-c", "curl --insecure --silent --location --show-error --fail http://localhost:${APACHE_HTTP_PORT}${HEALTHCHECK_PATH} || exit 1" ]