How to Deploy a Shopware Project
require 'recipe/shopware.php';
Deployer is a free and open source deployment tool written in PHP. It helps you to deploy your Shopware 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.
The deploy task of Shopware consists of:
- deploy:prepare – Prepares a new release
- deploy:info – Displays info about deployment
- deploy:setup – Prepares host for deploy
- deploy:lock – Locks deploy
- deploy:release – Prepares release
- deploy:update_code – Updates code
- deploy:env – Configure .env file
- deploy:shared – Creates symlinks for shared files and dirs
- deploy:writable – Makes writable dirs
- sw:writable:jwt –
- sw:deploy –
- deploy:clear_paths – Cleanup files and/or directories
- sw:cache:warmup –
- deploy:publish – Publishes the release
- deploy:symlink – Creates symlink to release
- deploy:unlock – Unlocks deploy
- deploy:cleanup – Cleanup old releases
- deploy:success – Deploys your project
The shopware recipe is based on the common recipe.
Usage
Add repository
to your deploy.php file:
set('repository', 'git@github.com:shopware/production.git');
configure host:
host('SSH-HOSTNAME')
->set('remote_user', 'SSH-USER')
->set('deploy_path', '/var/www/shopware') // This is the path, where deployer will create its directory structure
->set('http_user', 'www-data') // Not needed, if the `user` is the same user, the webserver is running with
->set('http_group', 'www-data')
->set('writable_mode', 'chmod')
->set('writable_recursive', true)
->set('become', 'www-data'); // You might want to change user to execute remote tasks because of access rights of created cache files
Please remember that the installation must be modified so that it can be build without database.
Configuration
bin/console
'{{bin/php}} {{release_or_current_path}}/bin/console'
default_timeout
Overrides default_timeout from recipe/common.php
.
shared_files
Overrides shared_files from recipe/deploy/shared.php
.
These files are shared among all releases.
[
'.env.local',
'install.lock',
'public/.htaccess',
'public/.user.ini',
]
shared_dirs
Overrides shared_dirs from recipe/deploy/shared.php
.
These directories are shared among all releases.
[
'config/jwt',
'files',
'var/log',
'public/media',
'public/thumbnail',
'public/sitemap',
]
writable_dirs
Overrides writable_dirs from recipe/deploy/writable.php
.
These directories are made writable (the definition of "writable" requires attention).
Please note that the files in config/jwt/*
receive special attention in the sw:writable:jwt
task.
[
'config/jwt',
'custom/plugins',
'files',
'public/bundles',
'public/css',
'public/fonts',
'public/js',
'public/media',
'public/sitemap',
'public/theme',
'public/thumbnail',
'var',
]
Tasks
sw:cache:clear
This task remotely executes the cache:clear
console command on the target server.
sw:cache:warmup
This task remotely executes the cache warmup console commands on the target server, so that the first user, who visits the website, doesn't have to wait for the cache to be built up.
sw:database:migrate
This task remotely executes the database:migrate
console command on the target server.
sw:plugin:refresh
sw:scheduled-task:register
sw:theme:refresh
sw:theme:compile
This task is not used per default, but can be used, e.g. in combination with SHOPWARE_SKIP_THEME_COMPILE=1
,
to build the theme remotely instead of locally.
sw:plugin:update:all
sw:writable:jwt
sw:deploy
Grouped SW deploy tasks.
This task is group task which contains next tasks:
- sw:database:migrate
- sw:plugin:refresh
- sw:theme:refresh
- sw:scheduled-task:register
- sw:cache:clear
- sw:plugin:update:all
- sw:cache:clear
deploy
Deploys your project.
This task is group task which contains next tasks:
sw-build-without-db:get-remote-config
sw-build-without-db:build
sw-build-without-db
This task is group task which contains next tasks: