In Adobe Commerce, formerly known as Magento, the magento.app.yaml
file is a crucial component for configuring the environment and defining settings specific to your Adobe Commerce instance. This file is part of the Magento Cloud infrastructure, designed to streamline deployment and management processes.
Here’s a breakdown of what you might find in a typical magento.app.yaml
file:
- Environment Configuration: The file allows you to define different configurations for various environments such as production, staging, and development. Each environment can have its own set of settings like cache configurations, logging levels, etc.
- Services: It specifies the services required for your Adobe Commerce application. These services could include databases, caches, search engines, etc. Each service is configured with its own set of parameters like version, type, and settings.
- Routes: You can define custom routes for your application. This includes specifying which URL patterns should be routed to which services or controllers within your application. This allows for URL rewriting and mapping to specific functionality within your Adobe Commerce instance.
- Hooks and Build Processes: The
magento.app.yaml
file also allows you to define hooks and build processes that should be executed during deployment. This could include tasks like compiling static assets, running database migrations, or clearing caches. - Environment Variables: You can specify environment variables that should be available to your Adobe Commerce application. This is useful for configuring sensitive information like API keys, database credentials, etc., without hardcoding them into your codebase.
- Application Configuration: Finally, you can specify various application-level configurations such as cron job settings, session storage options, and more.
Here’s a simple example of what a magento.app.yaml
file might look like:
#Application name
name: magento
#php version
type: php:7.4
# The size of the persistent disk of the application (in MB).
disk: 2048
hooks:
# We run build hooks before your application has been packaged.
build:
set -e
php ./vendor/bin/ece-tools build:generate
php ./vendor/bin/ece-tools build:transfer
# The mounts that will be performed when the package is deployed.
mounts:
"/pub/media": "shared:files/media"
"/var/log": "shared:files/log"
variables:
env:
PAYMENT_BROKER_DOMAIN: "payment-broker.xyzservice.com"
services:
mysql:
type: mysql:10.4
disk: 2048
In this example:
- It specifies the PHP version to be used (
php:7.4
).- Set -e causes hooks to fail on the first failed command, instead of the final failed command for build phase
- build:generate – applies patches, validates configuration, generates DI, and generates static content if SCD is enabled for build phase.
- build:transfer – transfers generated code and static content to the final destination for build phase.
- It mounts specific directories for media and log files.
- It sets environment variables.
- It configures a MySQL service.
The magento.app.yaml
file serves as a central configuration point for your Adobe Commerce application, allowing you to easily manage and deploy your environment across different stages of development.