NestJS
Learn how to deploy a NestJS application to Valyent
Introduction
NestJS is a progressive Node.js framework for building efficient, reliable and scalable server-side applications. In this article, we are going to deploy a freshly created NestJS API to Valyent.
Prerequisites
- a UNIX-like system (see WSL if you are using Windows), in order to use the Valyent CLI
- a Valyent account, with a registered payment method (you can sign up here)
- NodeJS and NPM installed on your machine
Installing the CLI
You can inspect the installation script here and the GitHub repository.
Authenticating
Initializing the project
In the first place, we are going to set up a new NestJS project. To do that, we’ll need the NestJS CLI, which we can install this this way :
Then, we can scaffold the NestJS project :
Now, we can initialize the valyent.toml
configuration file, that allows to link the local codebase, to a Valyent application :
This command will ask you to select/create a project and an associated application.
Adding the Dockerfile
Let’s add a Dockerfile so that Valyent can build a Docker image for your application.
We can fill it this way :
Deploy the project
To expose the application’s port, we need to set up the PORT
environment variable :
Then, we can deploy the application :
Once the deployment is finished, type :
to see your NestJS application in your browser.