Deploy variables

The following deploy variables control actions in the deploy phase and can inherit and override values from the Global variables. Insert these variables in the deploy stage of the .magento.env.yaml file:

stage:
  deploy:
    DEPLOY_VARIABLE_NAME: value

For more information about customizing the build and deploy process:

CACHE_CONFIGURATION

  • DefaultNot set
  • Version—Magento 2.1.4 and later

Configure Redis page and default caching. When setting the cm_cache_backend_redis parameter, you must specify the server, port, and database options.

stage:
  deploy:
    CACHE_CONFIGURATION:
      frontend:
        default:
          backend: file
        page_cache:
          backend: file

By default, the deployment process overwrites all settings in the env.php file; however, you can choose to merge one or more values for a service configuration without overwriting all of the values.

Set the _merge option to one of the following:

  • trueMerge the configured service values with the environment variable values.
  • falseOverwrite the configured service values with the environment variable values.

The following example merges new values to an existing configuration:

stage:
  deploy:
    CACHE_CONFIGURATION:
      _merge: true
      frontend:
        default:
          backend:
            database: 10
        page_cache:
          backend:
            database: 11

CLEAN_STATIC_FILES

  • Defaulttrue
  • Version—Magento 2.1.4 and later

Enables or disables cleaning static content files generated during the build or deploy phase. We recommend the default value true in development.

  • true—Removes all existing static content before deploying the updated static content.
  • false—The deployment only overwrites existing static content files if the generated content contains a newer version.

If you make modifications to static content through a separate process, set the value to false.

stage:
  deploy:
    CLEAN_STATIC_FILES: false

Failure to clean static view files before deploying can cause problems if you deploy updates to existing files without removing the previous versions. Because of static file fallback rules, fallback operations can display the wrong file if the directory contains multiple versions of the same file.

CRON_CONSUMERS_RUNNER

  • Defaultcron_run = false, max_messages = 1000
  • Version—Magento 2.2.0 and later

Use this environment variable to make sure message queues are running after a deployment.

  • cron_run—A boolean value that enables or disables the consumers_runner cron job (default = false).
  • max_messages—A number specifying the maximum number of messages each consumer must process before terminating (default = 1000). Although we do not recommend it, you can use 0 to prevent the consumer from terminating.
  • consumers—An array of strings specifying which consumer(s) to run. An empty array runs all consumers.
stage:
  deploy:
    CRON_CONSUMERS_RUNNER:
      cron_run: true
      max_messages: 1000
      consumers:
        - consumer1
        - consumer2

By default, the deployment process overwrites all settings in the env.php file. Refer to Manage message queues for more information about how this works in Magento Open Source and Magento Commerce.

To see a list of message queue consumers:

./bin/magento queue:consumers:list

CRYPT_KEY

  • DefaultNot set
  • Version—Magento 2.1.4 and later

Use the Project Web UI to set this value. When you move the database from one environment to another without an installation process, you need the corresponding cryptographic information. Magento uses the encryption key value set in the Web UI as the crypt/key value in the env.php file. This does not overwrite an existing encryption key value in the env.php file.

DATABASE_CONFIGURATION

  • DefaultNot set
  • Version—Magento 2.1.4 and later

If you defined a database in the relationships property of the .magento.app.yaml file, you can customize your database connections for deployment.

stage:
  deploy:
    DATABASE_CONFIGURATION:
      some_config: 'some_value'

By default, the deployment process overwrites all settings in the env.php file; however, you can choose to merge one or more values for a service configuration without overwriting all of the values.

Set the _merge option to one of the following:

  • trueMerge the configured service values with the environment variable values.
  • falseOverwrite the configured service values with the environment variable values.

The following example merges new values to an existing configuration:

stage:
  deploy:
    DATABASE_CONFIGURATION:
      some_config: 'some_new_value'
      _merge: true

ENABLE_GOOGLE_ANALYTICS

  • Defaultfalse
  • Version—Magento 2.1.4 and later

Enables and disables Google Analytics when deploying to Staging and Integration environments. By default, Google Analytics is true only for the Production environment. Set this value to true to enable Google Analytics in the Staging and Integration environments.

  • true—Enables Google Analytics on Staging and Integration environments.
  • false—Disables Google Analytics on Staging and Integration environments.

