I trying to setup build system for setup:di:compile
and setup:static-content:deploy
based on official devdocs.
Build system
The build system compiles code and generates static view files for
themes registered in Magento. It doesn’t need a connection to the
Magento database; it needs only the Magento codebase.On your build system:
- Pull the shared configuration file from source control.
- Use the magento
setup:di:compile
command to compile code.- Use the magento
setup:static-content:deploy -f
command to update static file view files.- Check the updates into source control.
I have prepared docker image (bmxmale/magento2-php:2.2-cli) and running docker with mounted magento code, without access to DB.
Before I exec magento app:config:dump
and settings are now stored on config.php and env.php
Run docker with mounted Magento:
docker run -it -v $HOME/www/magento2:/srv/magento2 bmxmale/magento2-php:2.2-cli bash
Try to compile DI
magento@578fc8d10f6d:/srv/magento2$ magento setup:di:compile
[Zend_Db_Adapter_Exception]
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
[PDOException]
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
[PDOException]
PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known
setup:di:compile
Anyone know how build system should look like to make build code like described on devdocs?
Best Answer
Working build system
Based of issue 10041 for RC version I figure that we need to remove
env.php
file if exist.Second issue 11372 throwing error:
This is caused by previously genereated cache on
var/view_preprocessed
, to fix this we need to remove cache:Full steps to deploy static content on build system:
Run container with mounted our magento
Remove cache
Deploy static content for backend
Deploy static content for frontend