I followed the Shopware production docker image readme here:
https://github.com/shopware/docker
So my docker compose file is copied from the readme:
version: "3.8"
services:
db:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: 'shopware'
MYSQL_USER: shopware
MYSQL_PASSWORD: shopware
MYSQL_DATABASE: shopware
volumes:
- mysql-data:/var/lib/mysql
init-perm:
image: alpine
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
command: chown 82:82 /var/www/html/files /var/www/html/public/theme /var/www/html/public/media /var/www/html/public/thumbnail /var/www/html/public/sitemap
init:
image: local
build:
context: .
env_file: .app.env
entrypoint: /setup
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
depends_on:
db:
condition: service_started
init-perm:
condition: service_completed_successfully
web:
image: local
build:
context: .
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
depends_on:
init:
condition: service_completed_successfully
env_file: .app.env
ports:
- 8000:8000
worker:
image: local
restart: unless-stopped
build:
context: .
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
depends_on:
init:
condition: service_completed_successfully
env_file: .app.env
entrypoint: [ "php", "bin/console", "messenger:consume", "async", "--time-limit=300", "--memory-limit=512M" ]
deploy:
replicas: 3
volumes:
mysql-data:
files:
theme:
media:
thumbnail:
sitemap:
I am running docker 24.0.7 on Ubuntu 22.04, but I am getting:
$ docker compose up
validating /xxxxxxxx/docker-compose.yml: services.worker.init must be a boolean
sometimes also:
docker-compose.yml: services.worker.depends_on must be a list
What am I doing wrong?
I tried to remove the version tag in the docker-compose file and changing it to 3.9 - did not help.
As per https://docs.docker.com/compose/compose-file/compose-file-v3/#init I am not sure, if such a condition
should be supported.
Base on the comments - this is what was meant (under worker)
There is indeed init option existing but in this case it should belong to the
depends_on
clause and refer the service with the nameinit
.