Manage build and deploy actions

The .magento.env.yaml file centralizes the management of build and deploy actions across all of your environments, including Pro Staging and Production.

Unlike other YAML configuration files, such as .magento.app.yaml, routes.yaml, and services.yaml, you can use this file to manage configuration settings without opening a support ticket.

  • Settings you configure with environment variables using the magento-cloud CLI tool or Project Web Interface override settings in the .magento.env.yaml file.
  • If you want to configure unique actions in each environment, you must modify this file in each environment’s Git branch.

Add the following sections to the .magento.env.yaml file:

  • stage—Contains the global, build, and deploy sections.
  • global—Controls actions in both the build and deploy phases. You can override these settings in the build and deploy sections.
  • build—Controls actions in the build phase only. If you do not specify settings in this section, the build phase uses settings from the global section. Settings in the build_options.ini file override settings in this section.
  • deploy—Controls actions in the deploy phase only. If you do not specify settings in this section, the deploy phase uses settings from the global section. Settings you configure with environment variables using the magento-cloud CLI tool or Project Web Interface override settings in this section.

In each section, you use build options or environment variables to control the build and deploy actions.

Example

The following example shows how to minimize downtime during deployment by managing static content deployment:

stage:
  global:
    SCD_STRATEGY: quick         # Use the "quick" deployment strategy for both the build and deploy phases
    SKIP_SCD: true              # Skip static content deployment for both phases; you can override this in the build and deploy sections
  build:
    SKIP_SCD: false             # Override the global setting and perform static content deployment in the build phase
    SCD_COMPRESSION_LEVEL: 6    # Use the default gzip compression level for static content in the build phase
  deploy:
    SCD_COMPRESSION_LEVEL: 4    # Reduce the gzip compression level for static content in the deploy phase