1421825741heroku-deployment

Simply Deploy React.js App to Heroku

If you have read my another post about creating a ToDo app in react you are good to go; if not see this post.

You know that React App is a single page application containing only static assets. So, you only need to setup a mechanism to serve your static assets like CSS, JS, HTML, IMAGE, etc. files when clients ask for. Either you can use market leader HTTP servers like Apache, Nginx, etc or simple Express server that runs in Node.js.

Continue reading

banner

React.js | Advanced Todo App from scratch for beginner | Bootstrap | In a nut shell

Introduction

It is a good practice to follow community standards while developing softwares. It has some major pros like

  • Its easier to understand and debug/maintain software
  • quicker to get help when needed from community
  • It will lower development cost [Money and Time]

We will be taking the convention used by this project into consideration. react-slingshot

Initialize

Make a dir called ‘todo‘ and initialize a node.js app. Continue reading

Developer’s checklist: Production deployment

One has to be very careful for shipping new changes/features to the production server.

When feature is said to be done

Assumption: Proper development processes have been followed

  1. Smoke Test in local machine
  2. Production Database backups
    • Generate snapshots or database-dumps
    • Store the backups in safe places
    • In case of Heroku, you will be provided with backup-tools
  3. Codebase versioning in Github / Diffusion
    • Create tags with proper naming conventions followed
    • eg V 0.1.1 or V 1.0.0 pre
  4. Deployment to production
    • Deploy the changes to the server
    • Make sure you run rake db:migrate is any migration pending
  5. Do data migrations if required
    • Already existing Production data might not co-op with your new code changes
      • reasons: there might be some data-fields manipulations or
        • new cols might have been added and data need to be filled in; data to be gathered from existing fields
    • Document the migration code you wrote for data-migrations [remember I am not taking about schema migrations]
    • eg
TransactionHistory.recurring_rewards.each do |tx|
   charge = Stripe::Charge.retrieve(tx.charge_id)
   invoice = Stripe::Invoice.retrieve(charge.invoice)
   subscription_id = invoice.subscription
   metadata = tx.transaction_additional_detail.metadata
   tx.transaction_additional_detail.update metadata: metadata.deep_merge(
                                           {
                                               subscription_id: subscription_id,
                                               invoice_id: invoice.id
                                           })
end
  1. Smoke test in production
capistranologo

Capistrano : SSHKit : Introduction

SSHKit is an amazing tool to run any commands on your VPS or docker images as any user. Capistrano uses it to all the server related stuffs. In other words you can build your own deployer software or server maintenance tools using SSHKit.

$ gem install sshkit

Simple Introduction

Lets create a ruby script to create a file in my VPS’s home directory

require 'sshkit'
require 'sshkit/dsl'
on ['deployer@4X.79.XXX.XX1'], in: :sequence, wait: 1 do |host|
  within '~' do # or '/home/deployer/'
    as :deployer do
      execute 'echo', 'My name is shiva > shiva.txt'
    end
  end
end

Go and check in your VPS, you see the file Continue reading

Capistrano 3.0 : Task Flow : Rails deployment

Deploy flow

When you run cap production deploy, it invokes the following tasks in sequence:

deploy:starting    - start a deployment, make sure everything is ready
deploy:started     - started hook (for custom tasks)
deploy:updating    - update server(s) with a new release
deploy:updated     - updated hook
deploy:publishing  - publish the new release
deploy:published   - published hook
deploy:finishing   - finish the deployment, clean up everything
deploy:finished    - finished hook

Notice there are several hook tasks e.g. :started, :updated for you to hook up custom tasks into the flow using after() and before().

Flow examples

Continue reading