This guide provides step-by-step instructions for deploying the Multi Dimension Deterrence Strategy (MDDS) application on both Windows and Linux servers.
- Prerequisites
- Windows Server Deployment
- Linux Server Deployment
- Post-Deployment Configuration
- Troubleshooting
Before deploying, ensure you have:
- Node.js 18 or higher installed
- PostgreSQL 14 or higher database
- Git (optional, for cloning the repository)
- At least 2GB RAM and 5GB disk space
- Download Node.js from https://nodejs.org
- Choose the LTS version (18.x or higher)
- Run the installer and follow the prompts
- Check installation by opening Command Prompt and running:
node --version npm --version
- Download PostgreSQL from https://www.postgresql.org/download/windows/
- Run the installer
- Set a password for the
postgresuser (remember this!) - Keep the default port
5432 - Complete the installation
- Open pgAdmin 4 (installed with PostgreSQL)
- Connect to your PostgreSQL server
- Right-click on Databases → Create → Database
- Name it
mddsand click Save
Alternatively, use Command Prompt:
psql -U postgres
CREATE DATABASE mdds;
\q- Extract the application ZIP file to a folder, e.g.,
C:\mdds-app - Open Command Prompt and navigate to the folder:
cd C:\mdds-app
Run the following command:
npm installThis will install all required packages (may take 2-5 minutes).
- Create a file named
.envin the application folder - Add the following content (replace values with your PostgreSQL credentials):
DATABASE_URL=postgresql://postgres:your_password@localhost:5432/mdds
PGHOST=localhost
PGPORT=5432
PGUSER=postgres
PGPASSWORD=your_password
PGDATABASE=mdds
SESSION_SECRET=your-random-secret-key-here
NODE_ENV=productionImportant: Replace your_password with your actual PostgreSQL password and generate a random string for SESSION_SECRET.
Run the database migration:
npm run db:pushIf you see a warning about data loss, run:
npm run db:push --forceBuild the production version:
npm run buildThis creates optimized files in the dist folder.
Start the server:
npm startOr for production with PM2 (recommended):
npm install -g pm2
pm2 start npm --name "mdds" -- start
pm2 save
pm2 startupThe application will be available at http://localhost:5000
- Open Windows Defender Firewall → Advanced Settings
- Click Inbound Rules → New Rule
- Select Port → Click Next
- Select TCP and enter port
5000→ Click Next - Select Allow the connection → Click Next
- Check all profiles (Domain, Private, Public) → Click Next
- Name it "MDDS Application" → Click Finish
- Local access:
http://localhost:5000 - Network access:
http://YOUR_SERVER_IP:5000 - Replace
YOUR_SERVER_IPwith your server's IP address
Open terminal and run:
sudo apt update
sudo apt upgrade -yFor CentOS/RHEL:
sudo yum update -yFor Ubuntu/Debian:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejsFor CentOS/RHEL:
curl -fsSL https://rpm.nodesource.com/setup_18.x | sudo bash -
sudo yum install -y nodejsVerify installation:
node --version
npm --versionFor Ubuntu/Debian:
sudo apt install -y postgresql postgresql-contrib
sudo systemctl start postgresql
sudo systemctl enable postgresqlFor CentOS/RHEL:
sudo yum install -y postgresql-server postgresql-contrib
sudo postgresql-setup initdb
sudo systemctl start postgresql
sudo systemctl enable postgresqlSwitch to postgres user:
sudo -u postgres psqlRun the following SQL commands:
CREATE DATABASE mdds;
CREATE USER mdds_user WITH PASSWORD 'your_secure_password';
GRANT ALL PRIVILEGES ON DATABASE mdds TO mdds_user;
\qEdit the PostgreSQL configuration:
sudo nano /etc/postgresql/14/main/pg_hba.confFind the line:
local all all peer
Change it to:
local all all md5
Restart PostgreSQL:
sudo systemctl restart postgresqlUpload the ZIP file to your server and extract:
cd /var/www
sudo mkdir mdds-app
sudo chown $USER:$USER mdds-app
cd mdds-app
unzip /path/to/mdds-app.zipOr clone from Git (if available):
git clone <repository-url> /var/www/mdds-app
cd /var/www/mdds-appnpm installCreate .env file:
nano .envAdd the following:
DATABASE_URL=postgresql://mdds_user:your_secure_password@localhost:5432/mdds
PGHOST=localhost
PGPORT=5432
PGUSER=mdds_user
PGPASSWORD=your_secure_password
PGDATABASE=mdds
SESSION_SECRET=your-random-secret-key-here
NODE_ENV=productionSave and exit (Ctrl+X, then Y, then Enter).
npm run db:pushIf needed:
npm run db:push --forcenpm run buildsudo npm install -g pm2pm2 start npm --name "mdds" -- start
pm2 save
pm2 startupFollow the command output to set up PM2 to start on boot.
For Ubuntu/Debian (UFW):
sudo ufw allow 5000/tcp
sudo ufw reloadFor CentOS/RHEL (firewalld):
sudo firewall-cmd --permanent --add-port=5000/tcp
sudo firewall-cmd --reloadInstall Nginx:
sudo apt install -y nginx # Ubuntu/Debian
# OR
sudo yum install -y nginx # CentOS/RHELCreate Nginx configuration:
sudo nano /etc/nginx/sites-available/mddsAdd the following:
server {
listen 80;
server_name your-domain.com; # Replace with your domain or IP
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}Enable the site:
sudo ln -s /etc/nginx/sites-available/mdds /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx- Direct access:
http://YOUR_SERVER_IP:5000 - Via Nginx:
http://YOUR_SERVER_IPorhttp://your-domain.com
- Install Certbot:
sudo apt install -y certbot python3-certbot-nginx- Obtain SSL certificate:
sudo certbot --nginx -d your-domain.com- Follow the prompts to complete setup
View logs:
pm2 logs mddsRestart application:
pm2 restart mddsStop application:
pm2 stop mddsView status:
pm2 statusMonitor resources:
pm2 monit- Database Password: Password for "MDDS" (database access settings dialog)
- Single Player Password: "MDDS"
- Research Dashboard: No password required
- Analysis Dashboard: No password required
Problem: Cannot connect to database
Solution:
-
Check PostgreSQL is running:
- Windows: Services → PostgreSQL
- Linux:
sudo systemctl status postgresql
-
Verify
.envfile has correct credentials -
Test database connection:
psql -U mdds_user -d mdds -h localhost
Problem: Port 5000 is already taken
Solution:
-
Find what's using the port:
- Windows:
netstat -ano | findstr :5000 - Linux:
sudo lsof -i :5000
- Windows:
-
Change the port in the application by editing
server/index.ts:const PORT = process.env.PORT || 3000; // Change from 5000
-
Rebuild and restart the application
Problem: Application fails to start
Solution:
-
Check logs:
pm2 logs mdds --lines 50
-
Verify Node.js version:
node --version # Should be 18+ -
Reinstall dependencies:
rm -rf node_modules package-lock.json npm install
Problem: Application runs out of memory
Solution:
-
Increase Node.js memory limit:
pm2 delete mdds pm2 start npm --name "mdds" --node-args="--max-old-space-size=4096" -- start
-
Monitor memory usage:
pm2 monit
Problem: Environment variables not loading
Solution:
-
Ensure
.envfile is in the root directory -
Check file permissions:
chmod 600 .env
-
For PM2, use ecosystem file:
pm2 ecosystem
Edit
ecosystem.config.jsto include env variables
| Feature | Password | Purpose |
|---|---|---|
| Single Player Mode | MDDS |
Access single-player AI game |
| Database Sessions | MDDS |
View stored game sessions |
| Permanent Cards Logs | MDDS |
View card purchase history |
- CPU: 2 cores
- RAM: 2GB
- Disk: 5GB
- OS: Windows Server 2016+ or Ubuntu 18.04+
- CPU: 4 cores
- RAM: 4GB
- Disk: 10GB SSD
- OS: Windows Server 2019+ or Ubuntu 20.04+
-
Update dependencies:
npm update npm audit fix
-
Backup database:
pg_dump -U mdds_user mdds > backup_$(date +%Y%m%d).sql
-
Monitor disk space:
- Windows: Check C:\ drive space
- Linux:
df -h
-
Update Node.js when needed:
- Windows: Download new installer
- Linux: Use NodeSource repository
Create /etc/logrotate.d/mdds:
/var/www/mdds-app/logs/*.log {
daily
rotate 7
compress
delaycompress
notifempty
create 0640 www-data www-data
sharedscripts
postrotate
pm2 reloadLogs
endscript
}
- The application uses port 5000 by default
- Session data is stored in PostgreSQL database
- Game sessions are automatically saved to the database
- The application supports multiple concurrent users
- All passwords are case-sensitive
- For production use, always use HTTPS with SSL certificate
# Install Node.js and PostgreSQL
# Create database
psql -U postgres -c "CREATE DATABASE mdds;"
# Extract files and install
cd C:\mdds-app
npm install
npm run db:push
npm run build
npm start# Install Node.js and PostgreSQL
sudo apt install -y nodejs postgresql
# Create database
sudo -u postgres psql -c "CREATE DATABASE mdds;"
# Extract and install
cd /var/www/mdds-app
npm install
npm run db:push
npm run build
pm2 start npm --name "mdds" -- startFor additional help or questions, refer to the application documentation or contact your system administrator.