Skip to content

Build and Deploy

You are viewing an outdated version of the documentation.
Click here to switch to the stable version (v6.6), or use the version switcher on the left to navigate between versions.

Build and Deploy

Now that we have set up the repository, we are ready to push changes to your PaaS environment.

The key concept is that your PaaS project is a git repository. Every time you push to that repository, a new version of your store will be created from the source code and deployed. Different environments (e.g., dev-previews, staging, and production) are mapped by corresponding branches.

Push main branch

To push your latest changes, run the following commands from your terminal:

bash
git add .
git commit -m "Applied new configuration"
git push -u shopware main

First, we stage all changes and then add them as a new commit. Then, we push them to our shopware origin (remember, the one for our PaaS environment) on the main branch.

This will trigger a new build with a subsequent deploy consisting of the following steps:

BuildDeploy
Configuration validationHold app requests
Build container imageUnmount live containers
Installing dependenciesMount file systems
Run build hookRun deploy hook
Building app imageServe requests

After both steps have been executed successfully (you will get extensive logging about the process), you will be able to see the deployed store on a link presented at the end of the deployment.

First deployment

The first time the site is deployed, Shopware's command line installer will run and initialize Shopware. It will not run again unless the install.lock file is removed. Do not remove that file unless you want the installer to run on the next deploy.

The installer will create an administrator account with the default credentials.

usernamepassword
adminshopware

Make sure to change this password immediately in your Administration account settings. Not doing so is a security risk.

Manual steps

After the first deploy, some steps must be done manually before the environment is entirely up and running.

JWT keys

The JWT keys, used for the Administration authentication, need to be generated for your project. The keys will be stored securely in the Shopware Paas environment variable storage and should not be committed to the Git repository or be available on the file system.

To generate the keys and add them to the storage, run the following command:

bash
shopware ssh --app=app "bin/console system:generate-jwt-secret --use-env" |\
grep -E "^JWT_(PUBLIC|PRIVATE)_KEY=" |\
while read line ; do \
shopware variable:create --sensitive 1 --level project --name env:$(echo $line | cut -d "=" -f 1) --value $(echo $line | cut -d "=" -f 2-); \
done

Run this command from your project directory so the shopware command knows which project to update.

The command connects to the application server to generate the JWT keys. It then sets the JWT_PUBLIC_KEY and JWT_PRIVATE_KEY as private environment variables.

Finally, execute the shopware redeploy command to proceed with the build-and-deploy process.

Shopware config

By default, Shopware looks for the JWT keys on the file system. The configuration must be updated to use the keys in the environment variables.

If you use the Shopware Flex Paas template, the configuration will be applied automatically.

yaml
 shopware:
   api:
     jwt_key:
       private_key_path: '%env(base64:JWT_PRIVATE_KEY)%'
       public_key_path: '%env(base64:JWT_PUBLIC_KEY)%'

Theme assets

It is a known issue that after the first deployment, theme assets are not compiled during the deployment. For that reason, your store will look unstyled. The Theme Build section explains how to resolve that issue.

Composer authentication

You must authenticate yourself to install extensions from the Shopware store via composer. In your local development environment, this is possible by creating an auth.json file that contains your auth token. However, this file shouldn't be committed to the repository.

The following command adds your authentication token to the secure environment variable storage of Shopware Paas. This variable (contains the content which would otherwise be in auth.json) will be available during the build step and be automatically picked up by the composer.

bash
shopware variable:create --level project --name env:COMPOSER_AUTH --json true --visible-runtime false --sensitive true --visible-build true --value '{"bearer": {"packages.shopware.com": "%place your key here%"}}'

Make sure to replace %place your key here% with your actual token. You can find your token by clicking 'Install with Composer' in your Shopware Account.

Extending Shopware - plugins and apps

The PaaS recipe uses the Composer plugin loader.

Manually trigger rebuilds

Sometimes, you might want to trigger a rebuild and deploy of your environment without pushing new code to your project. To do this for your main environment, create a REBUILD_DATE environment variable. This triggers a build right away to propagate the variable.

bash
shopware variable:create --environment main --level environment --prefix env --name REBUILD_DATE --value "$(date)" --visible-build true

To force a rebuild at any time, update the variable with a new value:

bash
shopware variable:update --environment main --value "$(date)" "env:REBUILD_DATE"

This forces your application to be built even if no code has changed.