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)
Server Preparation
Update the system and install essential packages:
sudo apt update && sudo apt upgrade -ysudo apt install -y curl wget git unzip software-properties-commonConfigure 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 statusInstall Docker
Install Docker and Docker Compose:
# 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 dockersudo 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-composedocker --version
docker-compose --version✅ Docker is now installed and ready for Dokploy deployment.
Install Dokploy
Install Dokploy using the official installation script:
Quick Installation (Recommended)
curl -sSL https://dokploy.com/install.sh | shdocker ps | grep dokploy💡 Alternative: For manual installation, create a directory at /opt/dokploy and use the docker-compose.yml from the Dokploy repository.
Initial Configuration
Access and configure Dokploy dashboard:
URL: http://your-server-ip:3000
or
URL: http://your-domain:3000Complete Initial Setup:
- Create admin account
- Configure server settings
- Set up database connections
- Configure email notifications (optional)
🔒 Security Recommendation: Change the default port from 3000, enable HTTPS, and restrict access by IP if needed.
Prepare Your Application
Create a Dockerfile for your application:
For Static Website (Nginx)
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
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
# 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
# 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_herenode_modules
npm-debug.log
.env
.git
.gitignore
README.md
.DS_StoreDeploy Application
Repository Setup
git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/yourusername/your-app.git
git push -u origin mainCreate Application in Dokploy
1. Access Dokploy dashboard and click Create Application
2. Configure application settings:
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: ./DockerfileConfigure Environment Variables
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.comDeploy
1. Click Deploy in Dokploy dashboard
2. Monitor build logs for any errors
3. Wait for successful deployment confirmation
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:
Name: app-db
Username: app_user
Password: [Generate secure password]
Port: 54325. 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.
Domain Configuration
DNS Setup
Configure DNS records for your domain:
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: 300Configure Domain in Dokploy
1. Access application settings in Dokploy dashboard
2. Add your domain(s)
3. Enable automatic HTTPS redirect
# Check DNS propagation
nslookup yourdomain.com
dig yourdomain.com
# Test domain accessibility
curl -I http://yourdomain.comSSL/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
# 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.
Performance Optimization
Enable Gzip Compression
# 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
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}Resource Limits
# In Dokploy or docker-compose.yml
deploy:
resources:
limits:
cpus: '2.0'
memory: 2G
reservations:
cpus: '0.5'
memory: 512MContainer Restart Policy
restart: unless-stoppedHealth Checks
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1Monitoring 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
docker exec dokploy-postgres pg_dumpall -U postgres > backup-$(date +%Y%m%d).sqlApplication Data Backups
docker run --rm -v dokploy_app_data:/data -v $(pwd):/backup alpine tar czf /backup/app-backup-$(date +%Y%m%d).tar.gz /dataUpdate Procedures
cd /opt/dokploy
docker-compose pull
docker-compose up -dApplication Updates:
- Push code changes to repository
- Trigger redeployment in Dokploy
- Monitor deployment process
- Verify functionality
Common Troubleshooting
Container Not Starting
Symptoms: Container exits immediately, error messages in logs
# View container logs
docker logs container_name
# Check container status
docker ps -a
# Verify environment variables
docker inspect container_name | grep EnvSSL 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
# 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-postgresPerformance Issues
Symptoms: Slow response times, high resource usage
# Check resource usage
docker stats
# Monitor container processes
docker exec -it container_name top
# Check system resources
htopSecurity Best Practices
Server Security
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
