-
Notifications
You must be signed in to change notification settings - Fork 3
/
php.docker
58 lines (51 loc) · 2.1 KB
/
php.docker
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
# chekote/php:latest
# chekote/php:${PHP_MAJOR_VERSION}
# chekote/php:${PHP_MAJOR_VERSION}.${PHP_MINOR_VERSION}
# chekote/php:${PHP_MAJOR_VERSION}.${PHP_MINOR_VERSION}.${PHP_PATCH_VERSION}
# chekote/php:${PHP_MAJOR_VERSION}.${PHP_MINOR_VERSION}.${PHP_PATCH_VERSION}-$(date '+%Y-%m-%d-%H-%M-%S')
FROM chekote/ubuntu:noble-2024-07-23
ARG PHP_VERSION=7.3
ENV PHP_VERSION $PHP_VERSION
# Fix add-apt-repository is broken with non-UTF-8 locales, see https://github.com/oerdnj/deb.sury.org/issues/56
ENV LC_ALL C.UTF-8
RUN set -eu; \
#
apt-get update; \
#
# Configure ondrej PPA
apt-get install -y --no-install-suggests --no-install-recommends gnupg software-properties-common; \
add-apt-repository ppa:ondrej/php; \
apt-get update; \
#
# Install PHP
apt-get install -y --no-install-recommends \
php${PHP_VERSION}-cli \
php${PHP_VERSION}-fpm; \
#
# Cleanup
apt-get autoremove -y; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*; \
rm -rf /var/cache/apt/*; \
#
# Fix "Unable to create the PID file (/run/php/php5.6-fpm.pid).: No such file or directory (2)"
mkdir -p /run/php; \
#
# Configure PHP-FPM
sed -i "s!display_startup_errors = Off!display_startup_errors = On!g" /etc/php/$PHP_VERSION/fpm/php.ini; \
sed -i "s!;error_log = php_errors.log!error_log = /proc/self/fd/2!g" /etc/php/$PHP_VERSION/fpm/php.ini; \
#
sed -i "s!;daemonize = yes!daemonize = no!g" /etc/php/$PHP_VERSION/fpm/php-fpm.conf; \
sed -i "s!error_log = /var/log/php${PHP_VERSION}-fpm.log!error_log = /proc/self/fd/2!g" /etc/php/$PHP_VERSION/fpm/php-fpm.conf; \
#
sed -i "s!;catch_workers_output = yes!catch_workers_output = yes!g" /etc/php/$PHP_VERSION/fpm/pool.d/www.conf; \
sed -i "s!listen = /run/php/php${PHP_VERSION}-fpm.sock!listen = 0.0.0.0:9000!g" /etc/php/$PHP_VERSION/fpm/pool.d/www.conf; \
#
# Make sure everything works
php -v; \
php-fpm$PHP_VERSION -v
WORKDIR /workdir
EXPOSE 9000
COPY entrypoint.sh /usr/local/bin/entrypoint-php.sh
COPY check_php_version /usr/local/bin
ENTRYPOINT ["/usr/local/bin/entrypoint-php.sh"]