2023-01-08 20:46:33 +00:00
|
|
|
|
<!-- DO NOT EDIT THIS FILE! -->
|
|
|
|
|
<!-- Instead edit recipe/magento2.php -->
|
|
|
|
|
<!-- Then run bin/docgen -->
|
|
|
|
|
|
|
|
|
|
# How to Deploy a Magento 2 Project
|
|
|
|
|
|
|
|
|
|
```php
|
|
|
|
|
require 'recipe/magento2.php';
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
[Source](/recipe/magento2.php)
|
|
|
|
|
|
|
|
|
|
Deployer is a free and open source deployment tool written in PHP.
|
|
|
|
|
It helps you to deploy your Magento 2 application to a server.
|
|
|
|
|
It is very easy to use and has a lot of features.
|
|
|
|
|
|
|
|
|
|
Three main features of Deployer are:
|
|
|
|
|
- **Provisioning** - provision your server for you.
|
|
|
|
|
- **Zero downtime deployment** - deploy your application without a downtime.
|
|
|
|
|
- **Rollbacks** - rollback your application to a previous version, if something goes wrong.
|
|
|
|
|
|
|
|
|
|
Additionally, Deployer has a lot of other features, like:
|
|
|
|
|
- **Easy to use** - Deployer is very easy to use. It has a simple and intuitive syntax.
|
|
|
|
|
- **Fast** - Deployer is very fast. It uses parallel connections to deploy your application.
|
|
|
|
|
- **Secure** - Deployer uses SSH to connect to your server.
|
|
|
|
|
- **Supports all major PHP frameworks** - Deployer supports all major PHP frameworks.
|
|
|
|
|
|
|
|
|
|
You can read more about Deployer in [Getting Started](/docs/getting-started.md).
|
|
|
|
|
|
|
|
|
|
The [deploy](#deploy) task of **Magento 2** consists of:
|
|
|
|
|
* [deploy:prepare](/docs/recipe/common.md#deployprepare) – Prepares a new release
|
|
|
|
|
* [deploy:info](/docs/recipe/deploy/info.md#deployinfo) – Displays info about deployment
|
|
|
|
|
* [deploy:setup](/docs/recipe/deploy/setup.md#deploysetup) – Prepares host for deploy
|
|
|
|
|
* [deploy:lock](/docs/recipe/deploy/lock.md#deploylock) – Locks deploy
|
|
|
|
|
* [deploy:release](/docs/recipe/deploy/release.md#deployrelease) – Prepares release
|
|
|
|
|
* [deploy:update_code](/docs/recipe/deploy/update_code.md#deployupdate_code) – Updates code
|
|
|
|
|
* [deploy:shared](/docs/recipe/deploy/shared.md#deployshared) – Creates symlinks for shared files and dirs
|
|
|
|
|
* [deploy:writable](/docs/recipe/deploy/writable.md#deploywritable) – Makes writable dirs
|
|
|
|
|
* [deploy:vendors](/docs/recipe/deploy/vendors.md#deployvendors) – Installs vendors
|
|
|
|
|
* [deploy:clear_paths](/docs/recipe/deploy/clear_paths.md#deployclear_paths) – Cleanup files and/or directories
|
|
|
|
|
* [deploy:magento](/docs/recipe/magento2.md#deploymagento) – Magento2 deployment operations
|
|
|
|
|
* [magento:build](/docs/recipe/magento2.md#magentobuild) – Magento2 build operations
|
|
|
|
|
* [magento:compile](/docs/recipe/magento2.md#magentocompile) – Compiles magento di
|
|
|
|
|
* [magento:deploy:assets](/docs/recipe/magento2.md#magentodeployassets) – Deploys assets
|
|
|
|
|
* [magento:config:import](/docs/recipe/magento2.md#magentoconfigimport) – Config Import
|
|
|
|
|
* [magento:upgrade:db](/docs/recipe/magento2.md#magentoupgradedb) – Upgrades magento database
|
|
|
|
|
* [magento:cache:flush](/docs/recipe/magento2.md#magentocacheflush) – Flushes Magento Cache
|
|
|
|
|
* [deploy:publish](/docs/recipe/common.md#deploypublish) – Publishes the release
|
|
|
|
|
* [deploy:symlink](/docs/recipe/deploy/symlink.md#deploysymlink) – Creates symlink to release
|
|
|
|
|
* [deploy:unlock](/docs/recipe/deploy/lock.md#deployunlock) – Unlocks deploy
|
|
|
|
|
* [deploy:cleanup](/docs/recipe/deploy/cleanup.md#deploycleanup) – Cleanup old releases
|
|
|
|
|
* [deploy:success](/docs/recipe/common.md#deploysuccess) –
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The magento2 recipe is based on the [common](/docs/recipe/common.md) recipe.
|
|
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
### static_content_locales
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L23)
|
|
|
|
|
|
|
|
|
|
By default setup:static-content:deploy uses `en_US`.
|
|
|
|
|
To change that, simply put `set('static_content_locales', 'en_US de_DE');`
|
|
|
|
|
in you deployer script.
|
|
|
|
|
|
|
|
|
|
```php title="Default value"
|
|
|
|
|
'en_US'
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### magento_themes
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L29)
|
|
|
|
|
|
|
|
|
|
You can also set the themes to run against. By default it'll deploy
|
|
|
|
|
all themes - `add('magento_themes', ['Magento/luma', 'Magento/backend']);`
|
|
|
|
|
|
|
|
|
|
```php title="Default value"
|
|
|
|
|
[
|
|
|
|
|
|
|
|
|
|
]
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### static_content_jobs
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L37)
|
|
|
|
|
|
|
|
|
|
Also set the number of conccurent jobs to run. The default is 1
|
|
|
|
|
Update using: `set('static_content_jobs', '1');`
|
|
|
|
|
|
|
|
|
|
```php title="Default value"
|
|
|
|
|
'1'
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### content_version
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L39)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```php title="Default value"
|
|
|
|
|
return time();
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### shared_files
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L43)
|
|
|
|
|
|
|
|
|
|
Overrides [shared_files](/docs/recipe/deploy/shared.md#shared_files) from `recipe/deploy/shared.php`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```php title="Default value"
|
|
|
|
|
[
|
|
|
|
|
'app/etc/env.php',
|
|
|
|
|
'var/.maintenance.ip',
|
|
|
|
|
]
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### shared_dirs
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L47)
|
|
|
|
|
|
|
|
|
|
Overrides [shared_dirs](/docs/recipe/deploy/shared.md#shared_dirs) from `recipe/deploy/shared.php`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```php title="Default value"
|
|
|
|
|
[
|
|
|
|
|
'var/composer_home',
|
|
|
|
|
'var/log',
|
|
|
|
|
'var/export',
|
|
|
|
|
'var/report',
|
|
|
|
|
'var/import',
|
|
|
|
|
'var/import_history',
|
|
|
|
|
'var/session',
|
|
|
|
|
'var/importexport',
|
|
|
|
|
'var/backups',
|
|
|
|
|
'var/tmp',
|
|
|
|
|
'pub/sitemap',
|
|
|
|
|
'pub/media',
|
|
|
|
|
'pub/static/_cache'
|
|
|
|
|
]
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### writable_dirs
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L62)
|
|
|
|
|
|
|
|
|
|
Overrides [writable_dirs](/docs/recipe/deploy/writable.md#writable_dirs) from `recipe/deploy/writable.php`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```php title="Default value"
|
|
|
|
|
[
|
|
|
|
|
'var',
|
|
|
|
|
'pub/static',
|
|
|
|
|
'pub/media',
|
|
|
|
|
'generated',
|
|
|
|
|
'var/page_cache'
|
|
|
|
|
]
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### clear_paths
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L69)
|
|
|
|
|
|
|
|
|
|
Overrides [clear_paths](/docs/recipe/deploy/clear_paths.md#clear_paths) from `recipe/deploy/clear_paths.php`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```php title="Default value"
|
|
|
|
|
[
|
|
|
|
|
'generated/*',
|
|
|
|
|
'pub/static/_cache/*',
|
|
|
|
|
'var/generation/*',
|
|
|
|
|
'var/cache/*',
|
|
|
|
|
'var/page_cache/*',
|
|
|
|
|
'var/view_preprocessed/*'
|
|
|
|
|
]
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### magento_version
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L78)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```php title="Default value"
|
|
|
|
|
// detect version
|
|
|
|
|
$versionOutput = run('{{bin/php}} {{release_or_current_path}}/bin/magento --version');
|
|
|
|
|
preg_match('/(\d+\.?)+(-p\d+)?$/', $versionOutput, $matches);
|
|
|
|
|
return $matches[0] ?? '2.0';
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### maintenance_mode_status_active
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L85)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```php title="Default value"
|
|
|
|
|
// detect maintenance mode active
|
|
|
|
|
$maintenanceModeStatusOutput = run("{{bin/php}} {{release_or_current_path}}/bin/magento maintenance:status");
|
|
|
|
|
return strpos($maintenanceModeStatusOutput, MAINTENANCE_MODE_ACTIVE_OUTPUT_MSG) !== false;
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### enable_zerodowntime
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L92)
|
|
|
|
|
|
|
|
|
|
Deploy without setting maintenance mode if possible
|
|
|
|
|
|
|
|
|
|
```php title="Default value"
|
|
|
|
|
true
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### artifact_file
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L229)
|
|
|
|
|
|
|
|
|
|
artifact deployment section
|
|
|
|
|
settings section
|
|
|
|
|
|
|
|
|
|
```php title="Default value"
|
|
|
|
|
'artifact.tar.gz'
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### artifact_dir
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L230)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```php title="Default value"
|
|
|
|
|
'artifacts'
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### artifact_excludes_file
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L231)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```php title="Default value"
|
|
|
|
|
'artifacts/excludes'
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### artifact_path
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L233)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```php title="Default value"
|
|
|
|
|
if (!test('[ -d {{artifact_dir}} ]')) {
|
|
|
|
|
run('mkdir {{artifact_dir}}');
|
|
|
|
|
}
|
|
|
|
|
return get('artifact_dir') . '/' . get('artifact_file');
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### bin/tar
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L240)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:::info Autogenerated
|
|
|
|
|
The value of this configuration is autogenerated on access.
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### additional_shared_files
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L301)
|
|
|
|
|
|
|
|
|
|
Array of shared files that will be added to the default shared_files without overriding
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### additional_shared_dirs
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L303)
|
|
|
|
|
|
|
|
|
|
Array of shared directories that will be added to the default shared_dirs without overriding
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Tasks
|
|
|
|
|
|
|
|
|
|
### magento:compile
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L96)
|
|
|
|
|
|
|
|
|
|
Compiles magento di.
|
|
|
|
|
|
|
|
|
|
Tasks
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### magento:deploy:assets
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L103)
|
|
|
|
|
|
|
|
|
|
Deploys assets.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### magento:sync:content_version
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L116)
|
|
|
|
|
|
|
|
|
|
Syncs content version.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### magento:maintenance:enable
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L126)
|
|
|
|
|
|
|
|
|
|
Enables maintenance mode.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### magento:maintenance:disable
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L131)
|
|
|
|
|
|
|
|
|
|
Disables maintenance mode.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### magento:config:import
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L136)
|
|
|
|
|
|
|
|
|
|
Config Import.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### magento:upgrade:db
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L171)
|
|
|
|
|
|
|
|
|
|
Upgrades magento database.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### magento:cache:flush
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L198)
|
|
|
|
|
|
|
|
|
|
Flushes Magento Cache.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### deploy:magento
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L203)
|
|
|
|
|
|
|
|
|
|
Magento2 deployment operations.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This task is group task which contains next tasks:
|
|
|
|
|
* [magento:build](/docs/recipe/magento2.md#magentobuild)
|
|
|
|
|
* [magento:config:import](/docs/recipe/magento2.md#magentoconfigimport)
|
|
|
|
|
* [magento:upgrade:db](/docs/recipe/magento2.md#magentoupgradedb)
|
|
|
|
|
* [magento:cache:flush](/docs/recipe/magento2.md#magentocacheflush)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### magento:build
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L211)
|
|
|
|
|
|
|
|
|
|
Magento2 build operations.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This task is group task which contains next tasks:
|
|
|
|
|
* [magento:compile](/docs/recipe/magento2.md#magentocompile)
|
|
|
|
|
* [magento:deploy:assets](/docs/recipe/magento2.md#magentodeployassets)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### deploy
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L217)
|
|
|
|
|
|
|
|
|
|
Deploys your project.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This task is group task which contains next tasks:
|
|
|
|
|
* [deploy:prepare](/docs/recipe/common.md#deployprepare)
|
|
|
|
|
* [deploy:vendors](/docs/recipe/deploy/vendors.md#deployvendors)
|
|
|
|
|
* [deploy:clear_paths](/docs/recipe/deploy/clear_paths.md#deployclear_paths)
|
|
|
|
|
* [deploy:magento](/docs/recipe/magento2.md#deploymagento)
|
|
|
|
|
* [deploy:publish](/docs/recipe/common.md#deploypublish)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### artifact:package
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L250)
|
|
|
|
|
|
|
|
|
|
Packages all relevant files in an artifact.
|
|
|
|
|
|
|
|
|
|
tasks section
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### artifact:upload
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L260)
|
|
|
|
|
|
|
|
|
|
Uploads artifact in release folder for extraction.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### artifact:extract
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L265)
|
|
|
|
|
|
|
|
|
|
Extracts artifact in release path.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### build:remove-generated
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L271)
|
|
|
|
|
|
|
|
|
|
Clears generated files prior to building.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### build:prepare
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L276)
|
|
|
|
|
|
|
|
|
|
Prepare local artifact build.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### deploy:additional-shared
|
|
|
|
|
[Source](https://github.com/deployphp/deployer/blob/master/recipe/magento2.php#L307)
|
|
|
|
|
|
|
|
|
|
Adds additional files and dirs to the list of shared files and dirs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|