Quickstart: Deploy a NestJS App
This guide explains how to deploy a NestJS application to seenode.
Deploy a NestJS Template
Section titled “Deploy a NestJS Template”Get started in seconds by deploying our pre-configured NestJS template. This example is ready to deploy and reflects the structure discussed in this guide.
NestJS Template
Deploy a NestJS project pre-configured for production.Deploying an Existing NestJS Project
Section titled “Deploying an Existing NestJS Project”Follow these steps to prepare and deploy your NestJS project.
-
Prepare Your Project for Production
Your project structure should be ready for deployment. The NestJS starter template is well-configured for production builds.
Project Structure
A typical NestJS project contains the following key files:
Directoryyour-nestjs-project/
- package.json
- nest-cli.json
- tsconfig.json
Directorysrc/
- main.ts // The application entry point
- app.module.ts // The root module of the application
- app.controller.ts
- app.service.ts
By default, a new NestJS application listens on port
3000
. To deploy on seenode, you should modifysrc/main.ts
to listen on the port defined in an environment variable. You can then set thisPORT
variable in your service’s environment settings on seenode.src/main.ts import { NestFactory } from '@nestjs/core';import { AppModule } from './app.module';async function bootstrap() {const app = await NestFactory.create(AppModule);await app.listen(process.env.PORT || 3000);}bootstrap(); -
Deploy on seenode
Follow these steps to deploy your NestJS application:
- First, create a new Web Service from the seenode Dashboard and connect your NestJS project’s Git repository.
- Configure your build and start commands in the settings. seenode will attempt to detect these automatically for a NestJS project. A common setup is:
- Build Command: npm i && npm run build
- Start Command: npm run start:prod
- Build Command:
- Configure any production environment variables your application needs in the Environment tab. Make sure to set a
PORT
variable (e.g.,8080
). seenode does not automatically assign one. - Choose your preferred instance size and create your service.
- Watch your deployment progress in real-time through the Logs tab.
- Once complete, your NestJS application will be accessible via your service’s URL.
Next Steps
Section titled “Next Steps”Now that your NestJS application is deployed, here are some things you might want to do next:
Set up a Custom Domain (Coming Soon)
Configure a custom domain to point to your new web service.Connect to a Database
Instantly scaffold and connect PostgreSQL and MySQL databases