3

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.

Process:

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.

2. Buildsystem

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 :)

Questions:

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)
  • bin
  • 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?

gitignore

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.

Update

  • 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?

2

I suggest you to read some articles about processes already used by some, such as :

and then appropriate those to your needs.

You may install magento on production, staging and development environments the same way, then you just deploy versionned files (not ignored from .gitignore file). Optimized gitignore files can be found on github, from official magento repository to other sources.

  • Thanks for your reply. I have looked at these but am unsure about mainly the files needed at each stage and what to do about the media directory its quite large and i dont want to be copying it in and out each time. Random little things like this but trial and error seems to be getting me a decent way. – harri Nov 14 '17 at 16:09
  • Have a look at this gitignore : github.com/yireo-training/magento2-gitignore/blob/master/… You can assume that all other files are needed when you have to deploy on your production environment that already have the same magento version setup. Then, you will run setup, compile, ... and it will generate other needed files. About 'media' directory, it should be filled by the production env. If you don't see the complete catalog images on the dev env, it is not a problem. You can backup it – DependencyHell Nov 14 '17 at 16:19
  • Im just worried with rsync because i want to delete files if they are removed from dev but at same time dont want my media directory getting wiped either by the rsync? – harri Nov 14 '17 at 16:21
  • right, if you use the solution from c3media, they are talking about a "build version" and then, they use rsync to send new versionned + generated files to the live env. They specify a rsync-exclude config file in which media directory is listed as "do not delete this" – DependencyHell Nov 14 '17 at 16:24
  • 1
    Thanks for your suggestions tho pretty sure im quite close to having this painful process working now. – harri Nov 14 '17 at 16:42

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.