Athena — mahmoud-consultancy/archive/old-docs/DEPLOYMENT_GUIDE.md

🚀 GloryLabs InterimPlaza - Deployment Guide

Complete guide for deploying the InterimPlaza recruitment platform to production.


📋 Prerequisites

Required:

  • VPS with Ubuntu 22.04 LTS (minimum 2GB RAM)
  • Domain name (e.g., interimplaza.nl)
  • Node.js 20+ installed
  • Git access to repository

Services Needed:

  • PostgreSQL 15+ database
  • MinIO or S3-compatible storage for CV files
  • Email service (SendGrid, AWS SES, or SMTP)

🖥️ VPS Setup

1. Initial Server Setup

# Update system
sudo apt update && sudo apt upgrade -y

# Install Node.js 20 LTS
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs

# Install Nginx
sudo apt install -y nginx

# Install PostgreSQL
sudo apt install -y postgresql postgresql-contrib

# Install Git
sudo apt install -y git

# Install certbot for SSL
sudo apt install -y certbot python3-certbot-nginx

2. Create Application User

sudo adduser glorylabs
sudo usermod -aG sudo glorylabs
su - glorylabs

📦 Application Deployment

1. Clone Repository

cd /home/glorylabs
git clone https://github.com/yourorg/mahmoud-consultancy.git
cd mahmoud-consultancy

2. Backend Setup

cd backend/recruitment-backend

# Install Maven if not present
sudo apt install -y maven

# Build the application
mvn clean package -DskipTests

# Create application directory
sudo mkdir -p /opt/glorylabs
sudo cp target/recruitment-backend-*.jar /opt/glorylabs/app.jar
sudo chown -R glorylabs:glorylabs /opt/glorylabs

3. Database Setup

# Switch to postgres user
sudo -u postgres psql

# In PostgreSQL:
CREATE DATABASE interimplaza;
CREATE USER glorylabs WITH ENCRYPTED PASSWORD 'your_secure_password';
GRANT ALL PRIVILEGES ON DATABASE interimplaza TO glorylabs;
\q

4. Environment Configuration

# Create environment file
sudo nano /opt/glorylabs/.env

Add:

# Database
SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/interimplaza
SPRING_DATASOURCE_USERNAME=glorylabs
SPRING_DATASOURCE_PASSWORD=your_secure_password

# JWT
JWT_SECRET=your_256_bit_secret_key_here
JWT_EXPIRATION=3600000

# MinIO
MINIO_URL=https://minio.interimplaza.nl
MINIO_ACCESS_KEY=your_minio_access_key
MINIO_SECRET_KEY=your_minio_secret_key
MINIO_BUCKET=interimplaza-cvs

# Email
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=apikey
MAIL_PASSWORD=your_sendgrid_api_key
MAIL_FROM=noreply@interimplaza.nl

# App
APP_BASE_URL=https://interimplaza.nl
APP_FRONTEND_URL=https://interimplaza.nl

5. Create Systemd Service

sudo nano /etc/systemd/system/glorylabs-backend.service

Add:

[Unit]
Description=GloryLabs InterimPlaza Backend
After=network.target

[Service]
Type=simple
User=glorylabs
WorkingDirectory=/opt/glorylabs
EnvironmentFile=/opt/glorylabs/.env
ExecStart=/usr/bin/java -jar /opt/glorylabs/app.jar
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

Enable and start:

sudo systemctl daemon-reload
sudo systemctl enable glorylabs-backend
sudo systemctl start glorylabs-backend
sudo systemctl status glorylabs-backend

6. Frontend Build

cd /home/glorylabs/mahmoud-consultancy/frontend/recruitment-portal

# Install dependencies
npm install

# Build for production
npm run build

