What are good code deployment strategies? - automated-deploy

I am working on a Django project. And our team follows agile practices(TDD,very short launch times etc..)
When it comes to deployment stage of a feature, we follow manual procedures to get the code deployed on to our production machine. Manual procedures in the sense, run the test cases (of the entire project) manually and run the syncdb (or any latest db changes) manually and other stuff.
This manual stuff is taking about 1/2 hour per day,everyday. So I wanted to automate this. So is there any automatic deployement system or something that takes the commands I give and do what I want or it should be done only MANUALLY?? (using a simple shell file which has got all my commands. In which case, I need to learn shell programming a bit because I don't want to update my latest code in my production machine if any test case fails. So such a sort of conditions exist for deploying, which may involve a bit of shell programming. I guess!)

I just started researching this myself and it looks like the Python-equivalent of Capistrano is Fabric, although maybe not as mature. There seem to be a growing number of people wanting to switch over simply because Capistrano is too ruby/rails centric, although I haven't seen anyone complain about Capistrano being incapable or lacking. YMMV. More info here and here.
EDIT: Looks like Fabric is undergoing a lot of changes. They're moving their homepage to http://docs.fabfile.org/

So in Agile terms, you've identified duplication in your deployment process, now you're looking for ways to refactor it. ;-)
In the Ruby/Rails world, you'd turn first to Capistrano or Vlad The Deployer, and in the Python/Django world you'd turn to the equivalent, except AFAIK there isn't one.
It seems from this post that Capistrano has been used successfully to handle Django deployment, so that's an option worth exploring.
Beyond that, why would you need shell programming? You have a super-powerful scripting language in Python - why not automate your manual process in that?

Related

will using Docker allow me to not install necessary requisites?

I am a bit confused about Docker and how can I use it. My situation is the following:
I have a project that requires the use of a requisite, in my case installing ROS2. I have installed it in my system and develop a program. No problem there.
I wish to upload it to Gitlab and use CICD there. So I am guessing I will push it to my repository and then build a pipeline where I can use as image the docker image for ROS 2. I haven't tried it yet (will do it tomorrow) but I guess that is how I should do it.
My question is, can I do something similar (or how to ) in my local machine? In other words, just use the docker image and then develop and build over there and not install the requisite in the first place?
I heartily agree that using docker to develop locally improves the development experience, primarily by obviating system specific dependency management, just as you say.
Exactly how this is done depends on how many components you need to develop simultaneously, and how you want the development environment to behave .
An obvious place to start might be docker compose, a framework for starting multiple docker containers. https://docs.docker.com/compose/gettingstarted/ looks like quite a nice tutorial on the subject, and straight from the horse's mouth too.
However, your robotics project (?) may not be a very good fit for the server/client model behind the write - restart python - execute client - debug - repeat cycle in the document. To provide a better answer, we'd need a lot more understanding of how exactly your local development works - what exactly you want your development process to look like in this project might require a different solution. So add some workflow details to your question!

Using IDE together with docker

I started looking into docker lately and I understand a lot of the benefits it offers I think, you can quickly create a docker container and run it on different machines. Building (compiling) is also relatively easy, you can download the maven image for example and just build your code. That works fine. So, building is easy, testing is easy and deploying (and running) in production is easy.
What I don't understand is how docker can make the development phase easier. And what I mean with the development phase is, starting up your IDE, reading code, quickly navigate through your methods definition using the methods the IDE provides, use intelliSense, etc. Then change something, run a unit test, try a different third party library, etc. All things you can do with your IDE. But I don't understand how to do this with a docker image. I've read a few posts about starting the IDE from within your docker container, but that requires setting things up with a windows manager and I am not sure if that's the way to go.
Of course I can set up my laptop in such a way that I can do all of this with my IDE, but that way I bypass all of the benefits docker should offer. I still have to download dependencies, set up environment variables, do a lot of manual settings etc. And not just me, but everyone in the team.
So, not a very concrete question, possibly a duplicate, but I just can't wrap my head around it, how to use an IDE together with docker?
Yeah it's hard. It also depends on what language/framework you're using. But the things you mention are all easy to accomplish. For example we use Ruby a lot and someone in my team uses RubyMine to work with his code. That source code is mapped onto the container so the changes are reflected immediately. If you want to run a test, I'm sure you can override the command your IDE brings by default with something custom like docker run --rm myapp ./run_tests.sh or similar. At least that's what I do with VIM.
Probably the most important missing part when doing dev with Docker is debugging. I think JetBrains is starting to add features to their IDE's but I'm not sure on the status of that.
Also, almost every IDE or good editor has an integrated console. You could maintain a docker exec sessions opened there and run all your app commands, like tests, generators or any other. Even do some basic debugging.
Hope it helps.

