Deployment

Introduction

For our Shopware cluster, deploying Shopware via a pipeline is mandatory to ensure that all affected app servers receive the same updates.

For optimal deployment, we recommend using our GitLab hosting.


Prerequisites

  • creoline Shopware cluster
  • GitLab with at least one active GitLab runner
  • SSH access to all app servers via the deployer user



Folder Structure

After deployment by us, the following folder structure exists on all app servers:

/var/www/shop.com/
│
├── current -> releases/test-release-2
│
├── releases
│   ├── test-release-1
│   └── test-release-2
│
└── shared
    ├── config
    │    └── jwt
    │ 
 ├── custom
    │    ├── plugins
    │    └── apps
    │
    ├── files
    │
    ├── public
    │   ├── media
    │   ├── thumbnail
    │   ├── theme
    │   └── sitemap
    │
    └── var
 └── log


The releases folder allows you to deploy multiple releases and activate or deactivate them via the active symbolic link. The symbolic link current points to the desired active release.



App Server Definition

For our Shopware cluster, there are two types of app servers:


  1. App Server Master
  2. App Server Slave


The App Server Master provides the following functions:

  • Shopware Administration (Admin Traffic)
  • Shopware Message Queue
  • Cron jobs / internal tasks


The App Server Slave provides the following functions:

  • Shopware Storefront (visitor traffic)



File and Folder Distribution

The following files and directories are made available to all other app servers via the App Server Master:


Shared Files

.env.local
install.lock
public/.htaccess
auth.json


Shared Directories

config/jwt
files
var/log

public/media
public/thumbnail
public/sitemap
public/theme

custom/plugins
custom/apps



Deployment Steps

The following steps are required for deployment:


  1. All: Create the new release folder
  2. All: Deploy all files and folders within the new release folder
  3. Master: Run the database migrations
  4. Master: Update the plugin list sw:plugin:update:all
  5. Master: Run the theme compilation sw:theme:compile
  6. All: Run asset installation sw:assets:install
  7. All: Clear the cache sw:cache:clear
  8. All: Clear OpCache (More information)
  9. All: Update symlinks



Additional Notes

Console Command sw:theme:compile

This command must only be executed on the App Server Master, as Shopware has generated a random hash for each compilation since Shopware 6.5. Executing the command on other servers will invalidate the compiled theme on those servers.



Examples

Deployer with GitLab Pipelines

Deployer (https://deployer.org/) is ideal for deploying Shopware 6 on our Shopware cluster. The example provided here was developed by our partner, webimpact GmbH.


GitHub Repository:

https://github.com/creoline/shopware-deployer-example