This guide will help you deploy your NestJS app or API to the Adaptable Cloud. In just a few clicks, Adaptable deploys all the cloud-based resources you need to run your NestJS app, including:
- Building your app into Serverless Containers
- Fully-managed Serverless Database (MongoDB, PostgreSQL, or MS SQL Server)
- Autoscaling
- Load Balancing
- HTTPS (SSL/TLS)
» Step 1: Get your app ready
Before you get started deploying your existing app, you may want to review the Adaptable containerized app requirements.
note
This template sets the PORT
environment variable to 3000 by default, which will work for most standard NestJS apps.
If your app listens for HTTP requests on a different hard-coded port number, you can change the port Adaptable uses in your app's Runtime Environment settings after the first deploy.
» Test your build first
When developing your code, you typically run the NestJS development server, usually via npm run start
.
The development server is very useful during development, but doesn't work well in a non-development environment like Adaptable because it is very slow, consumes excess memory, and may create security problems.
In Adaptable, you'll use the production build of your app, which is built with the nest build command. Before deploying to Adaptable, make sure that you can build your app successfully. To do this, run
npm run build #or yarn run build if you use yarn
If there are any errors running your build, fix them and push the fixes to GitHub before deploying on Adaptable.
note
By default, the template assumes that build
is your script that runs nest build
.
This is correct for the default NestJS setup.
However, your NestJS setup may have a different build script.
If you have a different build script, make sure to change the Build Scripts setting when deploying to Adaptable.
If your package.json does not have a build script that runs nest build
, make sure you add one and configure it during App setup below.
» Push to GitHub
Make sure that any changes you made to your project from the steps above have been committed to git and pushed to your GitHub repo.
» Step 2: Connect to GitHub
Start by clicking the button below:
Alternatively, you can go to your App Dashboard, then click the New App
button and then Connect an Existing Repository
.
If you haven't yet connected any of your GitHub repositories to Adaptable, click Connect GitHub Repository
.
Choose which scope you'd like to connect Adaptable to. You can connect Adaptable to your personal GitHub scope or to an organization you're a member of.
And finally, click the Install & Authorize
button.
» Step 3: Choose a GitHub repo to deploy
Next, choose the repo you'd like to deploy to the Adaptable Cloud.
If you don't see the repo you're looking for, click Add more GitHub repositories
to authorize Adaptable on more of your repos or GitHub organizations.
Then select the branch you'd like to deploy. Once connected, Adaptable sets up continuous deployment to build and deploy your repo each time you push to this branch.
» Step 4: Choose a Deploy Template
Since you're deploying a NestJS app, choose the NestJS App Template
.
» Step 5: Review settings
The default settings for the Deploy Template are shown.
For more information on each setting, click the help icon next to the setting or see the template documentation.
To change a setting, click Change
next to the setting you wish to change.
When you're satisfied with the settings, click Next
.
note
The template sets your Start Command to node dist/main
.
This is correct for the default nest build
settings.
However, your NestJS setup may compile your project's main
to a different location than dist/main
.
To confirm the correct path to main
for the Start Command, run npm run build
on your local development system and then locate main.js
in the dist
directory.
For example, if it's located at dist/src/main.js
, modify your Start Command to node dist/src/main
instead of node dist/main
.
» Step 6: Choose an app name
Choose a name for your app project on Adaptable.
This name will be used to create a URL for your project like https://YOURAPPNAME.adaptable.app
, so it must be unique among all other app names on Adaptable.
Enter your chosen app name and click Next
.
» Step 7: Pre-flight checks
Adaptable will now perform some basic checks on your GitHub repo to ensure it's ready to deploy.
Most of the checks can be performed automatically.
However, this screen asks you to manually confirm that your app listens for HTTP requests on the port specified by the environment variable PORT
.
(See Step 1 above.)
Click the square checkbox to confirm.
For more information on any of the checks, see Pre-flight checks. If the checks do not pass or you have more questions on them, contact our support team for help.
When the checks have passed, click Deploy App
to start deploying your new app.
» Deployed!
Once deployment is complete, your app will be running at https://YOURAPPNAME.adaptable.app
.
You will be redirected to the app status page with a congratulations message if your app deployed successfully.
Otherwise you'll get an error message and some help to resolve the error.
In either case, you will have the option to take a tour to see how Adaptable works!
tip
Now that your app is set up on Adaptable, each time you push to the branch you selected on your GitHub repo, Adaptable will automatically deploy your code changes.
» Having trouble?
Look for the How to Fix This App
tip box on your App Status page.
It will help guide you toward logs and documentation appropriate for the error your app has.
If you need to make any code changes, you can push to your GitHub repo to update your app and Adaptable will re-deploy it.
If you're still having trouble deploying, contact our support team for help.