CI tool with code metrics for ruby on rails application

I need to integrate a CI(continues integration)+CD(continuous deployment) tool for my ruby on rails application.
It would be great if it has the following features.
Code metric tool like (metric_fu)
Gitlab,Gitlub for repository managements.
Following are the list of CI tool I'm consider.
https://travis-ci.org/
https://circleci.com/
https://www.shippable.com/
https://www.codeship.io/
https://wiki.jenkins-ci.org
http://cruisecontrolrb.thoughtworks.com/
https://drone.io/
​please help me to compare the feature of these CI tools......
(full disclosure, I work for ThoughtWorks)
I'd replace CruiseControl.rb with http://www.go.cd/ or http://snap-ci.com - ThoughtWorks isn't actively updating CruiseControl.rb since Go CD came out several years ago. Both of the newer tools (also from TW) are designed with CD at their core.
To the main part of your question - With any of the tools you mentioned I'd recommend calling the code metrics tool of your choice as one of the stages, and not relying on the CI/CD tool to have that knowledge natively. Generally speaking, CI/CD servers are used to orchestrate a process that relies on several other tools like build systems, metrics tools, testing tools etc.
Magnum CI should be great for what you need.
It also deploys to Heroku, which hosts Rails apps. So if you want it to run some tests then deploy automatically, it sounds like it could be a good fit!
I found magnum-ci.com recently and feel it suites my entire need.
Hope this may help ROR enthusiastic...

Good alternative for ant for use on jenkins build server

Hy there. I have a number of software projects (also iOS and OSX) which I build with Apache ant`.
Although I quite like Ant it is often too verbose and some things which should be easy are quite tricky or I have to use shell scripts along with ant.
Is there a good alternative for which is extensible, easy to use and should work well on my jenkins build server.
Thanks for your input.
Have a look at Gradle - it's quite different from Ant and may take a little while to get your head around, but I think it's going to be the new standard for build systems. One nice thing is that it has full Ant support under the hood, so you can easily get your existing Ant builds running and then port them to Gradle.
Gareth's answer of Gradle is a good one. But do take a look at what you are doing that is hard with Ant. In my experience, a fair portion of the time its "non-build" stuff. Perhaps leave Ant for the pure build stuff, and use an alternate tool for and deploy or test stuff that's snuck in there.
Although gradle looks very promising I decided to use Rake instead.
I should say that this is a biased decision since I am already using ruby for other parts in my build setup. I found a good Article by Martin Fowler
Another point is that by doing OSX development the platform-independence-aspect of Ant (or Gradle) does not have such a big weight for me.
BTW Besi's Rake answer:
JRuby's Rake+Ant integration seems like a really powerful combo:
http://www.engineyard.com/blog/2010/rake-and-ant-together-a-pick-it-n-stick-it-approach
One big advantange there, it fully supports integration with Ant, allowing step-by-step migration.. which IMHO is only viable strategy for large, existing projects.
Gradle seems similar and while it looks good; I think learning Rake could be a better investment as it's more universal outside of Java.
(The other thing I'm seriously considering is BuildR http://buildr.apache.org, but Jenkins doens't explicitly support it yet, so have to use scripted build steps, which seems less preferable. TODO: a BuildR plugin).

How do I package a rails as a standalone executable

I've been developing a web application and a lot of customers are asking if they can host the application in their network (for security reasons). I have been looking for a way to package up a rails app into a single executable (with server and all), but haven't been able to find anything. My other requirement is that we distribute it without the source. Because of that I was looking at JRuby and Warbler. The end product should run on linux or windows. Has anyone done anything like this before, or can anyone point me in the right direction.
Thanks
My best guess would be to use JRuby and the JRubyCompiler, although I have no idea if you could compile a whole rails project (including all the required gems). I got it to compile a small ruby script though. Anyway, if you succeed, you could package those in a jar or war and deploy that as a contained application.
It doesn't sound like you necessarily need to package it as an executable, as long as the code is obfuscated. I personally haven't needed to protect any of my code, but a quick google search returned this product http://rubyencoder.com/. I'm sure there are others out there, but the basic idea is that your code is unreadable and cannot be reverse engineered. This would allow you to run a standard rails environment without giving access to your source code.
If you have the budget and really want to outsource this, the Github guys partnered with BitRock to build their cross-platform installable product (Github Firewall Install). BitRock has this case study on their website.

Resources