This could be one kind of discussion more than a question.
I'd like to know which deployment policy you follow with Magento2 & local > staging > production environments
After some tries we've decided the best (or at least, the most solid) approach would be this gitignore file including vendor folder in git.
.DS_Store
/.buildpath
/.cache
/.metadata
/.project
/.settings
atlassian*
/nbproject
/sitemap
/sitemap.xml
/.idea
/.gitattributes
/app/config_sandbox
/app/etc/config.php
/app/etc/env.php
/app/code/Magento/TestModule*
/lib/internal/flex/uploader/.actionScriptProperties
/lib/internal/flex/uploader/.flexProperties
/lib/internal/flex/uploader/.project
/lib/internal/flex/uploader/.settings
/lib/internal/flex/varien/.actionScriptProperties
/lib/internal/flex/varien/.flexLibProperties
/lib/internal/flex/varien/.project
/lib/internal/flex/varien/.settings
/node_modules
/.grunt
/pestle.phar
/pub/media/*.*
!/pub/media/.htaccess
/pub/media/catalog/*
!/pub/media/catalog/.htaccess
/pub/media/customer/*
!/pub/media/customer/.htaccess
/pub/media/downloadable/*
!/pub/media/downloadable/.htaccess
/pub/media/import/*
!/pub/media/import/.htaccess
/pub/media/theme/*
/pub/media/theme_customization/*
!/pub/media/theme_customization/.htaccess
/pub/media/wysiwyg/*
!/pub/media/wysiwyg/.htaccess
/pub/media/tmp/*
!/pub/media/tmp/.htaccess
/pub/media/captcha/*
/pub/static/***
!/pub/static/.htaccess
/var/*
!/var/.htaccess
.unison*
/sync.sh
So we run composer only in local environment: As any new extension, or software upgrade is tested in local, then validated and committed. We'd probably then include app/etc/config.php file in git too but that file is rewriten when running setup:upgrade
, right?
Including vendor means repository size will be bigger than (maybe) recommended but this way when deploying code, we just run the sequence:
bin/magento setup:upgrade
bin/magento setup:di:compile (optional)
bin/magento setup:static-content:deploy
Related info: http://www.damianculotta.com.ar/magento/gitignore-y-la-estrategia-de-deploys-en-magento2
See why we choose compile command as optional Magento 2 - setup:di:compile ?
UPDATE
The truth is we are having some problems when deploying code changes in our published Magento 2 projects
Changes work in local & staging (checked in both modes: developer & production... although we conceptually configure that environments in developer mode), but some of them don't work in production environment (in production mode), etc... so I am not sure we are following the right strategy. I'd like to see what's the appropriated command sequence, and the relevance of the order in that commands
In fact, every day I am less convinced about the utility of Magento 2 production mode, unless you are not going to change anything in the project. Can you change my mind?