Davide Mendolia

Dev Team Campfire: How to Automate your Development Environment Setup

Automation represents a very important matter in the professional software development world. For a software development business, the automated development environment is the campfire upon which the projects and infrastructure of the company are built.

As a lean and agile team, at Karumi we automate everything including deployment and tests so that when a new developer joins the team or when the computer setup of a developer changes the modifications propagate right away to every machine of every team member.

On top of that, if your team is remote like ours, it becomes absolutely critical to count on a proper dev-environment automation setup.



image




In the next sections we would like to share Karumi’s practice to automate the local development environment setup. In order to be able to reproduce setups and environments across different team members’ computers we chose Boxen from Github. The reason behind this choice is that Boxen makes it really easy to extend and write your own puppet manifests.

For our particular case we configured our dev environment as follows:

1- Create the Karumi environment file

By setting up this environment file we make sure that any work computer will have the exact same environment, accordingly minimizing the friction caused by the “oh, I forgot to install XXX package”.

Apart from making sure that everyone has the proper collaborations tools installed (special mention to Screenhero, which is a wonderful tool to share screens) we make sure that the following languages, packages and tools are installed:

  • python, pip, virtualenv and virtualenvwrapper.

  • ruby 1.9.3 and 2.0 and rbenv.

  • nodejs 0.10.3

  • mysql.

  • memcache.

  • Redis.

  • eb-tools and awscli for Amazon Web Services.

  • cocoapods.

  • android sdk, build-tools, system-images.

This ensures that every team member is able to:

  • run any project locally regardless of being web, iOS or Android based


  • deploy to AWS


which are the two more common tasks undertaken by Karumi’s dev team.

 

2- Extend boxen’s project.pp manifest

We extended the default project manifest to add a very opinionated django setup so it is extremely easy for us to create a new project:

example-project.pp

class projects::example-project {

    include karumi::environment

    boxen::project {‘example-project’:

        source => ‘git@bitbucket.org:user/example-project.git’,

        nginx    => true,

        django  => true,

    }

}

Such flag will do the following under the hood:

  • Setup a new virtual host in nginx for this site.


  • Setup an error and access log for this site.


  • Setup the upstream server so django can handle the requests.


  • Setup locations for static content, both in development and when the site is built (we need two different rules as the location of the files and the URLs are different for each case).


  • Setup the domain name to http://example-project.dev


  • Install coffee-script, yuglify and sass to integrate django-pipeline in the django app.


  • Install django and all the requirements in a virtual environment under ~/src/example-project/


  • Setup a virtualenv postactivate script so uwgsi is properly configured when working on this project. For instance, making it autoreload python processes when the code changes.


All of the above is done automatically in order for nobody to worry about it anymore. In case we need to change it afterwards, we just change the setup in one place and it will instantly propagate the changes to all machines.

As a summary, this is the flow every time a team member wants to work on any project:

$ cd /opt/boxen/repo

$ script/boxen example-project

This will setup the environment for example-project

$ workon example-project

This will change the active virtualenv to example-project.

And that’s it! With the afore presented setup, any team member must simply open http://example-project.dev in the browser and check the django app.

-Alberto on behalf of all Karumies.

Subscribe to Karumi Blog

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!