Building and Deployment Workflow for CodeIgniter Projects
I did a lot of search but I can’t find the solution that fits to my problem.
I would like to improve my development workflow in my projects using Phing. My current workflow is so simple and susceptible to fails. My current situation is the following:
- Dev: My machine and development environment.
- Testing: Testing and VCS server. When the projects are ready-to-release they are “deployed” to this machine for tests and the code are pushed to a Git central repository in this machine too.
- Production: When the projects are ready-to-production they are “deployed” to this machine.
The current “deployment” process:
The application changes are made in my machine in a
feature branch. When the changes are ready-to-release, I merge it to the
develop branch and then I “deploy” it from my machine working directory (not from the local or remote VCS) to the testing server (which is physically the same machine from VCS). If everything is ok, I merge the changes from
develop to the
master branch, then I “deploy” it to the production server the same way I do for the testing server. Finally, I push my local changes in
master branches to their correspondents branches in the central remote repository. These processes are sometimes made manually or through a custom shell script.
- Manually deployment process are a not professional and safe way to do this.
- My custom shell script are simple and has some problems like: (1) manually provide a list of files that should be deployed, (2) needs to change the code to deploy to different servers, (3) there is no rollback task and so on.
- I can’t during the building or deployment processes some tasks like tests, database migrations, clean cache and log files, change permission and so on.
- That is, it is not a simple single task as it should be!
- Phing is a build tool. Can I use it for deployment too?
- I think that the application code should be deployed (in my case) from the ‘develop’ and ‘master’ branches from the central remote repository (and not from my working directory) respectively to ‘testing’ and ‘production’ servers. Is this the correct way?
- Considering the previous question and that I would like to use Phing, where should I install it? In my development machine or in the testing machine?
What are the ‘recipes’ that make more sense and should I use to the ‘testing’ and ‘production’ deployment strategies?
Case A1 – Testing Deployment (run from local machine)
(1) connect to testing machine, (2) clone ‘develop’ branch from central repo to webroot folder, (3) remove .git directory, cache and log files, (4) change some permissions, (5) run databases scripts, (6) change the symlink to current release and (7) restart webserver.
Case A2 – Testing Deployment (run from testing machine)
The same steps from Case A1.
Case B1 – Production Deployment (run from local machine)
(1) connect to produciton machine, (2) clone ‘master’ branch from central repo to webroot folder, (3) remove .git directory, cache and log files, (4) change some permissions, (5) run databases scripts, (6) change the symlink to current release and (7) restart webserver.
Case B2 – Production Deployment (run from testing machine)
The same steps from Case B1.
Should I deploy the entire project or only the changed files? What is better and safe?
- Should I have a build process in my development machine to run tests, quality assurance and minification tools or this should be run in testing server?
- Should I run the deployment strategies manually or as a Git hook in the server?
One Solution collect form web for “Building and Deployment Workflow for CodeIgniter Projects”
personally my workflow is similar to this:
- i code in a feature branch and test locally.
- when im ready, i merge into a CI (continuous integration) branch and push
- jenkins sees a new commit to CI and auto builds the repo on our test server and runs all the unit tests. if the units all pass, docs are generated and the results are emailed to me.
- usually, i then run a few manual tests on the testing server.
- if everything looks good i have a jenkins deploy script that merges the CI branch into master, updates the /docs/ folder with the newly generated documentation, then pushes everything up to the remote. finally the live server pulls the new changes and i receive another email.
- final live site manual testing, and repeat.
IMHO the real secret to my workflow is HOOKS, HOOKS, HOOKS!
all the automation that jenkins does for me are all based on post commit/push hooks. when i commit to CI and push the to remote server (github) jenkins is alerted of this via a post push hook (http://developer.github.com/v3/repos/hooks/#test-a-push-hook).