Skip to content

Commit 8127feb

Browse files
committed
Static Content Deployment
1 parent 6ff215d commit 8127feb

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed

5. Deployment Process.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ Build and deploy full steps:
5858
php ./vendor/bin/ece-tools deploy
5959
```
6060
- deploy script uses the values defined by configuration files in the `.magento` directory, then the script deletes the directory and its contents
61+
62+
Note:
63+
> During the deployment process, all connections queue for up to 5 minutes preserving any active sessions and pending actions,
64+
> such as adding to cart or checkout.
65+
> After deployment, the queue is released and connections continue without interruption.
66+
> To use this connection hold to your advantage and reduce downtime to zero, you must configure your project to use the most efficient deploy strategy.
6167
6. Post-deployment: configure routing
6268
- creates backup (BAK) files for the app/etc/env.php and the app/etc/config.php configuration files
6369
- execute commands after deploying your application and after the container begins accepting connections

6. Static Content Deployment.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,109 @@
22

33
#### 6.1 Demonstrate ability to move SCD to build phase
44

5+
###### Describe the default process of generating SCD and how it impacts downtime
6+
7+
The default strategy generates static content during the deploy phase when the site is in maintenance mode;
8+
This deployment strategy takes time to write the content directly to the mounted pub/static directory.
9+
10+
###### Describe the reason for moving generation static content to the build phase. Consider the way to do this and show the result (timeline)
11+
12+
> Generating static content during the build phase with minified HTML is the optimal configuration for zero-downtime deployments, also known as the ideal state. Instead of copying files to a mounted drive, it creates a symlink from the ./init/pub/static directory.
13+
>
14+
> By default, the STATIC_CONTENT_SYMLINK environment variable is set to true. After generating the static content during the build phase, it creates a symlink to the content folder.
15+
>
16+
> Generating static content requires access to themes and locales. Magento stores themes in the file system, which is accessible during the build phase; however, Magento stores locales in the database.
17+
> The database is not available during the build phase. In order to generate the static content during the build phase, you must use the config:dump command in the package to move locales to the file system. It reads the locales and saves them in the app/etc/config.php file.
18+
19+
To configure your project to generate SCD on build:
20+
21+
22+
23+
Verify your settings by running the Smart wizard for the ideal state.
24+
`php ./vendor/bin/ece-tools wizard:ideal-state`
25+
26+
###### Determine additional configuration that helps decrease deployment time (SKIP_HTML_MINIFICATION)
27+
28+
`SKIP_HTML_MINIFICATION` in the `.magento.env.yaml` file (Default: true, for ece-tools 2002.0.13 and later).
29+
30+
> Enables or disables copying static view files to the <magento_root>/init/ directory at the end of the build stage.
31+
> If set to true files are not copied and HTML minification is available on request.
32+
> Set this value to true to reduce downtime when deploying to Staging and Production environments.
33+
34+
> You can improve the SCD load time during the deployment process if you skip copying the static view files in the var/view_preprocessed directory and generate minified HTML when requested
35+
36+
`SCD_THREADS` - Sets the number of threads for static content deployment. Increasing the number of threads speeds up static content deployment; decreasing the number of threads slows it down.
37+
38+
`SCD_MATRIX` - You can configure multiple locales per theme as long as the theme is not excluded using the SCD_EXCLUDE_THEMES variable during build. This is ideal if you want to speed up the build process by reducing the amount of unnecessary theme files. For example, you can build the magento/backend theme in English and a custom theme in other languages.
39+
40+
```yaml
41+
stage:
42+
build:
43+
SCD_MATRIX:
44+
"magento/backend":
45+
language:
46+
- en_US
47+
- nb_NO
48+
# not deploy a theme:
49+
"magento/blank": [ ]
50+
```
51+
52+
`STATIC_CONTENT_SYMLINK` (Default: true) Generates symlinks for static content. This setting is vital in the Pro Production environment for the three-node cluster.
53+
When this variable is set to false, it must copy every file during the deployment, which increases deployment time. Setting SCD_ON_DEMAND to true disables this variable.
54+
55+
If you generate static content during the build phase, it creates a symlink to the content folder.
56+
If you generate static content during the deploy phase, it writes directly to the content folder.
57+
Generating static content on demand disables this variable.
58+
59+
###### Display time measurements
60+
61+
![csd load](https://devdocs.magento.com/common/images/cloud/scd-load-times.png)
62+
563
#### 6.2 Demonstrate ability to avoid SCD on both phases
664

65+
###### What are causes for avoiding SCD
66+
###### Describe the way to do this in all cases, and the expected result
67+
68+
`SKIP_SCD` in the `.magento.env.yaml` - skips static content deployment during the build/deploy phases
69+
70+
```yaml
71+
stage:
72+
build:
73+
SKIP_SCD: true
74+
# or
75+
deploy:
76+
SKIP_SCD: true
77+
```
78+
779
#### 6.3 Describe how to generate static content on demand
80+
81+
###### Describe the default Magento behavior in Production mode and why the new "mode" was added
82+
###### How does Magento behave when it is set to this "mode"?
83+
###### Know when users can use this configuration and how it works from the Cloud side
84+
###### Display time measurements
85+
86+
`SCD_ON_DEMAND` in the `.magento.env.yaml` file (Default: false) enable generation of static content when requested by a user
87+
88+
> Generating SCD on demand is optimal for a development workflow in the Integration environment.
89+
> It decreases deployment time so that you can quickly review your implementations and run integration tests.
90+
> Enable the SCD_ON_DEMAND environment variable in the global stage of the .magento.env.yaml file.
91+
> The SCD_ON_DEMAND variable overrides all other configurations related to SCD and clears existing content from the ~/pub/static directory.
92+
>
93+
> When using the SCD on-demand strategy, it helps to preload the cache with pages you expect to request, such as the home page.
94+
> Add your list of expected pages in the WARM_UP_PAGES environment variable in the post-deploy stage of the .magento.env.yaml file.
95+
> (https://devdocs.magento.com/guides/v2.3/cloud/deploy/static-content-deployment.html)
96+
97+
98+
> The SCD_ON_DEMAND variable skips the SCD and the STATIC_CONTENT_SYMLINK in both phases (build and deploy),
99+
> clears the pub/static and var/view_preprocessed folders, and writes the following to the app/etc/env.php file:
100+
```php
101+
return array(
102+
...
103+
'static_content_on_demand_in_production' => 1,
104+
...
105+
);
106+
```
107+
108+
Documentation:
109+
- [Cloud deployment process](https://devdocs.magento.com/guides/v2.3/cloud/deploy/cloud-deployment-process.html)
110+
- [Reduce downtime](https://devdocs.magento.com/guides/v2.3/cloud/deploy/reduce-downtime.html)

0 commit comments

Comments
 (0)