0

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:

  1. Pull the shared configuration file from source control.
  2. Use the magento setup:di:compile command to compile code.
  3. Use the magento setup:static-content:deploy -f command to update static file view files.
  4. 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?

0

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:

Fatal error: Uncaught Error: Call to a member function getPackage() on null in /srv/magento2/vendor/magento/module-deploy/Package/Processor/PostProcessor/CssUrls.php on line 217

Error: Call to a member function getPackage() on null in /srv/magento2/vendor/magento/module-deploy/Package/Processor/PostProcessor/CssUrls.php on line 217

This is caused by previously genereated cache on var/view_preprocessed, to fix this we need to remove cache:

rm -rf pub/static/* 
rm -rf var/view_preprocessed/pub

Full steps to deploy static content on build system:

Run container with mounted our magento

docker run -it -v $HOME/www/magento2:/srv/magento2 bmxmale/magento2-php:2.2-cli bash

Remove cache

rm -rf pub/static/* 
rm -rf var/view_preprocessed/pub

Deploy static content for backend

php bin/magento setup:static-content:deploy -f en_US -t Magento/backend

Deploy static content for frontend

php bin/magento setup:static-content:deploy -f da_DK -t OurTheme/default
  • pub/static/* remove .htaccess and symlinks!!! This isn't correct command. Better is: pub/static/adminhtml/* pub/static/frontend/* – Patryk Padus Dec 10 '17 at 20:58
  • @PatrykPadus rm -rf pub/static/* doesn't remove the .htaccess and is mentioned in the docs – M.Elwan May 24 '18 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.