Dockerfile:
FROM wordpress:php7.4-fpm-alpine
RUN apk update && apk add -f nginx
COPY ./config/nginx/ /etc/nginx/
RUN nginx -t
RUN touch /var/run/nginx.pid
RUN chown -R www-data:www-data /var/lib/nginx/ &&
chown -R www-data:www-data /var/run/
RUN ln -sf /dev/stdout /var/log/nginx/access.log
RUN ln -sf /dev/stderr /var/log/nginx/error.log
ADD . /project
RUN chown -R www-data:www-data /project/ &&
find /project/ -type f -exec chmod 644 {} ; &&
find /project/ -type d -exec chmod 755 {} ;
WORKDIR /project
EXPOSE 80 443
CMD php-fpm | nginx -g 'daemon off;'
USER www-data
NGINX default.conf:
server {
listen 80;
listen [::]:80;
listen 443 http2;
listen [::]:443 http2;
server_name _;
client_body_timeout 3s;
client_header_timeout 3s;
root /project/web;
index index.php index.htm index.html;
location ~* /app/uploads/.*.php$ {
deny all;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ .php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass localhost:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTP_PROXY "";
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_buffer_size 128k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
}