From df4083275318592f5358390916a018c2ac326112 Mon Sep 17 00:00:00 2001 From: azeeee05 Date: Mon, 7 Sep 2026 20:13:36 +0530 Subject: [PATCH] feat: enhance README with detailed environment variables and build scripts for local, test, and production deployments --- README.md | 63 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e6f415a..1a85b4b 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,64 @@ Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/bui This project is configured with multiple environments for seamless deployments and testing. ### Environment Variables -- `.env` / `.env.local`: Used for local development (default points to `http://localhost:5173`). -- `.env.test`: Used for test environments (points to `http://localhost:5173`). -- `.env.production`: Used for the live production build (points to `https://app.docqube.com/login`). +- `.env`: Used by `npm run local` and points to `http://localhost:5173/login`. +- `.env.test`: Used by `npm run test` and `npm run build:test`; points to `https://docqubeapp-test.maskantech.in/login`. +- `.env.production`: Used by `npm run build:production` and `npm run prod`; points to `https://app.docqube.com/login`. **Note:** Environment files (`.env*`) are ignored in Git to keep variables secure. Make sure you create them locally if you clone this repository. ### Build Scripts -- `npm run dev`: Starts the local development server (uses `.env` / `.env.local`). -- `npm run build:test`: Uses `dotenv-cli` to load `.env.test` and runs the Next.js build. -- `npm run build:production`: Uses `dotenv-cli` to load `.env.production` and runs the Next.js build. +- `npm run local`: Starts the local development server using `.env`. +- `npm run test`: Starts the development server using `.env.test`. +- `npm run build:local`: Builds the application using `.env`. +- `npm run build:test`: Builds the application using `.env.test`. +- `npm run build:production`: Builds the application using `.env.production`. +- `npm run prod`: Starts the production server using `.env.production`. + +### Production Deployment Artifact + +The Next.js configuration uses standalone output. Build the production artifact with: + +```bash +npm ci +npm run build:production +``` + +The deployment must include: + + +Prepare the standalone artifact after building: + +```bash +cp -r public .next/standalone/ +cp -r .next/static .next/standalone/.next/ +``` + +On Windows PowerShell, use this equivalent sequence because `cp` does not merge existing directories: + +```powershell +Remove-Item -Recurse -Force .next\standalone\public -ErrorAction SilentlyContinue +Remove-Item -Recurse -Force .next\standalone\.next\static -ErrorAction SilentlyContinue +Copy-Item public .next\standalone\public -Recurse +Copy-Item .next\static .next\standalone\.next\static -Recurse +``` + +Start the standalone server with: + +```bash +node .next/standalone/server.js +``` + +On Windows PowerShell: + +```powershell +$env:PORT = "3000" +$env:HOSTNAME = "127.0.0.1" +node .next\standalone\server.js +``` + +For Nginx deployment, run the server on an internal port and reverse proxy to it: + +```bash +PORT=3000 HOSTNAME=127.0.0.1 node .next/standalone/server.js +```