Prepare your Shopware Project

Our setup is based on Shopware 6 installed using the Symfony flex template and strictly requires all plugins and apps to be installed via composer. The base is shopware/docker, so install it with composer using the following command:

composer req shopware/docker

Afterwards, check the status of your recipes with composer recipes and update if needed with:

composer recipes:update shopware/docker

Refer to https://github.com/shopware/docker/blob/main/README.md for more and detailed information.

Also, we need shopware/deployment-helper for the deployment process, so run:

composer req shopware/deployment-helper

Create a new docker-compose.yml file with the following content. (I put mine in the newly created docker folder, but it doesn't really matter. You will tell Coolify the exact path later).

# docker/docker-compose.yml
version: "3.8"
services:
    permissions:
        image: cgr.dev/chainguard/wolfi-base:latest
        restart: "no"
        volumes: &volumes
            - files:/var/www/html/files
            - theme:/var/www/html/public/theme
            - media:/var/www/html/public/media
            - thumbnail:/var/www/html/public/thumbnail
            - sitemap:/var/www/html/public/sitemap
            -   type: bind
                source: /var/data/
                target: /var/data/
            -   type: bind
                source: /var/data/.env.local
                target: /var/www/html/.env.local
        entrypoint: [ "chown", "-R", "82:82", "/var/www/html" ]

    setup:
        image: vanwittlaer/cooldemo:${SOURCE_COMMIT}
        build:
            context: .
            dockerfile: docker/Dockerfile
            args:
                SHOPWARE_PACKAGES_TOKEN: ${SHOPWARE_PACKAGES_TOKEN}
        env_file:
            - /var/www/html/.env.local
        restart: "no"
        volumes: *volumes
        entrypoint: [ "vendor/bin/shopware-deployment-helper", "run", "-n" ]
        depends_on:
            permissions:
                condition: service_completed_successfully

    web:
        image: vanwittlaer/cooldemo:${SOURCE_COMMIT}
        volumes: *volumes
        depends_on:
            setup:
                condition: service_completed_successfully
        ports:
            - 8000:8000

    worker-1: &worker
        image: vanwittlaer/cooldemo:${SOURCE_COMMIT}
        restart: unless-stopped
        volumes: *volumes
        depends_on:
            setup:
                condition: service_completed_successfully
        entrypoint: [ "php", "bin/console", "messenger:consume", "async", "low_priority", "--time-limit=300", "--memory-limit=512M" ]
    worker-2: *worker
    worker-3: *worker

    scheduler:
        image: vanwittlaer/cooldemo:${SOURCE_COMMIT}
        restart: unless-stopped
        volumes: *volumes
        depends_on:
            setup:
                condition: service_completed_successfully
        entrypoint: [ "php", "bin/console", "scheduled-task:run" ]

volumes:
    files:
    theme:
    media:
    thumbnail:
    sitemap:

The permissions service just does what its name says.

The setup service builds the Shopware project with its composer dependencies and also builds the admin and storefront components. Eventually it performs the necessary steps to recompile the theme(s) and to update Shopware and the plugins. The latter is performed by Shopware's deployment helper, see https://github.com/shopware/deployment-helper/blob/main/README.md for more information on how to configure the deployment.

The web, worker and scheduler services perform the actual runtime tasks.

The volumes are used to persist media files, private files and other data. In a production environment, it is recommended to use an external storage provider like S3 to store media and private files. In my setup, I also bind a /var/data folder to the containers, it is used later for example to write database and file backups.

Last updated