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.
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
Make a dir called ‘todo‘ and initialize a node.js app. Continue reading
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
You have not chosen to deploy your application to fancy web hosting services like Engineyard, Digitalocean, or Heroku then you might be willing to know how to give other developers collaborating in this project access to the server via SSH. In other words you want to let others to deploy the application via SSH (eg. Capistrano).
Well, its pretty much simpler than you have thought. Follow the steps
- Copy the public key of your colleague to clipboard ( Ctrl + C )
- SSH into the server
- If you want to use the same username for all developer (say `deployer`)
- If want a separate username for every individual
- It would be great if you create separate user-group for deployment purposes like `deployers`
- create a new user in that group with privileges you like
- to give sudo access you need to update the
- The configuration file for sudo is
- goto that particular user’s home directory
- add his ssh public key to the /home/user/.ssh/authorized_keys file
- the .ssh folder might not already be available, you can create though
$ mkdir /home/user/.ssh
- copy the content using `nano or echo` into the file
- Now you are Done!
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
Lets create a ruby script to create a file in my VPS’s home directory
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'
Go and check in your VPS, you see the file Continue reading
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.
:updated for you to hook up custom tasks into the flow using
Capistrano is designed to run commands remotely. To do this we’ll need to specify a server, which we do by calling
server. We need to pass this the address of a server and a role. We’ll explain roles later; for now we’ll just set this to
First you need to set the configurations. Common settings go to the `deploy.rb` and environment specific settings goes to either 'config/deploy/production.rb' or 'staging.rb'