Skip to content

Commit 37e961e

Browse files
committed
Update docs
1 parent 542b2b6 commit 37e961e

File tree

9 files changed

+308
-82
lines changed

9 files changed

+308
-82
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ RUN php -d memory_limit=2G bin/magento setup:static-content:deploy \
3030

3131
RUN mv app/etc/env.php.bak app/etc/env.php
3232

33+
RUN rm -rf var/*
34+
3335
COPY docs/docker/php/custom.ini /usr/local/etc/php/conf.d/custom.ini
3436
COPY docs/docker/php/www.conf /usr/local/etc/php-fpm.d/www.conf
3537

docs/.vitepress/config.mts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ const config = defineConfig({
1515
{ text: 'Introduction', link: '/guide/introduction' },
1616
{ text: 'Requirements', link: '/guide/requirements' },
1717
{
18-
text: 'Preparation',
18+
text: '📚 Preparation',
19+
collapsed: false,
1920
items: [
2021
{ text: 'Environment variables', link: '/guide/preparation/environment-variables' },
2122
]
2223
},
2324
{
24-
text: 'Build',
25+
text: '⚙️ Build',
26+
collapsed: false,
2527
items: [
2628
{ text: 'Introduction', link: '/guide/build/introduction' },
2729
{ text: 'Docker image', link: '/guide/build/docker' },
@@ -31,11 +33,14 @@ const config = defineConfig({
3133
]
3234
},
3335
{
34-
text: 'Deployment',
36+
text: '🚀 Deployment',
37+
collapsed: false,
3538
items: [
3639
{ text: 'Introduction', link: '/guide/deployment/introduction' },
3740
{ text: 'External services', link: '/guide/deployment/external-services' },
3841
{ text: 'Architecture', link: '/guide/deployment/architecture' },
42+
{ text: 'Resources and scaling', link: '/guide/deployment/resources-scaling' },
43+
{ text: 'Helm chart', link: '/guide/deployment/helm-chart' },
3944
]
4045
}
4146
],

docs/docker/nginx/vhost.nginx

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ log_format nginxlog_json escape=json
2323

2424
server {
2525
listen 80;
26-
server_name <your-magento-hostname>;
26+
2727
set $MAGE_ROOT /app;
2828
set $MAGE_DEBUG_SHOW_ARGS 0;
2929

@@ -43,50 +43,12 @@ server {
4343

4444
# PHP entry point for setup application
4545
location ~* ^/setup($|/) {
46-
root $MAGE_ROOT;
47-
location ~ ^/setup/index.php {
48-
fastcgi_pass fastcgi_backend;
49-
50-
fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
51-
fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=600";
52-
fastcgi_read_timeout 600s;
53-
fastcgi_connect_timeout 600s;
54-
55-
fastcgi_index index.php;
56-
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
57-
include fastcgi_params;
58-
}
59-
60-
location ~ ^/setup/(?!pub/). {
61-
deny all;
62-
}
63-
64-
location ~ ^/setup/pub/ {
65-
add_header X-Frame-Options "SAMEORIGIN";
66-
}
46+
deny all;
6747
}
6848

6949
# PHP entry point for update application
7050
location ~* ^/update($|/) {
71-
root $MAGE_ROOT;
72-
73-
location ~ ^/update/index.php {
74-
fastcgi_split_path_info ^(/update/index.php)(/.+)$;
75-
fastcgi_pass fastcgi_backend;
76-
fastcgi_index index.php;
77-
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
78-
fastcgi_param PATH_INFO $fastcgi_path_info;
79-
include fastcgi_params;
80-
}
81-
82-
# Deny everything but index.php
83-
location ~ ^/update/(?!pub/). {
84-
deny all;
85-
}
86-
87-
location ~ ^/update/pub/ {
88-
add_header X-Frame-Options "SAMEORIGIN";
89-
}
51+
deny all;
9052
}
9153

9254
location / {
@@ -179,7 +141,6 @@ server {
179141

180142
# PHP entry point for main application
181143
location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ {
182-
try_files $uri =404;
183144
fastcgi_pass fastcgi_backend;
184145
fastcgi_buffers 16 16k;
185146
fastcgi_buffer_size 32k;

docs/docker/php/custom.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
date.timezone = Etc/UTC
2-
# Recommended value by Magento / Adobe Commerce
2+
; Recommended value by Magento / Adobe Commerce
33
memory_limit = 756M
44
log_errors = On
55
display_errors = Off
@@ -14,13 +14,13 @@ opcache.interned_strings_buffer = 32
1414
opcache.max_accelerated_files = 130987
1515
opcache.enable_file_override = 1
1616

17-
# When set to 0, you'll need to restart the PHP process to apply changes to PHP files, which should never happen in production
17+
; When set to 0, you'll need to restart the PHP process to apply changes to PHP files, which should never happen in production
1818
opcache.consistency_checks = 0
1919
opcache.validate_timestamps = 0
2020

2121
realpath_cache_size = 10M
2222
realpath_cache_ttl = 7200
2323

24-
# Increase the maximum file upload size ; those should be set according to your needs (i.e. for image uploads from admin)
24+
; Increase the maximum file upload size ; those should be set according to your needs (i.e. for image uploads from admin)
2525
upload_max_filesize = 20M
2626
post_max_size = 20M

docs/docker/php/www.conf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ group = www-data
55
listen = 127.0.0.1:9000
66

77
pm = static
8-
pm.max_children = 10 # Or use an environment variable, such as ${PHP_FPM_MAX_CHILDREN}
8+
; Or use an environment variable, such as ${PHP_FPM_MAX_CHILDREN}
9+
pm.max_children = 10
910
pm.status_path = /status
10-
# Useful to avoid memory leaks ; processes will be restarted after handling 10 requests
11+
; Useful to avoid memory leaks ; processes will be restarted after handling 10 requests
1112
pm.max_requests = 10
1213

13-
# Useful to send logs from all workers to the main process, which will then send them to stdout
14+
; Useful to send logs from all workers to the main process, which will then send them to stdout
15+
; Note that those are usually already defined in /usr/local/etc/php-fpm.d/docker.conf shipped with PHP FPM docker image
1416
catch_workers_output = yes
1517
decorate_workers_output = no

docs/guide/build/docker.md

Lines changed: 83 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ bin/magento app:config:dump scopes themes i18n
202202
```
203203

204204
> [!IMPORTANT]
205-
> This command should be run outside of the Docker image, as it requires a database connection.
205+
> This command should be run outside the Docker image, as it requires a database connection.
206206
> The resulting `config.php` should be added to the VCS, so it's available when building the Docker image.
207207
208208
> [!NOTE]
@@ -238,7 +238,11 @@ Once the static content is deployed, we can move back the `env.php` file:
238238
RUN mv app/etc/env.php.bak app/etc/env.php
239239
```
240240

241-
## PHP configuration
241+
We can now do some cleanup:
242+
243+
```dockerfile
244+
RUN rm -rf var/*
245+
```
242246

243247
Although the PHP configuration is generally good enough for most cases, you may want to tweak it to your needs.
244248

@@ -284,7 +288,7 @@ COPY www.conf /usr/local/etc/php-fpm.d/www.conf
284288
285289
## nginx
286290

287-
Now that we have our PHP-FPM image ready, we need to add an nginx server to serve our Magento / Adobe Commerce project, communicating with PHP-FPM using fastcgi.
291+
Now that we have our PHP-FPM image ready, we need to add a nginx server to serve our Magento / Adobe Commerce project, communicating with PHP-FPM using fastcgi.
288292

289293
To serve static assets in an efficient way, we'll also copy the `pub/static` directory to the nginx image.
290294

@@ -305,7 +309,9 @@ upstream fastcgi_backend {
305309
306310
server {
307311
listen 80;
308-
server_name <your-magento-hostname>;
312+
313+
# server_name directive is not mandatory, as we're using the default server block
314+
309315
set $MAGE_ROOT /app;
310316
set $MAGE_DEBUG_SHOW_ARGS 0;
311317
@@ -320,33 +326,83 @@ Additionnaly, you may change the following in the resulting `vhost.conf` file:
320326

321327
::: code-group
322328

323-
```nginx [At root level of vhost.conf]
324-
log_format nginxlog_json escape=json
325-
'{ "timestamp": "$time_iso8601", '
326-
'"remote_addr": "$remote_addr", '
327-
'"body_bytes_sent": $body_bytes_sent, '
328-
'"request_time": $request_time, '
329-
'"response_status": $status, '
330-
'"request": "$request", '
331-
'"request_method": "$request_method", '
332-
'"host": "$host",'
333-
'"remote_user": "$remote_user",'
334-
'"request_uri": "$request_uri",'
335-
'"query_string": "$query_string",'
336-
'"upstream_addr": "$upstream_addr",'
337-
'"http_x_forwarded_for": "$http_x_forwarded_for",'
338-
'"http_x_real_ip": "$http_x_real_ip",'
339-
'"http_referrer": "$http_referer", '
340-
'"http_user_agent": "$http_user_agent", '
341-
'"http_version": "$server_protocol" }';
329+
```nginx [vhost.conf]
330+
log_format nginxlog_json escape=json # [!code ++]
331+
'{ "timestamp": "$time_iso8601", ' # [!code ++]
332+
'"remote_addr": "$remote_addr", ' # [!code ++]
333+
'"body_bytes_sent": $body_bytes_sent, ' # [!code ++]
334+
'"request_time": $request_time, ' # [!code ++]
335+
'"response_status": $status, ' # [!code ++]
336+
'"request": "$request", ' # [!code ++]
337+
'"request_method": "$request_method", ' # [!code ++]
338+
'"host": "$host",' # [!code ++]
339+
'"remote_user": "$remote_user",' # [!code ++]
340+
'"request_uri": "$request_uri",' # [!code ++]
341+
'"query_string": "$query_string",' # [!code ++]
342+
'"upstream_addr": "$upstream_addr",' # [!code ++]
343+
'"http_x_forwarded_for": "$http_x_forwarded_for",' # [!code ++]
344+
'"http_x_real_ip": "$http_x_real_ip",' # [!code ++]
345+
'"http_referrer": "$http_referer", ' # [!code ++]
346+
'"http_user_agent": "$http_user_agent", ' # [!code ++]
347+
'"http_version": "$server_protocol" }'; # [!code ++]
348+
349+
server {
350+
...
351+
access_log /dev/stdout nginxlog_json; # [!code ++]
352+
...
353+
}
342354
```
343355

344-
```nginx [Within the server block]
345-
access_log /dev/stdout nginxlog_json;
356+
:::
357+
358+
* Remove unnecessary blocks:
359+
* `location ~* ^/setup($|/) { ... }`
360+
* `location ~* ^/update($|/) { ... }`
361+
362+
* Add a health check endpoint, to be able to monitor the nginx server:
363+
364+
::: code-group
365+
366+
```nginx [vhost.conf]
367+
server {
368+
...
369+
370+
location /nginx-health { # [!code ++]
371+
add_header Content-Type text/plain; # [!code ++]
372+
return 200 'OK'; # [!code ++]
373+
} # [!code ++]
374+
}
346375
```
347376

348377
:::
349378

379+
* Increase the buffers size in the main entry point:
380+
381+
::: code-group
382+
383+
```nginx [vhost.conf]
384+
# PHP entry point for main application
385+
location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ {
386+
fastcgi_buffers 16 16k; # [!code --]
387+
fastcgi_buffer_size 32k; # [!code --]
388+
fastcgi_buffers 16 32k; # [!code ++]
389+
fastcgi_buffer_size 64k; # [!code ++]
390+
fastcgi_busy_buffers_size 64k; # [!code ++]
391+
proxy_buffer_size 128k; # [!code ++]
392+
proxy_buffers 4 256k; # [!code ++]
393+
proxy_busy_buffers_size 256k; # [!code ++]
394+
395+
...
396+
}
397+
```
398+
399+
:::
400+
401+
> [!INFO]
402+
> The complete `vhost.conf` file can be found [here](https://github.com/ClickAndMortar/magento-kubernetes/blob/main/docs/docker/nginx/vhost.nginx).
403+
404+
---
405+
350406
The resulting `Dockefile` should look like this:
351407

352408
```dockerfile
@@ -397,7 +453,8 @@ Then push the images to your container registry, using `docker push`.
397453
> [!TIP]
398454
> When cross-building images for different architectures, you may want to use the `--platform` flag to specify the target architecture, such as `linux/amd64`, `linux/arm64`, etc.
399455
400-
The complete `Dockerfile` can be found [here](https://github.com/ClickAndMortar/magento-kubernetes/blob/main/Dockerfile).
456+
> [!INFO]
457+
> The complete `Dockerfile` can be found [here](https://github.com/ClickAndMortar/magento-kubernetes/blob/main/Dockerfile).
401458
402459
## Tagging strategy
403460

0 commit comments

Comments
 (0)