Docker-Images for Deployment with Gitlab-Runners

This page shows and explains a simple setup for a Docker image to be used for deployment of Shopware 6.6 and above.

My goal was to create a minimalist yet secure Docker container to use in my Shopware 6 deployments.

I used to start with php-cli images as a base for my setup. However, the resulting image was over 1 GB in size. The approach described here was inspired by https://shyim.me/blog/wolfi-os-for-php/. You can find more information about the wolfi base image here: https://github.com/wolfi-dev/. Not only is the resulting image much smaller, it is also easier to set up (due to the apk manager used) and can be considered one of the most secure base images for Docker setups.

This is the Dockerfile I ended up with:

FROM cgr.dev/chainguard/wolfi-base:latest

RUN apk add --no-cache \
    composer \
    curl \
    gd \
    git \
    jq \
    libsodium \
    nodejs-20 \
    npm \
    openssh-client \
    openssl \
    php-8.2 \
    php-8.2-ctype \
    php-8.2-curl \
    php-8.2-dom \
    php-8.2-fileinfo \
    php-8.2-gd \
    php-8.2-iconv \
    php-8.2-intl \
    php-8.2-mbstring \
    php-8.2-mysqli \
    php-8.2-mysqlnd \
    php-8.2-openssl \
    php-8.2-pdo \
    php-8.2-pdo_mysql \
    php-8.2-phar \
    php-8.2-redis \
    php-8.2-simplexml \
    php-8.2-soap \
    php-8.2-sodium \
    php-8.2-xml \
    php-8.2-zip \
    python3 \
    redis \
    rsync \
    zip

COPY php-config.ini /etc/php/conf.d/99-docker.ini

The imported php ini file simply raises the execution time and memory limit to whatever the server allows.

# php-config.ini
max_execution_time=0
memory_limit=-1
date.timezone=Europe/Berlin

The resulting image is only 265 MB in size. The deployment time for a vanilla Shopware 6.6 installation is less than 2.5 minutes.

I use this image on a Hetzner cloud server and have found a CX31 (2 Intel CPUs, 8GB RAM) to be quite sufficient for the job. Note that some Hetzner cloud server IP4 addresses may be inadvertently blacklisted by gitlab.com, causing problems when the runner tries to pull from the repository. In these cases, take a snapshot of your runner and spin up a new server, hoping to grab a "clean" unlisted IP4.

Last updated