As we know Magento cloud is a flexible ecommerce platform in a cloud hosting environment. It Provides a git-based workflow with automatic build and deployment. But it has an issue with automatic build and deployment.
Takes time to complete automatic deploy
Development time gets increased
Downtime gets increased
How does Deployment work in Magento Cloud?
- By default, it generates static content during the deployment phase when the site is in maintenance mode
- The site will be Offline until the deployment is complete
- Deploy time depends on
- Size of the site
- Number of changes applied and
- Static content deployment configuration
- During the deployment process, all connections queue for up to 5 minutes
- After deployment the queue released
What happens when a failure occurs during the build phase?
The site will be in Maintenance mode?
Site shows an error in frontend?
Answer: Works fine – No downtime because it never begins the deploy phase.
Follow the below simple steps to implement zero downtime with Magento cloud deployment.
Step 1: Upgrade Ece-Tools
Update the metapackage to the latest version with the following command,
composer require “magento/magento-cloud-metapackage”:”>=2.4.3 <2.4.5″ –no-update
composer update magento/magento-cloud-metapackage
Remove deprecated packages with the below commands,
composer remove magento/magento-cloud-configuration
composer remove magento/ece-patches
Update the ece-tools package with the following command,
composer update magento/ece-tools
Add and commit the code changes of the following files,
Step 2: Create A System-Specific Configuration:
Connect to SSH( ssh <project-id-integration>@ssh.us.magentosite.cloud
) and run the following command.
Download the generated/updated config.php file from the server, add it in local setup and commit this file to the cloud.
Step 3: SCD (Static Content Deployment)
3 types of SCD with Magento cloud: build phase, the deploy phase, or on-demand
Step 4: Reduce Theme Files:
Step 5: Speed Up Static Content Deployment:
Note: Max-value – 4
Here is the final script of .magento.env.yaml file.