production
production copied to clipboard
Dockerfile requires access to the production database to be build
I would like to use the provided Dockerfile to build the current state of our Shopware system with a custom theme and some custom blocks to be easily deployable.
The problem is that the bin/console assets:install
requires a working database connection.
Step 13/16 : RUN bin/console assets:install && rm -Rf var/cache && touch install.lock && mkdir -p var/cache
---> Running in fdb1d49afc28
In AbstractMySQLDriver.php line 93:
An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddr
esses: getaddrinfo failed: Name does not resolve
This is highly unusual, as Dockerfiles should work without such dependencies. Is there any way to work around this issue and make the command work without a database?
I just stumbled over this one as well. I guess it only needs a db connection, when there is one configured (.env). How about removing it there and putting it into the entrypoint?
I'm still not sure how to use this whole setup though.
Even a database connection, without any data, is difficult to handle in a CD pipeline. Also, I am not sure for what exactly a database is needed to install assets.
@Kovah In database are the plugins state... :)
we are also looking for a way, build all stuff outside from shopware, without database on a pipeline. one aproach can be to use comitted var/theme-files.json and var/plugins.json and scan these files for plugin states and collect all assets with a script and move it to right direction. a compilation of css and js files should also be possible by nodejs via configuration files.
there is only one problem. on production side, after deployment, you have to change theme timestamp in database for new js and css sources. for that a command is needed to update that via shell. thats the idea.
Thank you for the answers. It's not understandable, that assets are handled this way as it makes the whole deployment process just way more difficult. What's the purpose of a Dockerfile if you need to have the production database at hand in the build process?
Magento only got this with version 2.3 https://devdocs.magento.com/guides/v2.3/config-guide/cli/config-cli-subcommands-static-view.html#deploy_without_db
before, database was needed. It sounds to a nice Feature Request.
https://developer.shopware.com/docs/guides/hosting/installation-updates/deployments/build-w-o-db should help