Skip to content

Commit 73838c3

Browse files
committed
add php:7.4-fpm image, and update nginx conf
1 parent f4a11d5 commit 73838c3

File tree

8 files changed

+674
-57
lines changed

8 files changed

+674
-57
lines changed

CHANGELOG.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [1.6.0] - 2020-10-18
10+
### Added
11+
- New php image: php:7.4-fpm
12+
### Fixed
13+
- Fixed nginx buffer conf for Magento versions >= 2.4
14+
915
## [1.5.0] - 2020-07-03
1016
### Added
11-
- New node-php image with php7.3.
12-
- Added tags: node-php:node8-php7.3
17+
- New node-php image with php7.3.
18+
- Added tags: node-php:node8-php7.3
1319
### Updated
1420
- Improved error log for php-fpm
1521
- Updated tags: php7.2-fpm, php7.3-fpm

nginx/1.13/conf/default.conf

+98-55
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,56 @@
1+
# WEBSITES MAPPING
2+
map $http_host $MAGE_RUN_CODE {
3+
4+
default base;
5+
## For multi-store configuration add here your domain-website codes
6+
# dominio-es.lo es;
7+
# dominio-ch.lo ch;
8+
# dominio-de.lo de;
9+
}
10+
111
upstream fastcgi_backend {
212
server unix:/sock/docker.sock;
313
}
414

