This post contains content about Now 1.0 – Learn about the latest version, Now 2.0.
Now 2.0 - Upgrade Available
Businesses and engineering teams alike have long recognized the value of continuous integration (CI) and continuous deployment (CD) to build better products, faster.
The Now platform unifies these processes and provides you a secure and efficient pipeline for building, optionally running tests, and finally serving or executing your code, on-demand.
This article will go into a few examples of the value proposition, using our GitHub integration to take every push to the cloud.
We recently announced support for Dockerfile for building static websites. In a nutshell, if you give now a Dockerfile whose RUN instructions populate a /public directory, Now will serve it through our massively scalable CDN with 150+ locations around the world.
The exciting part is that because of the incredible versatility, flexibility, and reproducibility Dockerfile provides, this even makes it the perfect place to run tests.
This is not only due to practical reasons (i.e., setting up a single GitHub integration and minimizing costs). A unified environment prevents unexpected differences between environments.

With Now, the test, build and serving phases share the same environment and infrastructure.

In the following example, we show how Now is useful even for testing libraries that don't have a visible frontend. How? By executing our test runner and outputting the HTML reporting results to the /public directory, like any other static website.

The tests are available at https://router-fwckhgpkpx.zeit.sh. Full source code on GitHub.

Many CI/CD providers make many assumptions about the environment:
  • They give you VMs with an arbitrary operating system/version
  • They install (e.g., via apt) many utilities on your behalf
  • They use utilities like nvm to get a version of Node.js
Now, instead, gives you full control. To top it off, these are all the instructions it took to produce the above:
FROM node:10-alpine
WORKDIR /usr/src
COPY package.json yarn.lock ./
RUN yarn
COPY . .
RUN yarn test
Finally, with Now, the "Details" link on GitHub always goes to your deployment, which means that by default you see the beautiful UI of your tests, as shown in the video below. Logs are still available, of course, and you can access them quickly by suffixing /_logs to the URL:

Test results can be output to the deployment with the benefit of having the deployment logs still available for even more information.

When building programs that need to be compiled before distribution (such as CLI applications), it's helpful to have a build environment in the cloud. Building and publishing from a developer machine introduces security concerns and most likely, suboptimal performance.
In this example, the Dockerfile executes gox, a utility that runs the Go compiler in parallel to produce static binaries for all available operating system and architectures.
This is what the Dockerfile looks like:
FROM golang:1.10-alpine
RUN apk add --no-cache git &&  go get github.com/mitchellh/gox
COPY . .
RUN gox -output="/public/{{.Dir}}_{{.OS}}_{{.Arch}}"
With just four instructions we get a reproducible build environment that runs in the cloud for every push and every PR.
Where Now shines is in the ability to serve those binaries as a static deployment, by merely outputting them to the /public directory.

Each push inside a pull request gets built. The resulting static deployment contains the compiled Go binaries.

At ZEIT we recognized an opportunity to improve the story around distributing Node.js applications. We thought cross-compiling your app into binaries (similarly to Go), by embedding the Node.js runtime, not only could improve distribution but even improve boot up times.
We set out to solve that problem with pkg, now one of our most popular Open Source projects.
The following example uses pkg to create binaries for Linux (GLIBC), Linux (MUSL) and macOS:
FROM node:10-alpine
COPY package.json yarn.lock ./
RUN yarn
COPY . .
RUN yarn build -o /public/now-pkg
With the package.json scripts.build instruction looking like this:
{
  "scripts": {
    "build": "pkg -t node8-alpine,node8-linux,node8-mac,node8-win ."
  }
}

The commits page reveals the deployment of every push. The resulting deployment contains the Node.js binaries created by `pkg`.

In this blog post, we have demonstrated some powerful, advanced use-cases of Now in combination with GitHub.
Before serving your deployment via our CDN, we execute the build instructions you supply via a Dockerfile, containing instructions to, for example:
  • Compile and Build
  • Pre-fetch data
  • Run tests
  • Execute hooks and issue notifications
We look forward to seeing how you use these powerful primitives in your projects. Join our community and let us know!