Deploying to Render¶
Render is an excellent Platform-as-a-Service (PaaS) for deploying the NestJS Backend (apps/api). It supports Docker and native Node.js environments.
Deployment via Docker (Recommended)¶
Since Atlas ERP is a monorepo, using Docker ensures that all shared packages (packages/database, packages/types) are correctly built and bundled with the API.
1. Create a Web Service¶
- Go to Render Dashboard -> New -> Web Service.
- Connect your GitHub repository.
2. Configure Service¶
- Name: e.g.,
atlas-erp-api - Environment: Docker
- Region: Choose a region close to your Database (e.g., US East).
- Branch:
main
3. Environment Variables¶
You must set all the required backend environment variables. Go to the Environment tab and add:
DATABASE_URL(Your Neon or Render PostgreSQL connection string)REDIS_HOST,REDIS_PORT,REDIS_PASSWORD(Your Upstash details)BETTER_AUTH_SECRET,JWT_SECRET,JWT_REFRESH_SECRETBETTER_AUTH_URL(The URL Render assigns to this service, e.g.,https://atlas-erp-api.onrender.com)WEB_URL(Your frontend URL, e.g.,https://app.yourdomain.com)TRUSTED_ORIGINS(e.g.,https://app.yourdomain.com)PORT:3001
4. Build and Deploy¶
Render will read the Dockerfile at the root of the repository.
Note: Ensure your Dockerfile uses Turborepo's prune command to selectively build only apps/api and its dependencies.
| Docker | |
|---|---|
Running Migrations on Render¶
You need to ensure database migrations run before the API starts. You can configure a Pre-Deploy Command in Render:
| Bash | |
|---|---|