full stack apps

Deploy with One Command

2343 VIEWS

Building an app in a local development environment is usually where I do most of my work, but as I continue to learn software development, I know that it is essential to deploy a web app early and often. There are more advantages to doing this than not. A/B testing, debugging potential production issues, beta testing, and ensuring that the production environment is stable are all great reasons to deploy, even at “Hello World!”

For those who are still learning like myself, the idea of configuring environments, plugins, and  looking at complex dashboards at times takes away from the bandwidth to write code, solve issues, and ship features. While services like AWS, Azure, and Heroku (which I will write a post about soon) are vital to the growth of developers and startups, maybe it would be great to be able to type one word in the command line and get an app deployed on the Web in real time.

This is the goal of Zeit’s Now, a service that allows the user to type the word “now” into the command line, and then this happens:  

 ~/my-proj $ ls 
package.json	index.js	lib	static 
~/my-proj $ now 
> Ready! https://my-proj-hj1v2m.now.sh
	(copied to clipboard) [440ms]

As long as your project has a package.json file with those three letters, you get a URL copied to your clipboard. This URL can be put into your browser and you will see a simple dashboard which displays the build steps for your deployment:

You can also look at your logs and source files:


Why is this a good option for deployment?

A great quality to Now is the unique URLs. They are helpful since there is no need to remove older URLs (in fact, you could use those for A/B tests). The most recent URL represents the current state of your application and can be shared immediately with teammates. This method also helps greatly with scalability of your apps. The other advantage to this is that you could always point a specific URL from your deployment history to your domain name if you need to go back to a preferred production build.

Zeit also believes in a minimalist approach to just about everything they do, and this is especially true of Now. Resources are used as needed, and the user doesn’t need to configure anything beyond a start script in their package.json. Another interesting strategy that Zeit employs is that they abstract their cloud providers, which is a multi-cloud strategy that allows them to provide the most reliable service possible.

Here are a few things to keep in mind when using Now:

For your project, you should use the latest version of Node and NPM (in fact, you should do this anyway since NPM v5 has answered Yarn quite well), but if you must use a different version, simply create and specify an engines field in your package.json and point it to the version of node you are using. If you want to specify Now-specific commands, you can write commands such as “now-build” or “now-start” if you want to override your usual build and start scripts (although, you could just use alternate scripts i.e. “start:prod” or “start:dev”). The “now” prefix can also come in handy for your engine if for some reason you want to specify a certain node version for your deployments.

{
 “name” : “my-project”, 
 “Version”: “0.1.0”, 
 “engines”:  { 
      “node”:  “4.x.x”
},
“now”:  { 
  “engines”: { 
      “node”:  “4.x.x” 
   } 
  } 
}

If your app is ready for production, Zeit offers domains with now integration and now alias, which is meant to point your Now deployment URL to a custom URL that the user owns. You do not need to buy a domain through Zeit, as long as you point your CNAME or ALIAS record to alias.zeit.co. Once Now confirms this, then the now process points the unique URL to the user’s custom domain, and then there is a production build ready for Beta testing.

~/my=proj $ now alias domains-help-ykaxwfgdoy.now.sh zeit.domains
> zeit.domains is a custom domain.
> verifying that zeir.domains has a CNAME or ALIAS record pointing to alias.zeir.co.
>Verification OK!
> Provisioning Certificate for Zeit.domains.
> Success! Alias created (8luXvHQCwbdaEN7QXEBL): https://domains-help-ykaxwfgdoy.now.sh (1edYGXD9JiLJxedzhn4VSvnj) now points to https://Zeit.domains

Performance

Since Now is fairly lightweight, it performs faster than a build through AWS or Heroku. I may have to update this post with data. Another consideration in performance is how Now serves apps without the need to use git. Now bundles the “src” file and simply deploys, so there’s no need to “git push now master” (that’s nice). I would recommend looking into a noSQL database for your data hosting needs if you’re using Now to deploy full stack apps (I have used a postgreSQL database and the deploy was fine, but a little slower than a noSQL option would be).  

When to use Now
I think that you should use Now—no pun intended (well, maybe a little) now. Try to build a quick node app and deploy it with the service. You can use the free version, but if you start getting really serious about using this for your team and/or startup, here are the pricing options. It can get a little expensive, but compared to other services, at $15 you can build up a great production environment for your full stack apps. The minimal nature of Zeit’s services are appealing, especially when considering how much configuration (and at times, multi-tab monitoring) one may have to do to deploy using other services. This post is by no means a statement on any other service. Other deployment platforms have their pros/cons, but Zeit has made a compelling product that requires minimal setup and provides an immediate, actionable deployment environment suitable for single and small team development.


Phillip Lorenzo is a recent graduate of Learners Guild, an apprenticeship program in Oakland, CA. Before beginning his journey to code, Phil was in nonprofit arts management and was also pursuing a filmmaking career. He started coding last January, and hasn’t looked back since.


Discussion

Click on a tab to select how you'd like to leave your comment

Leave a Comment

Your email address will not be published.

Menu
Skip to toolbar