Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is no documentation about deploy commands queue and share folders and files #419

Closed
luckyraul opened this issue Nov 19, 2015 · 40 comments
Assignees
Labels
Site Improvements Updates to tools, processes, and site architecture that improve reader and contributor experience

Comments

@luckyraul
Copy link

have a look magento/magento2#2423

@ghost
Copy link

ghost commented Nov 19, 2015

I've read this and do not understand your question. Can you clarify and give an example?

@luckyraul
Copy link
Author

Which folders and files should be shared between releases(for example for m1 var, media and app/etc/local.xml are shared) and how and what order should I use bin/magento setup commands during rollout release

@buskamuza
Copy link
Contributor

Hi @luckyraul ,

could you, please, clarify what do you mean under "folders/files shared between releases"? Are those storing user data?

@luckyraul
Copy link
Author

Usually it is everything that not changed between releases

For instance, I already know that pub/media and app/etc/env.php should be shared

/var/www/example.com/     # The deploy_to path
 |-  releases/              # Holds releases, one subdir per release
 |   |- 1/
 |   |- 2/
 |   |- 3/
 |   '- ...
 |-  shared/                # Holds files shared between releases
 |   |- logs/               # Log files are usually stored here
 |   `- ...
 '-  current/               # A symlink to the current release in releases/

@hostep
Copy link
Contributor

hostep commented Jun 26, 2016

Hi

I also believe Magento should write some documentation about recommended deployment scenario's to/on a production server.
There already exists a page about this, but this only talks about the initial setup. Not about deploying updates of your project to the production server.

We need to know exactly which steps (commands) we need to perform and in what order (git clone, composer install, setup:di:compile, setup:static-content:deploy, setting up correct permissions, setup:upgrade, ...).
Also some commands need to have access to the database, so we would need to know at what stage in the deployment process we need to provide access to the database (preferable as late as possible). Then we also need to know when to put the current webshop in maintenance mode (preferable for the shortest time possible), before running the upgrade scripts and when we can disable maintenance mode again.

The deployment directories @luckyraul points out is what a lot of deployments scripts (capistrano, fabric, deployer, ...) prefer to use, so would be ideal if the documentation tries to use a similar setup.

As a clarification, this is about documentation for a deployment process where you execute a bunch of commands on the production server itself. This isn't about a separate build server which produces an artifact which you then need to upload to a production server. Although the steps would probably be very similar for that scenario.

Thanks!

@erikhansen
Copy link
Contributor

@xcomSteveJohnson I agree with @hostep that the devdocs should be updated to include the recommend order of steps to deploy. It might also be useful to link to community projects that can facilitate production deployments, such as @davidalger's capistrano-magento2 Gem.

Whoever is writing this documentation may want to reference the sequence of commands in the capistrano-magento2 scripts: https://github.com/davidalger/capistrano-magento2/blob/master/lib/capistrano/tasks/deploy.rake#L14

@maderlock
Copy link

As usual we're trying to work this out ourselves but it is a lot more difficult to get working than with Magento 1 which in very well understood by this point. c.f.
http://magento.stackexchange.com/questions/102144/magento-2-deployment-process
http://magento.stackexchange.com/questions/124166/order-of-magento-2-deployment-tasks

@ghost
Copy link

ghost commented Jul 13, 2016

Tracking with internal issue MAGETWO-55366.

Expect some questions from me as I get started.

@erikhansen
Copy link
Contributor

@xcomSteveJohnson I'd be happy to answer questions as you have them.

@maderlock
Copy link

Ditto. We have our first production site going live next week and we've reverted to manual commands due to uncertainty over ordering of commands. Great to see some movement on this.

@ghost ghost added Site Improvements Updates to tools, processes, and site architecture that improve reader and contributor experience Waiting for Response Waiting for response from internal/external parties labels Jul 18, 2016
@rob1256
Copy link

rob1256 commented Jul 27, 2016

Can I ask what commands people are using and in what order for deployment in production mode, with minimal down-time? I don't think I'm going to be able to have a build server to compile etc. on to then sync across to the production server (the idea of this seems a bit ridiculous anyway).

For example, say there is an update to one or more less files in my theme, as far as I can tell, you need to eithere delete the entire pub/static folder (thus breaking the site) or find the files that have been updated and then run the static-content:deploy command. Is this correct?

My thoughts on how deployment in general might work (be it for less files or for module code updates etc.) would be:

  1. Push code to production server
  2. setup:di:compile
  3. rm -rf var/view_preprocessed/*
  4. setup:static-content:deploy
  5. setup:upgrade --keep-generated (though I know this is broken currently)
  6. cache:flush

Is the above anywhere near correct?

@davidalger
Copy link
Member

@rob1256 Classy Llama is using the capistrano-magento2 gem (which I personally wrote and published on my github) for all code deployments to staging and production environments: https://rubygems.org/gems/capistrano-magento2 (more info in the README and at this blog post)

@rob1256
Copy link

rob1256 commented Aug 1, 2016

@davidalger Thanks for that information, looks like a useful deployment tool, do you know of anyway of doing deployments with no down-time and without having to do release folders etc?

I'm getting relatively close but it looks like I may need to run magento setup:upgrade --keep-generated as soon as any new code is pushed to make sure that the setup_modules table is up-to-date to stop Magento throwing errors. Are there any potential issues with doing that and then running all the compilation steps?

@mbrehme
Copy link

mbrehme commented Aug 30, 2016

+1

@hostep
Copy link
Contributor

hostep commented Aug 30, 2016

Just a heads up for people working on deployment workflows, because something important has changed between Magento 2.1.0 and 2.1.1.
Magento now requires a file pub/static/deployed_version.txt to exist before running bin/magento setup:static-content:deploy

So if you are using a current/releases/shared directory setup, you'll need to copy that file from your current directory into your release directory before running bin/magento setup:static-content:deploy.

I don't know if this is an intentional change, or if this is a new bug introduced in 2.1.1, but using the above workaround, you can get around it.

@davidalger
Copy link
Member

@hostep

Magento now requires a file pub/static/deployed_version.txt to exist before running bin/magento setup:static-content:deploy

Also interesting tidbit is that issue only causes trouble if the versioned URLs have been enabled. I've worked around that in the capistrano-magento2 gem by adding a call to touch the deploy_version.txt file prior to running static asset deployment. See davidalger/capistrano-magento2@d61d6983

@luckyraul
Copy link
Author

luckyraul commented Sep 12, 2016

@xcomSteveJohnson

Hi, do have any updates to this ticket?

@ghost
Copy link

ghost commented Sep 20, 2016

@luckyraul Sorry about the delay. I should know something soon.

@hostep hostep mentioned this issue Sep 28, 2016
@ghost
Copy link

ghost commented Oct 16, 2016

@luckyraul We should have a better story about deployment to production in 2.2 but I don't know the ETA for that release.

magento-cicd2 pushed a commit that referenced this issue Oct 26, 2016
* additions to upgrade doc

* Cloud stuff: revise upgrade article, pull out logs and SSH into new articles

* Fix collapsible issue

* Fix collapsible issue

* Spell check complete

* Updates

* Ready for spell check

* Ready for spell check after updating SSH to environment topic

* Update
@ghost
Copy link

ghost commented Oct 26, 2016

As with issue #739 we're planning to address this in 2.2 but I don't know the ETA for that release.

@tschifftner
Copy link

We are currently trying to find a good deployment setup. You are welcome to use and participate:

https://github.com/tschifftner/magento2-deployscripts

@ghost
Copy link

ghost commented Nov 7, 2016

Thanks. I passed the link along.

@Khaleel
Copy link

Khaleel commented Nov 17, 2016

magento/magento2#6131

Is this related?

@ghost
Copy link

ghost commented Nov 17, 2016

@Khaleel Yes, thanks!

@DavidLambauer
Copy link
Contributor

Matthias Walter published a series of our (netz98) deployment process. This might be interesting too!

https://dev98.de/2017/01/06/deploying-magento2-history-overview-14/

@aaronsturm
Copy link

I'm using Docker to build a deployable image with any changes from a previous release. I wanted to state that I found if I run bin/magento setup:upgrade and then bin/magento deploy:mode:set production, that that seems to remove the need for the individual steps others have listed above.

@luckyraul
Copy link
Author

@aaronsturm
magento deploy:mode:set production enables maintenance mode, you can't do it on the production

@aaronsturm
Copy link

aaronsturm commented Feb 1, 2017

I'm using a load balanced environment with rolling updates, that's how I bypass that. The Docker image doesn't even launch the web server until that's complete.

@luckyraul
Copy link
Author

@aaronsturm if you put production site to maintenance mode, lb will not help )
You code may be okay, but only to building images

@aaronsturm
Copy link

You can remove the instance from the load balancer before updating, of course. In my case, I use AWS' immutable policy to create a new instance, deploy the Docker image, add the instance to the load balancer, and destroy the others after it's successful. Using deploy:mode:set production won't work in every case, I was just adding input to hopefully help someone else out there.

@nickrigby
Copy link

I wrote a blog post about deploying Magento 2 using envoyer.io. Hopefully it is useful to someone, even if you're not using Envoyer.

@ipascual
Copy link
Contributor

ipascual commented Mar 16, 2017

My two cents, this is how I'm currently deploying using JENKINS:

echo "Removing files in case they exists in the repo"
rm -rf var
rm -rf pub/media

echo "Creating the required symbolic links"
ln -s $WORKSPACE/../env/var ./var
ln -s $WORKSPACE/../env/media ./pub/media

echo "Changing permissions of the temporary folder to www-data user"
sudo chown -R www-data:www-data $WORKSPACE/../*
sudo chmod -R 770 $WORKSPACE/../*

echo "Dependencies"
composer install --no-dev

echo "MAINTENANCE STARTS"
sudo chmod u+x ./bin/magento
sudo -H -u www-data bash -c "./bin/magento maintenance:enable"

echo "Setup upgrade"
sudo -H -u www-data bash -c "./bin/magento setup:upgrade"

echo "Application mode"
sudo -H -u www-data bash -c "./bin/magento deploy:mode:set production"

echo "Flush cache"
sudo -H -u www-data bash -c "./bin/magento cache:flush"

Use jenkins configuration files for env.php and config.php and custom workspace to point to HTML folder.

@dooblem
Copy link

dooblem commented Mar 17, 2017

Come on, @magento-team , it's been months and this issue is still there. How are you proceeding for deployments in Magento Cloud Edition? Can you share it with us?

http://devdocs.magento.com/guides/v2.1/config-guide/prod/prod_deploy.html

We’re currently working with internal teams to research and publish best practice recommendations for deploying the Magento application to production.

The documentation page has not evolved in months!

It really gives the users a bad image of Magento 2.. like it's not ready for production.

@davidalger capistrano is the best workflow currently, to my opinion, but there are still things to optimise I think (like static assets and di:compile done on target servers...).

Thanks in advance,
Marc from Clever-Age Toulouse

@davidalger
Copy link
Member

@dooblem If you're having speed related issues with DI compile and static asset gen, make sure you're on the latest version of M2 and have php70u-process (this is from IUS repo, name according to rpm providing PHP 7 for your server) installed on the server. With this installed, we have deploys running in less than 5 minutes (the static content / DI compilation will become multi-threaded with 4 threads by default; major speed increase!).

@hostep
Copy link
Contributor

hostep commented Mar 18, 2017

@davidalger: unfortunately due to a new bug introduced in Magento 2.1.3 we can no longer benefit from the multi-threaded static content deploy, since it produces incorrect JS translations when you generate multiple languages at once. And for as far as I'm aware, the di:compile step isn't multi-threaded (yet), but there were some good performance improvements made in 2.1.3.

Just FYI :)

@ all the others: @xcomSteveJohnson said they would publish documentation for this when Magento 2.2 is released, which I expect will happen during the Imagine 2017 conference, and that's only a couple of weeks away (let's hope it is true :))

@Khaleel
Copy link

Khaleel commented Mar 18, 2017 via email

@ghost
Copy link

ghost commented Mar 19, 2017

@dooblem Magento Enterprise Cloud Edition deployment is discussed here. If you want a discussion of deployment per se, see this topic.

@dooblem @hostep The only thing we can say for certain is that for us to officially document reduced-downtime deployment to production, code changes have to be made in Magento 2. We're expecting those changes in 2.2 but I cannot give you an ETA either for the release or for documentation about deployment.

If you need that information now, you should contact one of the helpful community members who have responded to this issue such as @davidalger

When we know more we'll let you know here.

@dooblem
Copy link

dooblem commented Mar 20, 2017

Thanks all for you answers.
@xcomSteveJohnson can we use the "magento-cloud-configuration" module in an Enterprise Edition ?

@ghost
Copy link

ghost commented Mar 20, 2017

@dooblem No, only if you have Cloud Edition.

@jfrontain jfrontain removed their assignment Jun 28, 2017
@jcalcaben jcalcaben self-assigned this Jun 29, 2017
@jcalcaben
Copy link
Contributor

Closing due to lack of activity.

@hguthrie hguthrie removed Waiting for Response Waiting for response from internal/external parties labels Jun 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Site Improvements Updates to tools, processes, and site architecture that improve reader and contributor experience
Projects
None yet
Development

No branches or pull requests