From f8899e949374c7ac7ac21f6bd797d0d4bf1141b5 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 26 Nov 2025 11:14:29 +0100 Subject: [PATCH] Refactor Shopware role: separate Shopware app version and PHP runtime, update Dockerfile to use dynamic images, consolidate pull_policy, and improve image configuration. See conversation: https://chatgpt.com/share/6926d2f2-083c-800f-916a-7c260d1eada8 --- roles/web-app-shopware/config/main.yml | 10 ++++++---- roles/web-app-shopware/templates/Dockerfile.j2 | 4 ++-- roles/web-app-shopware/templates/docker-compose.yml.j2 | 3 +-- roles/web-app-shopware/vars/main.yml | 5 ++++- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/roles/web-app-shopware/config/main.yml b/roles/web-app-shopware/config/main.yml index 74d14bd8..07acb73e 100644 --- a/roles/web-app-shopware/config/main.yml +++ b/roles/web-app-shopware/config/main.yml @@ -26,17 +26,19 @@ docker: enabled: true init: - name: software-init + name: "shopware-init" cpus: 1.0 mem_reservation: 1g mem_limit: 2g - - # Base PHP image used by all app services shopware: + image: "shopware/production" + version: "6.7.3.1" + + php: image: "ghcr.io/shopware/docker-base" version: "8.3" - + web: name: "shopware-web" port: 8000 diff --git a/roles/web-app-shopware/templates/Dockerfile.j2 b/roles/web-app-shopware/templates/Dockerfile.j2 index b8842ae7..eb7c3f8e 100644 --- a/roles/web-app-shopware/templates/Dockerfile.j2 +++ b/roles/web-app-shopware/templates/Dockerfile.j2 @@ -15,7 +15,7 @@ ENV COMPOSER_ALLOW_SUPERUSER=1 \ COMPOSER_PROCESS_TIMEOUT=900 WORKDIR /app -ARG SHOPWARE_PROD_VERSION=shopware/production:6.7.3.1 +ARG SHOPWARE_PROD_VERSION="{{ SHOPWARE_IMAGE }}:{{ SHOPWARE_VERSION }}" # 1) Scaffold project without installing dependencies RUN set -eux; \ @@ -45,7 +45,7 @@ RUN set -eux; \ ############################ # Stage 2: Runtime ############################ -FROM ghcr.io/shopware/docker-base:8.3 +FROM {{ SHOPWARE_PHP_IMAGE }}:{{ SHOPWARE_PHP_VERSION }} WORKDIR /var/www/html # Install required PHP extensions in the Alpine-based runtime diff --git a/roles/web-app-shopware/templates/docker-compose.yml.j2 b/roles/web-app-shopware/templates/docker-compose.yml.j2 index 844c88e5..40fc63cb 100644 --- a/roles/web-app-shopware/templates/docker-compose.yml.j2 +++ b/roles/web-app-shopware/templates/docker-compose.yml.j2 @@ -10,6 +10,7 @@ x-environment: &shopware - bundles:/var/www/html/public/bundles - "{{ SHOPWARE_FRAMEWORK_HOST }}:{{ SHOPWARE_FRAMEWORK_DOCKER }}:ro" working_dir: {{ SHOPWARE_ROOT }} + pull_policy: never {% include 'roles/docker-compose/templates/base.yml.j2' %} @@ -61,7 +62,6 @@ x-environment: &shopware {% include 'roles/docker-container/templates/base.yml.j2' %} <<: *shopware container_name: "{{ SHOPWARE_WORKER_CONTAINER }}" - pull_policy: never entrypoint: {{ SHOPWARE_WORKER_ENTRYPOINT }} depends_on: init: @@ -86,7 +86,6 @@ x-environment: &shopware {% include 'roles/docker-container/templates/base.yml.j2' %} <<: *shopware container_name: "{{ SHOPWARE_SCHED_CONTAINER }}" - pull_policy: never entrypoint: {{ SHOPWARE_SCHED_ENTRYPOINT }} depends_on: init: diff --git a/roles/web-app-shopware/vars/main.yml b/roles/web-app-shopware/vars/main.yml index cd8a2a86..eba3d113 100644 --- a/roles/web-app-shopware/vars/main.yml +++ b/roles/web-app-shopware/vars/main.yml @@ -12,11 +12,14 @@ SHOPWARE_DOMAIN: "{{ domains | get_domain(application_id) }}" # Shopware container/image vars SHOPWARE_VERSION: "{{ applications | get_app_conf(application_id, 'docker.services.shopware.version') }}" SHOPWARE_IMAGE: "{{ applications | get_app_conf(application_id, 'docker.services.shopware.image') }}" -SHOPWARE_CUSTOM_IMAGE: "{{ SHOPWARE_IMAGE }}:{{ SHOPWARE_VERSION }}" +SHOPWARE_CUSTOM_IMAGE: "shopware_custom" SHOPWARE_VOLUME: "{{ applications | get_app_conf(application_id, 'docker.volumes.data') }}" SHOPWARE_USER: "www-data" SHOPWARE_ROOT: "/var/www/html" +SHOPWARE_PHP_VERSION: "{{ applications | get_app_conf(application_id, 'docker.services.php.version') }}" +SHOPWARE_PHP_IMAGE: "{{ applications | get_app_conf(application_id, 'docker.services.php.image') }}" + # Split service container names SHOPWARE_INIT_CONTAINER: "{{ applications | get_app_conf(application_id, 'docker.services.init.name') }}" SHOPWARE_WEB_CONTAINER: "{{ applications | get_app_conf(application_id, 'docker.services.web.name') }}"