production icon indicating copy to clipboard operation
production copied to clipboard

Dockerfile requires access to the production database to be build

Open Kovah opened this issue 4 years ago • 6 comments

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?

Kovah avatar Apr 03 '20 08:04 Kovah

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.

claudiobianco avatar Apr 04 '20 23:04 claudiobianco

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 avatar Apr 05 '20 07:04 Kovah

@Kovah In database are the plugins state... :)

hlohaus avatar Apr 05 '20 11:04 hlohaus

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.

wrongspot avatar Apr 05 '20 18:04 wrongspot

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?

Kovah avatar Apr 06 '20 09:04 Kovah

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.

wrongspot avatar Apr 06 '20 10:04 wrongspot

https://developer.shopware.com/docs/guides/hosting/installation-updates/deployments/build-w-o-db should help

shyim avatar Oct 25 '22 07:10 shyim