At the moment development is done on a local server to myself. The site is not live but testing is done on what is to be on production server and a git push from development triggers a webhook that does a git pull on 'production' environment and deploys the production server automatically.
I want to add an extra testing environment before production ready for when this is live and also make this work with Magento version updates.
1. Development System
Includes all Magento files. Initial code modifications and initial testing here. Git Push pushes code to development repository which then triggers a 'deployment script' on build system via a web-hook.
Based on same repository as development need all files that are needed in production however not have a database. Git Pull triggered by web-hook from change in development repository.
System will then run composer update to get necessary vendor files however am unsure weather this updates lib folder and weather this is needed in repo or is updated with composer?
Once completes triggers a script that copies only files necessary for production into testing system and then runs deployment commands on testing system (maintenance mode / setup:upgrade / compile / deploy static content / exit maintenance).
3. Testing System
Identical to production system. Once testing is complete run deploy production command. This command will overwrite necessary files in production folder and re run deploy commands similar to Buildsystem -> Testing System but on the production environment.
4. Production System
Live environment ready for customers to buy things :)
What folders / files are needed are needed for Production to work even if updating magento version from 2.x.y to 2.zx.zy. if running from pub folder?
So far i have in my repository:
- app (will remove certain files in here e.g. env.php)
- lib (unsure weather to include this in repo or if composer update will generate neccasary files)
- pub (certain files in here will be excluded .htaccess bit worried about the media folder and what to do for this. May keep in live and symlink to testing? Can get very large however and do not want multiple copies on server)
- update? (is this needed in production?)
- .htaccess (is this needed if server from pub directory?)
- .gitignore (will not move this in production)
- .php_cs? (not sure what this is)
- .travis.yml? (not sure what this is but will test without)
- .user.ini? (seems to be php configs not sure this is needed?)
- auth.json? (will keep for composer update up until build system)
- composer.json? (setup:upgrade doesn't run without)
- composer.lock? (setup:upgrade doesn't run without)
- index.php? (is this needed if served from pub directory)
- package.json? (not sure what this is)
Main issues are in bold but if someone can clarify these bits it would be great. Am unsure i need index.php also if serving from pub directory and other files like php_cs i am unsure what they are.
There are also some folders that get created on composer update in the build system.
- dev? (Just seems like a dev folder :P am not copying this and seems fine)
- phpserver? (not copying and seems fine)
- setup (this seems like its needed as setup:upgrade doesn't run)
Are these required in production?
Then i have some files that will stay put in my development / testing / production like .htaccess and /app/etc/env.php that aren't in repository but will have specific configs for each system but wondering if i'm missing any here also? I initially wasn't going to include /app/etc/config.php as thought this would regenerate however was getting
Missing required argument $routerList of Magento\Framework\App\RouterList. error.
I have managed to get it to work with updating magento and all automated however still going to do a lot of testing.
What to do about the media directory would it be a good idea to remove it from the directory and symlink it to both testing and live environments or may this cause issues?
Should a reindex be run after a magento update? I don't tend to do this but feel some updates may require this but then will add 10 - 20 mins to deployment? I guess reindex is not supposed to affect frontend to much especially since 2.2.x and so it can run after i have removed maintenance mode?