Skip to main content

Windows Server Installation

Step-by-step guide for deploying WorkForce on Windows Server.

Prerequisites

  1. Windows Server 2019 or 2022
  2. Node.js 20 LTS — Download from nodejs.org
  3. PostgreSQL 16 — Download from postgresql.org
  4. Git (optional) — For cloning the repository

Step 1: Install Node.js

  1. Download the Node.js 20 LTS Windows installer (.msi)
  2. Run the installer with default options
  3. Verify:
node --version   # Should show v20.x.x
npm --version # Should show 10.x.x

Step 2: Install PostgreSQL

  1. Download and run the PostgreSQL installer
  2. Set a strong password for the postgres user
  3. Keep default port 5432
  4. After installation, open pgAdmin or psql and create the database:
CREATE USER workforce WITH PASSWORD 'YourStrongPassword';
CREATE DATABASE workforce OWNER workforce;

Step 3: Deploy Application Files

Option A: Git Clone

cd C:\
git clone https://github.com/your-org/workforce.git WorkForce
cd WorkForce

Option B: Copy Files

Copy the project folder to C:\WorkForce.

Step 4: Configure Environment

cd C:\WorkForce
Copy-Item .env.example .env
notepad .env

Edit .env with your production values:

NODE_ENV=production
DATABASE_URL="postgresql://workforce:YourStrongPassword@localhost:5432/workforce?schema=public"
NEXTAUTH_SECRET="generated-random-secret"
NEXTAUTH_URL="https://your-domain.com"

Step 5: Install Dependencies & Build

npm ci
npx prisma generate
npx prisma migrate deploy
npm run build

Step 6: Configure as Windows Service

Using NSSM

  1. Download NSSM and extract to C:\nssm
  2. Install the service:
C:\nssm\nssm.exe install WorkForce "C:\Program Files\nodejs\node.exe"
C:\nssm\nssm.exe set WorkForce AppParameters "C:\WorkForce\node_modules\.bin\next start"
C:\nssm\nssm.exe set WorkForce AppDirectory "C:\WorkForce"
C:\nssm\nssm.exe set WorkForce AppEnvironmentExtra "NODE_ENV=production" "PORT=3000"
C:\nssm\nssm.exe set WorkForce DisplayName "WorkForce HR Platform"
C:\nssm\nssm.exe set WorkForce Description "WorkForce HR Management System"
C:\nssm\nssm.exe set WorkForce Start SERVICE_AUTO_START
C:\nssm\nssm.exe set WorkForce AppStdout "C:\WorkForce\logs\service-stdout.log"
C:\nssm\nssm.exe set WorkForce AppStderr "C:\WorkForce\logs\service-stderr.log"
  1. Start the service:
C:\nssm\nssm.exe start WorkForce
  1. Verify:
Get-Service WorkForce

Step 7: Configure Firewall

# Allow HTTP and HTTPS
New-NetFirewallRule -DisplayName "WorkForce HTTP" -Direction Inbound -Port 80 -Protocol TCP -Action Allow
New-NetFirewallRule -DisplayName "WorkForce HTTPS" -Direction Inbound -Port 443 -Protocol TCP -Action Allow

Step 8: Set Up Reverse Proxy

See the Reverse Proxy guide for IIS or Caddy configuration.

Updating the Application

cd C:\WorkForce
C:\nssm\nssm.exe stop WorkForce
git pull # or copy new files
npm ci
npx prisma generate
npx prisma migrate deploy
npm run build
C:\nssm\nssm.exe start WorkForce