From development to deployment with Git
I am very puzzled. I have read many sources about ‘development & deploy’ with git and haven’t understand anything.
Now I have:
- How to install Laravel 4?
- Working with Laravel 4 repository and my own repository
- laravel blade files, Your local changes would be overwritten by merge
- Is there a place to get the laravel `vendor` folder in one spot?
- If Composer cannot be installed on production server is it OK to track vendor folder in Git?
- Why doesn't the vendor folder show in Bitbucket?
- Local (Development) repository with project (
- Gitlab/Github Server where I store/commit/push my project.
- Production server
Many sources writes that I need two repositories on production server:
git --bare init
- And non-bare repository in
Then I need to push changes from my local/development repository to Bare then pull project in
/var/www from this Bare repository.
But if I have Github/Gitlab Server then I don’t see logic in this Bare repository, because I have this code on the server. I’m right?
I am using Laravel for my projects and after some commits
composer install is required. If I pull this commit on production server, then it may break site and it will be down for some time until I will make all required steps. Of course all steps can be done with automatic script, but I think it also will break site for a short time.
I want to understand right scheme of deploying applications to production server.
2 Solutions collect form web for “From development to deployment with Git”
The best approach i think (and this is what we are following on a large project we are working) is to setup a separate git project on a separate environment (let’s say “Test” or “Stage” environment) from which you are going to clone the git project hosted on gitlab.
After cloning the stage and doing the necessary preparatory steps you can pull the changes committed to gitlab/github server. This way you can test the website on stage after each pull request. If all is ok and there are no broken parts you can pull the git content from the production environment too respecting the same logic as described below. The idea is the stage environment have to have the same php version and server settings etc.
Of course you can use automation tools like Vagrant, Docker or Jenkins (just to name a few but there are much more), which are freeing up from the headaches produced by different system configuration by creating images with the actual system configuration including the project and deploying the project to separate virtual machines.
Below is a detailed picture about the process which you might follow.
More extensive tools like Capistrano can automate a lot of things for you, but also has a learning curve.
It’s hard to know the best solution without more details, but once strategy I’ve seen for atomic commits is using symlinks. I’ll give an example
Clone your repository twice on your server, and set up a symlink from
/var/www to point to one of them. When you deploy, go into the other folder and
git pull, run any needed install commands, and then update your symlink to point to the updated folder. I believe this is similar to how Capistrano works under the covers.
Just my two cents!