Deployment Platform

    Self-Hosted Deployment with Dokploy

    Dokploy is a powerful self-hosted Platform-as-a-Service (PaaS) that simplifies Docker-based application deployment. With automatic SSL, built-in database management, and an intuitive interface, you can deploy and manage your applications on RamNode VPS with professional-grade features.

    Ubuntu 20.04+
    Docker Containers
    Automatic SSL
    ⏱️ 45-60 minutes

    Prerequisites

    Before starting, ensure you have:

    System Requirements

    • • Ubuntu 20.04+ or Debian 11+
    • • 4GB RAM minimum (8GB+ recommended)
    • • 50GB+ available storage
    • • 2+ CPU cores
    • • Public IP with ports 80, 443, 22 open

    Access Requirements

    • • SSH access to server
    • • Root or sudo privileges
    • • Domain name with DNS access
    • • Git repository (optional)
    2

    Server Preparation

    Update the system and install essential packages:

    Update System
    sudo apt update && sudo apt upgrade -y
    Install Essential Packages
    sudo apt install -y curl wget git unzip software-properties-common

    Configure Firewall

    Setup UFW Firewall
    sudo ufw enable
    sudo ufw allow 22/tcp     # SSH
    sudo ufw allow 80/tcp     # HTTP
    sudo ufw allow 443/tcp    # HTTPS
    sudo ufw allow 3000/tcp   # Dokploy dashboard
    sudo ufw status
    3

    Install Docker

    Install Docker and Docker Compose:

    Install Docker
    # Add Docker's official GPG key
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
    
    # Add Docker repository
    echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    
    # Install Docker
    sudo apt update
    sudo apt install -y docker-ce docker-ce-cli containerd.io
    
    # Add current user to docker group
    sudo usermod -aG docker $USER
    newgrp docker
    Install Docker Compose
    sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    sudo chmod +x /usr/local/bin/docker-compose
    Verify Installation
    docker --version
    docker-compose --version

    ✅ Docker is now installed and ready for Dokploy deployment.

    4

    Install Dokploy

    Install Dokploy using the official installation script:

    Quick Installation (Recommended)

    Run Installation Script
    curl -sSL https://dokploy.com/install.sh | sh
    Verify Dokploy is Running
    docker ps | grep dokploy

    💡 Alternative: For manual installation, create a directory at /opt/dokploy and use the docker-compose.yml from the Dokploy repository.

    5

    Initial Configuration

    Access and configure Dokploy dashboard:

    Access Dashboard
    URL: http://your-server-ip:3000
    or
    URL: http://your-domain:3000

    Complete Initial Setup:

    1. Create admin account
    2. Configure server settings
    3. Set up database connections
    4. Configure email notifications (optional)

    🔒 Security Recommendation: Change the default port from 3000, enable HTTPS, and restrict access by IP if needed.

    6

    Prepare Your Application

    Create a Dockerfile for your application:

    For Static Website (Nginx)

    Dockerfile for Static Site
    FROM nginx:alpine
    
    # Copy website files
    COPY . /usr/share/nginx/html
    
    # Expose port 80
    EXPOSE 80
    
    # Start nginx
    CMD ["nginx", "-g", "daemon off;"]

    For Node.js Application

    Dockerfile for Node.js
    FROM node:18-alpine
    
    # Set working directory
    WORKDIR /app
    
    # Copy package files
    COPY package*.json ./
    
    # Install dependencies
    RUN npm ci --only=production
    
    # Copy application code
    COPY . .
    
    # Create non-root user
    RUN addgroup -g 1001 -S nodejs
    RUN adduser -S nodeuser -u 1001
    USER nodeuser
    
    # Expose port
    EXPOSE 3000
    
    # Start application
    CMD ["npm", "start"]

    For React Application

    Dockerfile for React
    # Build stage
    FROM node:18-alpine as build
    
    WORKDIR /app
    COPY package*.json ./
    RUN npm ci
    COPY . .
    RUN npm run build
    
    # Production stage
    FROM nginx:alpine
    COPY --from=build /app/build /usr/share/nginx/html
    COPY nginx.conf /etc/nginx/nginx.conf
    EXPOSE 80
    CMD ["nginx", "-g", "daemon off;"]

    Environment Configuration

    Create .env File
    # Database configuration
    DB_HOST=localhost
    DB_PORT=5432
    DB_NAME=app_db
    DB_USER=app_user
    DB_PASSWORD=secure_password
    
    # Application settings
    NODE_ENV=production
    PORT=3000
    API_URL=https://api.yourdomain.com
    
    # Security settings
    JWT_SECRET=your_jwt_secret_here
    SESSION_SECRET=your_session_secret_here
    Create .dockerignore
    node_modules
    npm-debug.log
    .env
    .git
    .gitignore
    README.md
    .DS_Store
    7

    Deploy Application

    Repository Setup

    Initialize Git Repository
    git init
    git add .
    git commit -m "Initial commit"
    git remote add origin https://github.com/yourusername/your-app.git
    git push -u origin main

    Create Application in Dokploy

    1. Access Dokploy dashboard and click Create Application

    2. Configure application settings:

    Application Configuration
    Name: your-application
    Description: Your application description
    Environment: production
    
    Git Integration:
    Repository URL: https://github.com/yourusername/your-app.git
    Branch: main
    Build context: /
    Dockerfile path: ./Dockerfile

    Configure Environment Variables

    Environment Variables in Dokploy
    NODE_ENV=production
    PORT=3000
    DB_HOST=dokploy-postgres
    DB_PORT=5432
    DB_NAME=app_production
    VIRTUAL_HOST=yourdomain.com,www.yourdomain.com
    LETSENCRYPT_HOST=yourdomain.com,www.yourdomain.com
    LETSENCRYPT_EMAIL=admin@yourdomain.com

    Deploy

    1. Click Deploy in Dokploy dashboard

    2. Monitor build logs for any errors

    3. Wait for successful deployment confirmation

    8

    Database Setup

    Create and configure PostgreSQL database:

    1. In Dokploy dashboard, navigate to Databases

    2. Click Create Database

    3. Select PostgreSQL

    4. Configure database settings:

    Database Configuration
    Name: app-db
    Username: app_user
    Password: [Generate secure password]
    Port: 5432

    5. Update environment variables with database connection details

    6. Ensure database URL is correctly formatted

    💡 Tip: Dokploy automatically handles database backups and provides easy restoration options in the dashboard.

    9

    Domain Configuration

    DNS Setup

    Configure DNS records for your domain:

    DNS Records
    A Record:
      Name: @ (root domain)
      Value: your-server-ip
      TTL: 300
    
    CNAME Record:
      Name: www
      Value: yourdomain.com
      TTL: 300
    
    Optional Subdomain:
      Name: api
      Value: yourdomain.com
      TTL: 300

    Configure Domain in Dokploy

    1. Access application settings in Dokploy dashboard

    2. Add your domain(s)

    3. Enable automatic HTTPS redirect

    Verify DNS Propagation
    # Check DNS propagation
    nslookup yourdomain.com
    dig yourdomain.com
    
    # Test domain accessibility
    curl -I http://yourdomain.com
    10

    SSL/TLS Setup

    Automatic SSL with Let's Encrypt

    Dokploy provides automatic SSL certificate management:

    1. Enable SSL in application settings:

    • Toggle "Enable SSL"
    • Select "Let's Encrypt"
    • Provide valid email address

    2. Configure SSL settings:

    • Enable HTTP to HTTPS redirect
    • Set HSTS headers
    • Configure SSL certificate renewal
    Verify SSL Installation
    # Test SSL certificate
    openssl s_client -connect yourdomain.com:443 -servername yourdomain.com
    
    # Check SSL rating
    curl -I https://yourdomain.com

    🔒 SSL certificates are automatically renewed by Dokploy before expiration.

    11

    Performance Optimization

    Enable Gzip Compression

    Nginx Configuration
    # nginx.conf
    gzip on;
    gzip_vary on;
    gzip_min_length 1024;
    gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss;

    Configure Caching Headers

    Nginx Caching
    location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
      expires 1y;
      add_header Cache-Control "public, immutable";
    }

    Resource Limits

    Configure Resource Limits
    # In Dokploy or docker-compose.yml
    deploy:
      resources:
        limits:
          cpus: '2.0'
          memory: 2G
        reservations:
          cpus: '0.5'
          memory: 512M

    Container Restart Policy

    Restart Policy
    restart: unless-stopped

    Health Checks

    Dockerfile Health Check
    HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
      CMD curl -f http://localhost:3000/health || exit 1
    12

    Monitoring and Backups

    Built-in Monitoring

    Dokploy provides built-in monitoring:

    • • Application metrics and response times
    • • Real-time log streaming
    • • Automated health monitoring
    • • Alert notifications
    • • Automatic restarts on failure

    Database Backups

    Automated PostgreSQL Backup
    # Automated PostgreSQL backup
    docker exec dokploy-postgres pg_dumpall -U postgres > backup-$(date +%Y%m%d).sql

    Application Data Backups

    Backup Application Volumes
    docker run --rm -v dokploy_app_data:/data -v $(pwd):/backup alpine tar czf /backup/app-backup-$(date +%Y%m%d).tar.gz /data

    Update Procedures

    Update Dokploy
    cd /opt/dokploy
    docker-compose pull
    docker-compose up -d

    Application Updates:

    1. Push code changes to repository
    2. Trigger redeployment in Dokploy
    3. Monitor deployment process
    4. Verify functionality

    Common Troubleshooting

    Container Not Starting

    Symptoms: Container exits immediately, error messages in logs

    Debug Container Issues
    # View container logs
    docker logs container_name
    
    # Check container status
    docker ps -a
    
    # Verify environment variables
    docker inspect container_name | grep Env

    SSL Certificate Issues

    Symptoms: SSL warnings, HTTPS not working

    • Verify domain DNS settings
    • Check Let's Encrypt rate limits
    • Ensure port 80 is accessible for HTTP validation
    • Review SSL configuration in Dokploy

    Database Connection Failures

    Symptoms: Database connection errors

    Debug Database Connection
    # Check database service status
    docker ps | grep postgres
    
    # Test database connection
    docker exec -it dokploy-postgres psql -U postgres
    
    # Review database logs
    docker logs dokploy-postgres

    Performance Issues

    Symptoms: Slow response times, high resource usage

    Monitor Performance
    # Check resource usage
    docker stats
    
    # Monitor container processes
    docker exec -it container_name top
    
    # Check system resources
    htop

    Security Best Practices

    Server Security

    System Updates
    sudo apt update && sudo apt upgrade -y
    • Disable root login via SSH
    • Use key-based authentication
    • Change default SSH port
    • Configure fail2ban for intrusion prevention

    Application Security

    • Use secure secrets management
    • Rotate credentials regularly
    • Avoid hardcoded secrets
    • Use non-root users in containers
    • Scan images for vulnerabilities
    • Keep base images updated

    Database Security

    • Use strong passwords
    • Implement role-based access
    • Restrict network access
    • Enable audit logging
    • Encrypt data at rest and in transit
    • Regular backups and test restoration

    Deployment Complete

    You now have a fully functional self-hosted deployment platform with Dokploy on RamNode VPS. This setup provides automated deployment pipelines, SSL certificate management, container orchestration, and professional-grade security.

    Key Benefits Achieved

    • Automated Deployment: Git-based deployment with automatic builds
    • SSL Management: Automatic Let's Encrypt certificates
    • Container Orchestration: Easy Docker container management
    • Built-in Monitoring: Real-time metrics and logs
    • Database Management: Integrated PostgreSQL with backups
    • Easy Scaling: Simple horizontal and vertical scaling

    Next Steps

    • 1. Implement comprehensive monitoring and alerting
    • 2. Set up automated backup schedules
    • 3. Configure CI/CD pipelines with webhooks
    • 4. Plan disaster recovery procedures
    • 5. Optimize performance based on usage patterns

    Related Guides

    Learn the basics of Dokploy deployment

    Master containerization fundamentals