Add the ENABLE_GOOGLE_ANALYTICS environment variable to the deploy stage in the .magento.env.yaml file:

stage:
  deploy:
    ENABLE_GOOGLE_ANALYTICS: true 

The Magento Commerce Cloud deploy process always enables Google Analytics on Production environments.

MYSQL_USE_SLAVE_CONNECTION

  • Defaultfalse
  • Version—Magento 2.1.4 and later

Magento can read multiple databases asynchronously. Set to true to automatically use a read-only connection to the database to receive read-only traffic on a non-master node. This improves performance through load balancing, because only one node needs to handle read-write traffic. Set to false to remove any existing read-only connection array from the env.php file.

stage:
  deploy:
    MYSQL_USE_SLAVE_CONNECTION: true

QUEUE_CONFIGURATION

  • DefaultNot set
  • Version—Magento 2.1.4 and later

Use this environment variable to retain customized AMQP service settings between deployments. For example, if you prefer using an existing message queue service, like RabbitMQ, instead of relying on Magento Commerce Cloud to create it for you, use the QUEUE_CONFIGURATION environment variable to connect it to your site:

stage:
  deploy:
    QUEUE_CONFIGURATION:
      amqp:
        host: test.host
        port: 1234
      amqp2:
        host: test.host2
        port: 12345
      mq:
        host: mq.host
        port: 1234

By default, the deployment process overwrites all settings in the env.php file; however, you can choose to merge one or more values for a service configuration without overwriting all of the values.

Set the _merge option to one of the following:

  • trueMerge the configured service values with the environment variable values.
  • falseOverwrite the configured service values with the environment variable values.

The following example merges new values to an existing configuration:

stage:
  deploy:
        QUEUE_CONFIGURATION:
          _merge: true
          amqp:
            host: changed1.host
            port: 5672
          amqp2:
            host: changed2.host2
            port: 12345
          mq:
            host: changedmq.host
            port: 1234

REDIS_USE_SLAVE_CONNECTION

  • Defaultfalse
  • Version—Magento 2.1.4 and later

Magento can read multiple Redis instances asynchronously. Set to true to automatically use a read-only connection to a Redis instance to receive read-only traffic on a non-master node. This improves performance through load balancing, because only one node needs to handle read-write traffic. Set to false to remove any existing read-only connection array from the env.php file.

stage:
  deploy:
    REDIS_USE_SLAVE_CONNECTION: true

You must have a Redis service configured in the .magento.app.yaml file and in the services.yaml file.

The read-only connection is not available for use in the Integration environment or if you use the CACHE_CONFIGURATION variable.

SCD_COMPRESSION_LEVEL

  • Default6
  • Version—Magento 2.1.4 and later

Specifies which gzip compression level (0 to 9) to use when compressing static content; 0 disables compression.

stage:
  deploy:
    SCD_COMPRESSION_LEVEL: 4

SCD_EXCLUDE_THEMES

  • DefaultNot set
  • Version—Magento 2.1.4 and later

Themes can include numerous files. Set this variable to true if you want to skip copying over theme files during deployment. For example, the Luma theme is included with Magento Commerce Cloud. You may not need to constantly deploy this theme with your code updates and deployments. To exclude the magento/luma theme:

stage:
  deploy:
    SCD_EXCLUDE_THEMES: "magento/luma, magento/my-theme"

SCD_MATRIX

  • DefaultNot set
  • Version—Magento 2.1.4 and later

You can configure multiple locales per theme as long as the theme is not excluded using the SCD_EXCLUDE_THEMES variable during deployment. This is ideal if you want to speed up the deployment process by reducing the amount of unnecessary theme files. For example, you can deploy the magento/backend theme in English and a custom theme in other languages.

The following example deploys the Magento/backend theme with three locales:

stage:
  deploy:
    SCD_MATRIX:
      "Magento/backend":
        language:
          - en_US
          - fr_FR
          - af_ZA

Also, you can choose to not deploy a theme:

stage:
  deploy:
    SCD_MATRIX:
      "Magento/backend": [ ]

SCD_STRATEGY

  • Defaultquick
  • Version—Magento 2.2.0 and later

