kellerkinderDE / deployer-shopware5

Deployer base config to setup our shopware deployment
MIT License
9 stars 1 forks source link

deployer for shopware

This repository contains a deployer configuration for shopware.

Preparations

Repository

Copy the contents of this repository to your shop project. Within your shop project download the latest composer.phar and deployer.phar to the bin directory. Also download the latest cachetool.phar if you need to reset an OPCache.

The web directory will be used as shopware root directory. Place all custom files for your shopware project here, e.g. plugins and custom themes.

We recommend to use K10rProject for database migrations (via NetcomMigrations) and snippet management so this config depends on it. Please add it to your repository if you want to use it. However if you don't need it you will need to remove it from the plugin list in deploy.php and remove the command k10r:snippets:update in the task kellerkinder:shopware:config.

Configurations

deploy-hosts.yaml

This file defines the different hosts you may want to deploy to. Adjust those hosts to your needs. See deployer documentation for further information.

deploy.php

This file defines the basic configuration via deployers set-method. Make sure to adjust the following options to your needs:

kellerkinder tasks (deploy-shopware.php)

kellerkinder:shopware:install

Wrapper task for the basic installations steps:

kellerkinder:shopware:download

Downloads the defined shopware installation package, unpacks it and rsyncs it into the shopware root directory.

kellerkinder:vendors

Requires some plugins via composer. In this example config those will be K10rStaging and K10rDeployment

Note: They will not be installed yet.

kellerkinder:shopware:update

This task will check wether the currently installed shopware version matches the shopware_update_version (see above) and will download the shopware update package and update the shop if needed.

kellerkinder:shopware:configure

This tasks wraps several configuration steps:

kellerkinder:shopware:opcache

This will reset the OPCache using cachetool.phar and the fcgi_sockets specified in the deploy.php

kellerkinder:shopware:plugins

This will (re)install K10rDeployment which gives us some useful commands for the deployment process. Afterwards it deactivates SwagUpdate since we do not want anyone to install an update via backend. And most importantly it installs and updates all plugins specified in the plugins variable in deploy.php.

This task will also configure plugins according to the plugin_config variable in deploy.php.

kellerkinder:shopware:config

This step will import and update the snippets defined via K10rProject. It will also be used to set configurations that should be the same in all stages. Add your own configurations via shopware_config in deploy.php. For more information on how to set configurations check K10rDeployment.

kellerkinder:shopware:cache

Clears the cache using sw:cache:clear and compiles the themes afterwards. Can also be used to warm up the cache which is not activated by default. It can be activated by setting warm_cache_after_deployment to true in the deploy.php.

kellerkinder:shopware:production and kellerkinder:shopware:staging

These two commands are used to set configurations that differ between the stages.

The staging task will for example install and activate K10rStaging which will show a notice that the user is in a staging environment and catch mails.

This task also sets the shop name and title to DEV!!! via k10r:store:update. This is configurable in the deploy-hosts.yml.

These tasks are usually used to set plugin configurations differing between stage and production, e.g. PayPal in production or sandbox mode. Or to deactivate a tracking plugin that will only be used production.

Directories on the server

Within your deploy path deployer will create several directories:

The shared directories and files are configured in deploy-shopware.php. You can add more by using add in the deploy.php, e.g. add('shared_files', ['{{shopware_public_dir}}/.htaccess']);.

GitLab CI

Since we use GitLab CI to manage our code and deploy the projects we also ship the .gitlab-ci.yml.example which will work perfectly together with this deployer config.

To get this to work you will need some configuration in GitLab:

Contribution

Feel free to send pull requests if you have any optimizations. They will be highly appreciated.

License

MIT licensed, see LICENSE