515
server {
616
listen 8000;
17+
## Add here your domains or leave "localhost" wildcard
718
server_name localhost;
819

920
set $MAGE_ROOT /var/www/html;
1021
set $MAGE_MODE developer;
22+
set $MAGE_RUN_TYPE website;
1123

1224
root $MAGE_ROOT/pub;
1325

1426
index index.php;
1527
autoindex off;
16-
charset off;
17-
28+
charset UTF-8;
29+
client_max_body_size 64M;
30+
error_page 404 403 = /errors/404.php;
1831
add_header 'X-Content-Type-Options' 'nosniff';
32+
#add_header "X-UA-Compatible" "IE=Edge";
1933

20-
location /setup {
21-
root $MAGE_ROOT;
34+
# Deny access to sensitive files
35+
location /.user.ini {
36+
deny all;
37+
}
2238

39+
# PHP entry point for setup application
40+
location ~* ^/setup($|/) {
41+
root $MAGE_ROOT;
2342
location ~ ^/setup/index.php {
43+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
2444
fastcgi_pass fastcgi_backend;
45+
46+
fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
47+
fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=600";
48+
fastcgi_read_timeout 600s;
49+
fastcgi_connect_timeout 600s;
50+
2551
fastcgi_index index.php;
2652
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
27-
include fastcgi_params;
53+
include fastcgi_params;
2854
}
2955

3056
location ~ ^/setup/(?!pub/). {
@@ -35,20 +61,21 @@ server {
3561
add_header X-Frame-Options "SAMEORIGIN";
3662
}
3763
}
38-
39-
location /update {
64+
65+
# PHP entry point for update application
66+
location ~* ^/update($|/) {
4067
root $MAGE_ROOT;
4168

4269
location ~ ^/update/index.php {
4370
fastcgi_split_path_info ^(/update/index.php)(/.+)$;
4471
fastcgi_pass fastcgi_backend;
4572
fastcgi_index index.php;
4673
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
47-
fastcgi_param PATH_INFO $fastcgi_path_info;
48-
include fastcgi_params;
74+
fastcgi_param PATH_INFO $fastcgi_path_info;
75+
include fastcgi_params;
4976
}
5077

51-
# deny everything but index.php
78+
# Deny everything but index.php
5279
location ~ ^/update/(?!pub/). {
5380
deny all;
5481
}
@@ -59,57 +86,53 @@ server {
5986
}
6087

6188
location / {
62-
try_files $uri $uri/ /index.php?$args;
89+
try_files $uri $uri/ /index.php$is_args$args;
6390
}
64-
65-
location /pub {
91+
92+
location /pub/ {
6693
location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) {
6794
deny all;
6895
}
69-
70-
alias $MAGE_ROOT/pub;
96+
alias $MAGE_ROOT/pub/;
7197
add_header X-Frame-Options "SAMEORIGIN";
7298
}
73-
99+
74100
location /static/ {
75101
if ($MAGE_MODE = "production") {
76102
expires max;
77103
}
78104

79-
# remove signature of static files used to overcome browser cache
105+
# Remove signature of the static files that is used to overcome the browser cache
80106
location ~ ^/static/version {
81107
rewrite ^/static/(version\d*/)?(.*)$ /static/$2 last;
82108
}
83109

84-
location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
110+
location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|json)$ {
85111
add_header Cache-Control "public";
86112
add_header X-Frame-Options "SAMEORIGIN";
87113
expires +1y;
88-
114+
89115
if (!-f $request_filename) {
90116
rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
91117
}
92118
}
93-
94119
location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
95120
add_header Cache-Control "no-store";
96121
add_header X-Frame-Options "SAMEORIGIN";
97-
expires off;
98-
122+
expires off;
123+
99124
if (!-f $request_filename) {
100-
rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
125+
rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
101126
}
102127
}
103-
104128
if (!-f $request_filename) {
105129
rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
106130
}
107-
108131
add_header X-Frame-Options "SAMEORIGIN";
109132
}
110-
133+
111134
location /media/ {
112-
try_files $uri $uri/ /get.php?$args;
135+
try_files $uri $uri/ /get.php$is_args$args;
113136

114137
location ~ ^/media/theme_customization/.*\.xml {
115138
deny all;
@@ -119,59 +142,79 @@ server {
119142
add_header Cache-Control "public";
120143
add_header X-Frame-Options "SAMEORIGIN";
121144
expires +1y;
122-
try_files $uri $uri/ /get.php?$args;
145+
try_files $uri $uri/ /get.php$is_args$args;
123146
}
124-
125147
location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
126148
add_header Cache-Control "no-store";
127149
add_header X-Frame-Options "SAMEORIGIN";
128-
expires off;
129-
try_files $uri $uri/ /get.php?$args;
150+
expires off;
151+
try_files $uri $uri/ /get.php$is_args$args;
130152
}
131-
132153
add_header X-Frame-Options "SAMEORIGIN";
133154
}
134-
155+
135156
location /media/customer/ {
136157
deny all;
137158
}
138-
159+
139160
location /media/downloadable/ {
140161
deny all;
141162
}
142-
143-
location /media/import/ {
144-
deny all;
145-
}
146163

147-
location ~ /media/theme_customization/.*\.xml$ {
164+
location /media/import/ {
148165
deny all;
149166
}
150-
167+
151168
location /errors/ {
152-
try_files $uri =404;
153-
}
154-
155-
location ~ ^/errors/.*\.(xml|phtml)$ {
156-
deny all;
157-
}
158-
159-
location ~ cron\.php {
160-
deny all;
169+
location ~* \.(xml|phtml)$ {
170+
deny all;
171+
}
161172
}
162173

163-
location ~ (index|get|static|report|404|503)\.php$ {
174+
# PHP entry point for main application
175+
location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ {
164176
try_files $uri =404;
165177
fastcgi_pass fastcgi_backend;
166-
178+
fastcgi_buffers 1024 4k;
179+
fastcgi_buffer_size 32k;
180+
167181
fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
168-
fastcgi_param PHP_VALUE "max_execution_time=600";
182+
fastcgi_param PHP_VALUE "memory_limit=768M \n max_execution_time=600";
183+
fastcgi_param PHP_VALUE "max_input_vars=10000";
169184
fastcgi_read_timeout 600s;
170185
fastcgi_connect_timeout 600s;
171186
fastcgi_param MAGE_MODE $MAGE_MODE;
172-
187+
fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
188+
fastcgi_param MAGE_RUN_TYPE $MAGE_RUN_TYPE;
189+
173190
fastcgi_index index.php;
174191
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
175-
include fastcgi_params;
192+
include fastcgi_params;
176193
}
177-
}
194+
195+
gzip on;
196+
gzip_disable "msie6";
197+
198+
gzip_comp_level 6;
199+
gzip_min_length 1100;
200+
gzip_buffers 16 8k;
201+
gzip_proxied any;
202+
gzip_types
203+
text/plain
204+
text/css
205+
text/js
206+
text/xml
207+
text/javascript
208+
application/javascript
209+
application/x-javascript
210+
application/json
211+
application/xml
212+
application/xml+rss
213+
image/svg+xml;
214+
gzip_vary on;
215+
216+
# Banned locations (only reached if the earlier PHP entry point regexes don't match)
217+
location ~* (\.php$|\.htaccess$|\.git) {
218+
deny all;
219+
}
220+
}

php/7.4-fpm/Dockerfile

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
FROM php:7.4-fpm
2+
3+
LABEL authors="Daniel Lozano <dn.lozano.m@gmail.com>, Juan Alonso <juan.jalogut@gmail.com>"
4+
5+
RUN apt-get update && apt-get install -y --no-install-recommends \
6+
cron \
7+
git \
8+
gzip \
9+
libfreetype6-dev \
10+
libicu-dev \
11+
libjpeg62-turbo-dev \
12+
libmcrypt-dev \
13+
libpng-dev \
14+
libxslt1-dev \
15+
libzip-dev \
16+
lsof \
17+
mariadb-client \
18+
vim \
19+
zip \
20+
procps \
21+
sudo \
22+
openssh-client \
23+
libonig-dev \
24+
&& rm -rf /var/lib/apt/lists/*
25+
26+
RUN docker-php-ext-configure \
27+
gd --with-freetype --with-jpeg
28+
29+
RUN docker-php-ext-install \
30+
bcmath \
31+
gd \
32+
intl \
33+
mbstring \
34+
opcache \
35+
pcntl \
36+
pdo_mysql \
37+
soap \
38+
xsl \
39+
zip \
40+
sockets
41+
42+
# Remove libsodium and install upgrading version:
43+
RUN rm -f /usr/local/etc/php/conf.d/*sodium.ini \
44+
&& rm -f /usr/local/lib/php/extensions/*/*sodium.so \
45+
&& apt-get remove libsodium* -y \
46+
&& mkdir -p /tmp/libsodium \
47+
&& curl -sL https://github.com/jedisct1/libsodium/archive/1.0.18-RELEASE.tar.gz | tar xzf - -C /tmp/libsodium \
48+
&& cd /tmp/libsodium/libsodium-1.0.18-RELEASE/ \
49+
&& ./configure \
50+
&& make && make check \
51+
&& make install \
52+
&& cd / \
53+
&& rm -rf /tmp/libsodium \
54+
&& pecl install -o -f libsodium \
55+
&& docker-php-ext-enable sodium
56+
57+
RUN pecl channel-update pecl.php.net \
58+
&& pecl install xdebug \
59+
&& docker-php-ext-enable xdebug \
60+
&& sed -i -e 's/^zend_extension/\;zend_extension/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
61+
62+
# install composer
63+
RUN EXPECTED_SIGNATURE="$(curl -s https://composer.github.io/installer.sig)" \
64+
&& php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
65+
&& ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" \
66+
&& ( if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; then >&2 echo 'ERROR: Invalid installer signature'; rm composer-setup.php; exit 1; fi ) \
67+
&& php composer-setup.php --install-dir /usr/local/bin --filename=composer \
68+
&& php -r "unlink('composer-setup.php');"
69+
70+
RUN groupadd -g 1000 app \
71+
&& useradd -g 1000 -u 1000 -d /var/www -s /bin/bash app
72+
73+
COPY conf/www.conf /usr/local/etc/php-fpm.d/
74+
COPY conf/php.ini /usr/local/etc/php/
75+
COPY conf/xdebug.ini /usr/local/etc/php/conf.d/
76+
COPY conf/php-fpm.conf /usr/local/etc/
77+
78+
RUN mkdir /sock
79+
RUN chown -R app:app /usr/local/etc/php/conf.d /sock
80+
81+
RUN mkdir -p /var/www && chown -R app:app /var/www/
82+
RUN echo "app ALL=(ALL) NOPASSWD: /bin/chown" >> /etc/sudoers.d/app
83+
84+
USER app:app
85+
86+
VOLUME /var/www
87+
88+
WORKDIR /var/www/html
89+
90+
EXPOSE 9001
91+
92+
COPY ./docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
93+
94+
ENTRYPOINT [ "docker-entrypoint.sh" ]
95+
CMD [ "php-fpm" ]

0 commit comments

Comments
 (0)