Allows you to customize the deployment strategy for static content. See Deploy static view files.

Use these options only if you have more than one locale:

  • standard—deploys all static view files for all packages.
  • quick—minimizes deployment time. This is the default command option, if not specified.
  • compact—conserves disk space on the server. In Magento version 2.2.4 and earlier, this setting overrides the value for scd_threads with a value of 1.
stage:
  deploy:
    SCD_STRATEGY: "compact"

SCD_THREADS

  • Default:
    • 1—Starter environments and Pro Integration environments
    • 3—Pro Staging and Production environments
  • Version—Magento 2.1.4 and later

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.

stage:
  deploy:
    SCD_THREADS: 2

To further reduce deployment time, we recommend using Configuration Management with the scd-dump command to move static deployment into the build phase.

SEARCH_CONFIGURATION

  • DefaultNot set
  • Version—Magento 2.1.4 and later

Use this environment variable to retain customized search service settings between deployments. For example:

stage:
  deploy:
   SEARCH_CONFIGURATION:
     engine: elasticsearch
     elasticsearch_server_hostname: hostname
     elasticsearch_server_port: '123456'
     elasticsearch_index_prefix: magento
     elasticsearch_server_timeout: '15'

By default, the deployment process overwrites all settings in the env.php file; however, you can choose to merge one or more values for a service configuration without overwriting all of the values.

Set the _merge option to one of the following:

  • trueMerge the configured service values with the environment variable values.
  • falseOverwrite the configured service values with the environment variable values.

The following example merges a new value to the existing configuration:

stage:
  deploy:
    SEARCH_CONFIGURATION:
      engine: elasticsearch
      elasticsearch_server_port: '1234'
      _merge: true

SESSION_CONFIGURATION

  • DefaultNot set
  • Version—Magento 2.1.4 and later

Configure Redis session storage. You must specify the save, redis, host, port, and database options for the session storage variable. For example:

stage:
  deploy:
    SESSION_CONFIGURATION:
      redis:
        bot_first_lifetime: 100
        bot_lifetime: 10001
        database: 0
        disable_locking: 1
        host: redis.internal
        max_concurrency: 10
        max_lifetime: 10001
        min_lifetime: 100
        port: 6379
      save: redis

By default, the deployment process overwrites all settings in the env.php file; however, you can choose to merge one or more values for a service configuration without overwriting all of the values.

Set the _merge option to one of the following:

  • trueMerge the configured service values with the environment variable values.
  • falseOverwrite the configured service values with the environment variable values.

The following example merges a new value to the existing configuration:

stage:
  deploy:
    SESSION_CONFIGURATION:
      _merge: true
      redis:
        max_concurrency: 10

SKIP_SCD

  • DefaultNot set
  • Version—Magento 2.1.4 and later

Set to true to skip static content deployment during the deploy phase.

We recommend setting this option to true because running static content deployment during the deploy phase can significantly increase deployment times and downtime for your live site.

stage:
  deploy:
    SKIP_SCD: true
  • Defaulttrue
  • Version—Magento 2.1.4 and later

Generates symlinks for static content. This setting is vital in the Pro Production environment for the three-node cluster. 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.

If you generate static content during the build phase, it creates a symlink to the content folder. If you generate static content during the deploy phase, it writes directly to the content folder. Generating static content on demand disables this variable.

stage:
  deploy:
    STATIC_CONTENT_SYMLINK: false

UPDATE_URLS

  • Defaulttrue
  • Version—Magento 2.1.4 and later

On deployment, replace Magento base URLs in the database with project URLs. This is useful for local development, where base URLs are set up for your local environment. When you deploy to a Cloud environment, we change the URLs so you can access your storefront and Magento Admin using project URLs.

stage:
  deploy:
    UPDATE_URLS: false

You should set this variable to false only in Staging or Production environments, where the base URLs cannot change. For Pro, we already set this to false for you.

VERBOSE_COMMANDS

  • DefaultNot set
  • Version—Magento 2.1.4 and later

Enables or disables the Symfony debug verbosity level for your logs. Choose the level of detail provided in the logs: -v, -vv, or -vvv.

stage:
  deploy:
    VERBOSE_COMMANDS: "-vv"