Showing posts with label aws. Show all posts
Showing posts with label aws. Show all posts

Monday, January 12, 2015

PHP application with Mysql database to a Django app with Postgres Database

Recently I had a chance to work on a project, where a PHP app had to be converted to a Django one.

The work seemed trivial, but it brought a few difficult technicalities. It had a Mysql DB, with few tables. Overall, I had to  -


  • Convert them into Django models
  • Convert the app into Django
  • Setup the app on Heroku using Postgres

  1. Converting the models to Django is easy. Django provides an inspectdb command. It looks at the current model structures, inspects it and provides django model accordingly.
  2. This is a nice feature. It gave me a push forward to begin the app development. However, this feature lacked some points that I would like to point out - 
    1. In Mysql, we have a set type . This is basically similar to choices in Django models. I had to manually do that. 
    2. The foreign key constraint is set to id by default. The command could check this and set the field in model declaration using to_field parameter.
    3. The DB views had to created manually. 
  3. For changing Mysql Data to Heroku, https://devcenter.heroku.com/articles/heroku-mysql is a good resource.
As always, heroku has to be provided with a S3 access to uploading of static and media files. But thats a different matter.

Friday, April 25, 2014

Continuous Integration and Deployment using Bamboo and AWS Elastic Beanstalk

Walk-through of setting up Bamboo as CI and CD  

Bamboo is a popular Atlassion product . Lets go setup bamboo and discuss what steps did I do.
  • Install Bamboo on an EC2 instance
    • Configure to run on Port 80 instead on its default.
    • Make sure system has enough memory, I am using a m1.small instance. 
    • Bamboo has a startup script, use that , and make sure the permission thing.:P
  • For CI - 
    • Checkout the code
      • Used post push hook to automate the build plan on bamboo
    • Install dependencies
      • Remember to clean cache and remove the node_modules before installing
    • Run tests
      • Used Bamboo-mocha plugin for that. Ample doc is provided for that
    • Thats it !!
  • For CD -
    • Setup the deployment Server -
      • We are using Amazon Beanstalk,, our app being a Node.JS one.
    • The deployment process is tricky. Manually we have to initialize the repo and feed in a lot of details. But to do it automatically 
      • Initialize the repository with the AWSDevTools-RepositorySetup.sh script. It will add git aliases . We will now have git aws.push command
      • The deploy script searches for a file named aws_credentials_file, in the Home folder of the user in .elasticbeanstalk dir. So one task is to copy a file in home folder during each deployment.
    • Rest is simple.

This blog also has a lot of important details that helped me - http://blog.pedago.com/2014/02/18/build-and-deploy-with-grunt-bamboo-and-elastic-beanstalk/

Next step to include Code Coverage .. Will mention it in next blog post.