This guide walks you through setting up, containerizing, and deploying a NestJS application on Akash Network.
1. Build a NestJS App
Follow these steps to create and prepare your NestJS app:
Step 1.1: Create a New NestJS App
- Ensure Node.js and npm are installed on your system.
- Run the following commands:
npm i -g @nestjs/cli nest new my-nestjs-app
- Navigate into the project:
cd my-nestjs-app
Step 1.2: Configure Your Application
- Install any additional packages your app needs (e.g.,
npm install --save <package>
). - Update the application logic in the appropriate directories (e.g.,
src/
).
2. Containerize the App
To deploy the app on Akash, you need to containerize it using Docker
.
Step 2.1: Create a Dockerfile
In the root of your NestJS app, create a Dockerfile:
# Base imageFROM node:18-alpine
# Set working directoryWORKDIR /app
# Copy package files and install dependenciesCOPY package*.json ./RUN npm install
# Copy the rest of the appCOPY . .
# Build the appRUN npm run build
# Expose port 3000EXPOSE 3000
# Command to start the appCMD ["npm", "run", "start:prod"]
Step 2.2: Build and Test the Image
- Build the Docker image:
docker build -t my-nestjs-app .
- Run the image locally to test:
docker run -p 3000:3000 my-nestjs-app
- Visit
http://localhost:3000
to confirm your app works.
3. Deploy to Akash
Akash supports deployments via its CLI or Web Console. Below, you’ll find instructions for both, along with a sample deploy.yaml
file.
Step 3.1: Prepare the Deployment File
Akash deployments require an SDL file (deploy.yaml). Below is a sample based template:
---version: "2.0"
services: web: image: my-nestjs-app expose: - port: 3000 as: 80 to: - global: true
profiles: compute: web: resources: cpu: units: 0.5 memory: size: 512Mi storage: size: 1Gi
placement: westcoast: attributes: region: us-west signedBy: anyOf: - "akash1xxxxxx" pricing: web: denom: uakt amount: 1000
deployment: web: westcoast: profile: web count: 1
Replace my-nestjs-app
with the name of your image in a public Docker registry (e.g., Docker Hub).
Step 3.2: Deploy Using Akash CLI
- Install Akash CLI by following Akash CLI Installation Guideenticate your wallet by following Wallet Authentication .
- Deploy
deploy.yaml
using the commands below:
akash tx deployment create deploy.yaml --from <your-wallet-name> --node <akash-node-url>
Detailed CLI deployment instructions are available here.
Step 3.3: Deploy Using Akash Web Console
If you prefer a GUI, use the Akash Console.
- Access the console at console.akash.network.
- Login with your wallet.
- Follow the Console Deployment Guide to upload your
deploy.yaml
file to complete the process.
4. Monitor and Access Your App
After deployment:
1. Use the Akash CLI or Console to monitor the status of your deployment.2. Retrieve the app's external URL or IP from the deployment details.3. Access your app via a browser or API client.