# Copy build to web directory
sudo mkdir -p /var/www/interimplaza
sudo cp -r dist/recruitment-portal/browser/* /var/www/interimplaza/
sudo chown -R www-data:www-data /var/www/interimplaza

🌐 Nginx Configuration

1. Create Nginx Config

sudo nano /etc/nginx/sites-available/interimplaza

Add:

server {
    listen 80;
    server_name interimplaza.nl www.interimplaza.nl;

    root /var/www/interimplaza;
    index index.html;

    # Frontend - Angular routing
    location / {
        try_files $uri $uri/ /index.html;
    }

    # Backend API proxy
    location /api/ {
        proxy_pass http://localhost:8080/api/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        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;
        proxy_cache_bypass $http_upgrade;
        proxy_read_timeout 300s;
        proxy_connect_timeout 300s;
    }

    # Security headers
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-XSS-Protection "1; mode=block" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;

    # Gzip compression
    gzip on;
    gzip_vary on;
    gzip_min_length 1024;
    gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/javascript application/json;

    # Cache static files
    location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot)$ {
        expires 1y;
        add_header Cache-Control "public, immutable";
    }
}

Enable site:

sudo ln -s /etc/nginx/sites-available/interimplaza /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

2. SSL Certificate with Let's Encrypt

# Obtain certificate
sudo certbot --nginx -d interimplaza.nl -d www.interimplaza.nl

# Test automatic renewal
sudo certbot renew --dry-run

🔒 MinIO Setup (Optional - For CV Storage)

1. Install MinIO

wget https://dl.min.io/server/minio/release/linux-amd64/minio
sudo chmod +x minio
sudo mv minio /usr/local/bin/

# Create data directory
sudo mkdir -p /mnt/minio/data
sudo chown -R glorylabs:glorylabs /mnt/minio

2. Create MinIO Service

sudo nano /etc/systemd/system/minio.service

Add:

[Unit]
Description=MinIO
After=network.target

[Service]
Type=simple
User=glorylabs
Environment="MINIO_ROOT_USER=admin"
Environment="MINIO_ROOT_PASSWORD=your_secure_password"
ExecStart=/usr/local/bin/minio server /mnt/minio/data --console-address ":9001"
Restart=always

[Install]
WantedBy=multi-user.target

Enable:

sudo systemctl daemon-reload
sudo systemctl enable minio
sudo systemctl start minio

3. Configure Nginx for MinIO

Add to nginx config:

location /minio/ {
    proxy_pass http://localhost:9000/;
    proxy_set_header Host $host;
    client_max_body_size 10M;
}

🔐 Security Hardening

1. Firewall Setup

# Enable UFW
sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw enable

# Check status
sudo ufw status

2. Fail2Ban

# Install
sudo apt install -y fail2ban

# Configure
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo nano /etc/fail2ban/jail.local

# Enable and start
sudo systemctl enable fail2ban
sudo systemctl start fail2ban

3. Auto Updates

sudo apt install -y unattended-upgrades
sudo dpkg-reconfigure --priority=low unattended-upgrades

📊 Monitoring

1. Application Logs

# Backend logs
sudo journalctl -u glorylabs-backend -f

# Nginx logs
sudo tail -f /var/log/nginx/access.log
sudo tail -f /var/log/nginx/error.log

2. Resource Monitoring

# Install htop
sudo apt install -y htop

# Monitor resources
htop

# Check disk usage
df -h

# Check memory
free -h

🔄 Backup Strategy

1. Database Backup

# Create backup script
nano /home/glorylabs/backup-db.sh

Add:

#!/bin/bash
BACKUP_DIR="/home/glorylabs/backups"
DATE=$(date +%Y%m%d_%H%M%S)
mkdir -p $BACKUP_DIR

# Backup database
pg_dump -U glorylabs interimplaza > $BACKUP_DIR/db_$DATE.sql

# Keep only last 30 days
find $BACKUP_DIR -name "db_*.sql" -mtime +30 -delete

echo "Backup completed: db_$DATE.sql"

Make executable and add to crontab:

chmod +x /home/glorylabs/backup-db.sh
crontab -e

# Add daily backup at 2 AM
0 2 * * * /home/glorylabs/backup-db.sh

2. Application Files Backup

# Backup application directory
sudo tar -czf /home/glorylabs/backups/app_$(date +%Y%m%d).tar.gz /opt/glorylabs

🚀 Deployment Checklist

Pre-Deployment:

  • [ ] VPS provisioned and configured
  • [ ] Domain DNS pointed to VPS IP
  • [ ] SSL certificate obtained
  • [ ] Database created and migrated
  • [ ] Environment variables configured
  • [ ] MinIO bucket created
  • [ ] Email service configured

Deployment:

  • [ ] Code deployed to server
  • [ ] Backend service running
  • [ ] Frontend built and served
  • [ ] Nginx configured correctly
  • [ ] SSL working (HTTPS)
  • [ ] API endpoints responding
  • [ ] File uploads working

Post-Deployment:

  • [ ] Smoke tests passed
  • [ ] User registration working
  • [ ] Job listing loading
  • [ ] Application submission working
  • [ ] Admin dashboard accessible
  • [ ] Monitoring configured
  • [ ] Backups scheduled

🔧 Troubleshooting

Backend Won't Start

# Check logs
sudo journalctl -u glorylabs-backend -n 50

# Check if port is in use
sudo netstat -tulpn | grep 8080

# Verify environment variables
sudo systemctl show glorylabs-backend --property=Environment

Frontend Not Loading

# Check Nginx config
sudo nginx -t

# Verify files exist
ls -la /var/www/interimplaza

# Check Nginx logs
sudo tail -f /var/log/nginx/error.log

Database Connection Issues

# Test connection
psql -U glorylabs -d interimplaza -h localhost

# Check PostgreSQL status
sudo systemctl status postgresql

# Verify credentials in .env

📞 Support

For issues:

  1. Check application logs first
  2. Review Nginx error logs
  3. Verify environment configuration
  4. Check firewall rules
  5. Verify SSL certificate validity

Documentation: See README.md and API_SPECIFICATION.md
Contact: admin@glorylabs.nl


Deployment Guide Version: 1.0
Last Updated: October 11, 2025
Platform: GloryLabs InterimPlaza Recruitment Platform

Reacties

Nog geen reacties