Scheduled Tasks, Cronjobs, Shell

If you want to use bash scripts to back up the database, media, and private files, you will find that the container shipped with shopware/docker does not include bash or mysqldump. To work around this, set up a container that only runs shell commands as follows.

# docker/Dockerfile.shell
FROM cgr.dev/chainguard/wolfi-base:latest

COPY --from=mysql:latest /usr/bin/mysqldump /usr/bin/mysqldump
COPY --from=ghcr.io/friendsofshopware/shopware-cli:latest /usr/local/bin/shopware-cli /usr/bin/shopware-cli

RUN apk add --no-cache \
    bash \
    php-8.2 \
    libstdc++

ADD . /var/www/html
WORKDIR /var/www/html

Add the following service to your docker-compose.yml file:

# docker-compose.yml
    ...
    shell:
        image: vanwittlaer/shell:${SOURCE_COMMIT}
        build:
            context: .
            dockerfile: docker/Dockerfile.shell
        volumes: *volumes
        command: [ "tail", "-f", "/dev/null" ]
    ...

You can then for example use the Scheduled Tasks (a.k.a. cronjobs) tab in the resource's Configuration to run recurring commands in the shell container.

Last updated