Skip to content

Commit 7205818

Browse files
use PHP 8 for Docker image
1 parent 92de11e commit 7205818

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

Dockerfile

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
FROM alpine:edge
2-
3-
LABEL Maintainer="Tim de Pater <[email protected]>" \
4-
Description="Lightweight container with Nginx 1.18 & PHP-FPM 7.3 based on Alpine Linux."
1+
FROM alpine:3.14
2+
LABEL Maintainer="Tim de Pater <[email protected]>"
3+
LABEL Description="Lightweight container with Nginx 1.20 & PHP 8.0 based on Alpine Linux."
54

65
ENV APP_ENV=prod
76
ENV INSTALLATION_TYPE=docker
@@ -14,20 +13,23 @@ ENV SSL_VERIFY_HOST=$SSL_VERIFY_HOST
1413
ENV SECRET_REGISTER=$SECRET_REGISTER
1514

1615
# Install packages and remove default server definition
17-
RUN apk --update add php7 php7-fpm php7-opcache php7-json php7-openssl php7-curl \
18-
php7-zlib php7-xml php7-simplexml php7-phar php7-intl php7-dom php7-xmlreader php7-ctype php7-session \
19-
php7-tokenizer php7-pdo php7-pdo_mysql php7-pdo_pgsql php7-iconv php7-zip \
20-
php7-gmp php7-mbstring nginx supervisor nodejs nodejs npm curl && \
21-
rm -f /etc/nginx/conf.d/default.conf
16+
RUN apk --no-cache add php8 php8-fpm php8-opcache php8-json php8-openssl php8-curl \
17+
php8-zlib php8-xml php8-simplexml php8-phar php8-intl php8-dom php8-xmlreader php8-ctype php8-session \
18+
php8-tokenizer php8-pdo php8-pdo_mysql php8-pdo_pgsql php8-iconv php8-zip \
19+
php8-gmp php8-mbstring nginx supervisor nodejs nodejs npm curl
20+
21+
# Create symlink so programs depending on `php` still function
22+
RUN ln -s /usr/bin/php8 /usr/bin/php
2223

2324
# Configure nginx
2425
COPY docker/nginx.conf /etc/nginx/nginx.conf
2526
COPY docker/privkey.pem /etc/nginx/privkey.pem
2627
COPY docker/fullchain.pem /etc/nginx/fullchain.pem
28+
RUN rm -f /etc/nginx/conf.d/default.conf
2729

2830
# Configure PHP-FPM
29-
COPY docker/fpm-pool.conf /etc/php7/php-fpm.d/www.conf
30-
COPY docker/php.ini /etc/php7/conf.d/custom.ini
31+
COPY docker/fpm-pool.conf /etc/php8/php-fpm.d/www.conf
32+
COPY docker/php.ini /etc/php8/conf.d/custom.ini
3133

3234
# Configure supervisord
3335
COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
@@ -39,8 +41,8 @@ RUN mkdir -p /var/www/html && mkdir -p /.composer && mkdir -p /.npm
3941
RUN chown -R nobody.nobody /var/www/html && \
4042
chown -R nobody.nobody /.composer && \
4143
chown -R nobody.nobody /.npm && \
42-
chown -R nobody.nobody /run && \
4344
chown -R nobody.nobody /etc/nginx && \
45+
chown -R nobody.nobody /run && \
4446
chown -R nobody.nobody /var/lib/nginx && \
4547
chown -R nobody.nobody /var/log/nginx
4648

docker/nginx.conf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
worker_processes 1;
1+
worker_processes auto;
22
error_log stderr warn;
33
pid /run/nginx.pid;
44

@@ -85,6 +85,12 @@ http {
8585
return 404;
8686
}
8787

88+
# Deny access to . files, for security
89+
location ~ /\. {
90+
log_not_found off;
91+
deny all;
92+
}
93+
8894
# Allow fpm ping and status from localhost
8995
location ~ ^/(fpm-status|fpm-ping)$ {
9096
access_log off;

docker/supervisord.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ logfile_maxbytes=0
55
pidfile=/run/supervisord.pid
66

77
[program:php-fpm]
8-
command=php-fpm7 -F
8+
command=php-fpm8 -F
99
stdout_logfile=/dev/stdout
1010
stdout_logfile_maxbytes=0
1111
stderr_logfile=/dev/stderr

0 commit comments

Comments
 (0)