Closed willopez closed 3 years ago
This is the same issue that I'm facing in my current, somewhat custom, containerised Shopware 6 setup. The problem here is that you'd need to create a dependency between a process responsible for migrating the database and the database being ready to accept connections. One way to do this is to create a worker service using something like wait for it to execute bin/console system:install --create-database --basic-setup --force
after the database is ready.
@dfsoeten Thanks for the tip! That would be a good solution for, have you implemented something like it? also, somewhat related to this, do you know what is the purpose of the docker-compose-advanced.yml
? is that what should be used for an actual production deployment?
I'm not sure what the exact intention of this repository is and how it differs from the Docker setup that comes with the Shopware 6 production repository (see the Dockerfile and Docker Compose file), so I'm not in a position to answer your question. However, I'm currently in the process of deploying a Shopware 6 instance to GCP. And what I found is that you need the Shopware 6 production repository if your intention is to use it in production. See this blog.
Furthermore, I don't have a concrete implementation for you regarding Shopware 6. I do, however, have an implementation for an unrelated PHP/SQL project which might be helpful. I made a few changes so it should look something like this:
Create a file named mysql-migration.entrypoint.sh
:
#!/bin/bash
if [[ ! -f vendor/autoload.php ]]; then
exit 1;
else
./scripts/docker/wait-for-it.sh mysql:3306 -- ./bin/console system:install --create-database --force;
fi
Add a service responsible for seeding the database:
database-migration:
image: shyim/shopware:latest
depends_on:
- mysql
env_file:
- .env
entrypoint: ['./mysql-migration.entrypoint.sh']
volumes:
- state:/state
- plugins:/var/www/html/custom/plugins
- files:/var/www/html/files
- jwt:/var/www/html/config/jwt
- theme:/var/www/html/public/theme
- media:/var/www/html/public/media
- thumbnail:/var/www/html/public/thumbnail
- bundles:/var/www/html/public/bundles
- sitemap:/var/www/html/public/sitemap
Edit: Looking through this repository @shyim is doing something very similar regarding the maintenance
service which executes maintenance.sh
.
Should be fixed with the associated commit
docker-compose.yml
It runs only one container. On startup the container checks is it installed or needs to be updated. And runs after it the nginx
docker-compose-advanced.yml
That was intended for Kubernetes https://github.com/shyim/shopware-chart
I clicked the button to load this image in the PWD environment and looked at the logs of the Shopware image and see the following error:
It seems that there is an issue with the initialization of the database(the migrations don't run perhaps?) when the image is being built. If I log into the container and execute
bin/console system:install --create-database --basic-setup
after deleting the install lock.And then generating the jwt secret(
bin/console system:generate-jwt-secret
everything runs fineWondering how this could be fixed in the image? so that the initial run works out of the box.