What order do the deployment tasks of static-files, DI compilation, and setup:upgrade have to be performed?

In order to deploy updates for a Magento 2 site to live, the common approach would be to pull in the latest code and perform build actions on a release candidate (RC) of the repo to that running on live. If all builds OK then the files can be copied very quickly using rsync to be live.

The order I'm trying to use is:

  • Update code in RC
  • Clear var and pub/static in RC
  • Deploy static files in RC
  • Compile DI in RC
  • Rsync code from RC to the live site
  • Perform setup:upgrade in maintenance mode on live

Such an approach is complicated by my lack of knowledge of what each step is precisely relying on.

Obviously static deployment and compiling DI is ridiculously slow and so should be performed before copying across files, but after running setup:upgrade there is a message saying "Please re-run Magento compile command" suggesting that something has now changed which compilation requires.

Can the above order be safely used?

  • One thing we've found is that static compilation can be run after DI compilation. This is useful for CI as it will flag up DI compilation issues quicker. Commented Jan 24, 2017 at 10:58
  • Marked as a duplicate??? You do realise that on the question that you've referenced the TOP RATED ANSWER IS MINE?! Perhaps there is something I'm asking here that is not answered there? Arghh. Commented Feb 4, 2017 at 7:59


Browse other questions tagged or ask your own question.