Developer Advocate at Cloud Foundry Foundation
In addition, tools such as Netlify and Vercel have provided a modern developer experience that makes deployments frictionless. The sheer convenience that these deployment tools provide has made the ecosystem desire the same kind of experience for all infrastructure.
Ultimately, what does this enable?
Let’s start with a fundamental problem – Writing a Dockerfile.
In order to create a container for an application written in Node.JS, we need a Dockerfile. This will specify the commands needed to download dependencies, install the application, and finally start it.
Next, the convenient deployment methods promised by Netlify, Vercel, Cloudflare pages etc. are limited to static websites and not full-fledged applications. Developers who would like to deploy full stack applications are forced to look elsewhere. They either have to default to writing Dockerfiles or use platforms such as Heroku which are more accommodating of their needs.
Developers do not have any control over the nature of compute that will ultimately power their experience. There aren’t options to accommodate multi- or hybrid- cloud architectures.
As one example, let’s have a look at how Cloud Foundry solves these problems.
First of all, using Paketo (or any other Buildpacks) eliminates the need for writing Dockerfiles. Consequently, the burden of maintaining them is also eliminated. Cloud Foundry can deploy single-page apps, complex applications, or headless API endpoints and builds them uniformly. With the cf-for-k8s project, developers can deploy to a Kubernetes cluster of their choice, which is running on any infrastructure.
In addition, platform operators can make use of the Buildpacks to apply best practices during build time as opposed to pushing this as another task for developers to worry about.
Here’s a link to a tutorial that explains how to deploy a full stack Node.JS application to Kubernetes using the Cloud Foundry developer experience. (Watch a video instead, if you’re the sort that prefers to learn visually).
Here are some of the highlights from the installation process:
The command used to deploy the application is
cf push foo-foo Pushing app foo-foo to org test / space dev as admin...Packaging files to upload...Uploading files... 530 B / 530 B [====================================================] 100.00% 1s Waiting for API to complete processing files... Staging app and tracing logs...
The analysis phase within the cf push process identified the need for the following Buildpacks
3 of 4 buildpacks participating paketo-buildpacks/node-engine 0.1.2 paketo-buildpacks/npm-install 0.2.1 paketo-buildpacks/npm-start 0.0.2
The Buildpacks selected the NPM build process and completed installing the app in a mere seconds.
Selected NPM build process: 'npm install' Executing build process Running 'npm install --unsafe-perm --cache /layers/paketo-buildpacks_npm-install/npm-cache' Completed in 1.415s
Finally, the build completes and the containers are cached as layers inside a container registry. These layers can be individually addressed and updated allowing operators to rebase the final image instead of rebuilding whole images during updates.
After the build complete and the containers have been cached, the app is automatically started and a unique link(route) will be generated for you to see the app live.
Paketo NPM Start Buildpack 0.0.2 Assigning launch processes web: node server.js Adding layer 'paketo-buildpacks/node-engine:node' Adding layer 'paketo-buildpacks/npm-install:modules' Adding layer 'paketo-buildpacks/npm-install:npm-cache' Adding 1/1 app layer(s) Adding layer 'launcher' Adding layer 'config' Adding label 'io.buildpacks.lifecycle.metadata' Adding label 'io.buildpacks.build.metadata' Adding label 'io.buildpacks.project.metadata' *** Images (sha256:8d82765365bcceb52cc3b378e6f1d82e7869acd0543562039d855ad628918f6c): registry.gitlab.com/ramanujank/test-container-registry/278317be-6f71-498e-9e6a-7eb2e1076bcd registry.gitlab.com/ramanujank/test-container-registry/278317be-6f71-498e-9e6a-7eb2e1076bcd:b1.20210219.123808 Adding cache layer 'paketo-buildpacks/node-engine:node' Adding cache layer 'paketo-buildpacks/npm-install:modules' Adding cache layer 'paketo-buildpacks/npm-install:npm-cache' Build successful Waiting for app foo-foo to start...
If you have questions when getting started with cf-for-k8s or, for that matter Cloud Foundry in general, go to the Cloud Foundry community at slack.cloudfoundry.org. You’ll find the community is more than happy to welcome and help you out. Also, for more information about the Cloud Foundry Foundation and what it does, visit cloudfoundry.org.
Create your free account to unlock your custom reading experience.