Choosing a deploy strategy

Deployment strategies differ based on whether you choose to generate static content during the build phase, the deploy phase, or on-demand. As seen in the following chart, generating static content during the deploy phase is the least optimal choice. Even with minified HTML, each content file must be copied to the mounted ~/pub/static directory, which can take a long time. Generating static content on demand seems like the optimal choice. However, if the content file does not exist in the cache it generates at the moment it is requested, which adds load time to the user experience. Therefore, generating static content during the build phase is the most optimal.

SCD Load Comparison

Setting the SCD on build

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.

Generating static content requires access to themes and locales. Adobe Commerce stores themes in the file system, which is accessible during the build phase; however, Adobe Commerce stores locales in the database. 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 ece-tools package to move locales to the file system. It reads the locales and saves them in the app/etc/config.php file.

To configure your project to generate SCD on build:

  1. On your local workstation, change to your project directory.

  2. Use SSH to log in to the remote environment.

    magento-cloud ssh
    
  3. Move locales to the file system, then update the config.php file.

  4. The .magento.env.yaml configuration file should contain the following values:

  5. Verify configuration of the Post-deploy hook in the .magento.app.yaml file.

  6. Verify your settings by running the Smart wizard for the ideal state.

    php ./vendor/bin/ece-tools wizard:ideal-state