Skip to main content
العودة للمدونة
TutorialsCloud & DevOps

Deploying Applications with Coolify on VPS

Fametoll Team
December 28, 2023
12 min read
2,103 views

Why We Moved Our Clients Off Vercel (And How We Deploy with Coolify Instead)

Last year, one of our clients received a $2,400 Vercel bill for a marketing site with moderate traffic. Not a complex application — a Next.js site with a blog, a contact form, and about 150,000 monthly visitors. The bill was mostly serverless function invocations and bandwidth overages.

We migrated them to a $20/month Hetzner VPS running Coolify. Same performance. Same zero-downtime deployments. Same automatic SSL. Monthly cost went from $2,400 to $20. That is not a typo.

Coolify is not the right choice for everyone. But for the majority of web applications we build, it delivers 95% of the managed platform experience at 5% of the cost. Here is exactly how we set it up and the pitfalls we learned to avoid.

The Honest Comparison

Let us be clear about what you are trading:

What you gain: Full infrastructure control, predictable costs, no vendor lock-in, unlimited projects on one server, no cold starts on serverless functions.

What you lose: Edge network distribution (Coolify serves from one region), automatic scaling beyond your VPS capacity, and the "someone else handles it" peace of mind.

For 90% of the applications we build — B2B SaaS dashboards, marketing sites, internal tools, API backends — edge distribution is unnecessary and automatic scaling is overengineered. A properly configured $40/month VPS handles 500+ concurrent users without breaking a sweat.

Setting Up Coolify the Right Way

The installation is one command, but production readiness takes more thought:

BASH
# Install Coolify on a fresh Ubuntu 22.04 VPS
curl -fsSL https://get.coolify.io | bash

After installation, here is what we configure before deploying a single application:

1. SSH key-based access only

BASH
# Disable password authentication
sudo sed -i 's/PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
sudo systemctl restart sshd

2. Automatic security updates

BASH
sudo apt install unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades

3. Firewall configuration

BASH
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable

4. Swap space (critical for VPS with limited RAM)

BASH
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

That swap configuration is something most guides skip. Without it, a Next.js build on a 4GB VPS will kill the OOM killer during the webpack compilation phase. We learned this the hard way during a production deployment.

The Deployment Architecture We Use for Every Project

Every client project follows the same Coolify deployment pattern:

YAML
# docker-compose.yml - production deployment
services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    restart: always
    environment:
      - DATABASE_URL=postgresql://${DB_USER}:${DB_PASS}@postgres:5432/${DB_NAME}
      - REDIS_URL=redis://redis:6379
      - NODE_ENV=production
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3000/api/health"]
      interval: 30s
      timeout: 10s
      retries: 3

  postgres:
    image: postgres:15-alpine
    restart: always
    volumes:
      - postgres_data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=${DB_NAME}
      - POSTGRES_USER=${DB_USER}
      - POSTGRES_PASSWORD=${DB_PASS}
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${DB_USER}"]
      interval: 10s
      timeout: 5s
      retries: 5

  redis:
    image: redis:7-alpine
    restart: always
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5

volumes:
  postgres_data:

Key details that make this production-grade:

  • Health checks on every service. Coolify uses these to determine when a new deployment is ready before switching traffic. Without them, you get brief downtime during deployments.
  • depends_on with conditions. The app does not start until PostgreSQL and Redis are actually ready, not just "container is running."
  • Named volumes for persistence. Database data survives container rebuilds.

Backup Strategy That Actually Works

The biggest risk of self-hosting is data loss. We automate backups with a simple cron job:

BASH
#!/bin/bash
# /opt/scripts/backup.sh - runs daily via cron

TIMESTAMP=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR="/opt/backups"

# Dump PostgreSQL
docker exec postgres pg_dump -U $DB_USER $DB_NAME | gzip > "$BACKUP_DIR/db_$TIMESTAMP.sql.gz"

# Upload to S3-compatible storage (Backblaze B2 = $0.005/GB)
aws s3 cp "$BACKUP_DIR/db_$TIMESTAMP.sql.gz" "s3://backups-bucket/db_$TIMESTAMP.sql.gz" --endpoint-url https://s3.us-west-002.backblazeb2.com

# Keep only last 7 local backups
ls -t $BACKUP_DIR/db_*.sql.gz | tail -n +8 | xargs rm -f

echo "Backup completed: db_$TIMESTAMP.sql.gz"

Total cost for daily backups of a 2GB database with 30-day retention: about $0.15/month on Backblaze B2.

When NOT to Use Coolify

We still recommend managed platforms in specific situations:

  • Global audience with latency requirements. If your users are on five continents and you need sub-100ms response times everywhere, you need an edge network. Coolify serves from one location.
  • Extreme traffic spikes. If you regularly go from 100 to 100,000 concurrent users (flash sales, viral content), auto-scaling matters. A VPS has a fixed ceiling.
  • Regulated industries requiring SOC 2 compliance. Self-hosting means you own the compliance burden. Managed platforms handle much of this for you.

For everything else — and that covers the vast majority of web applications in existence — a $20-40/month VPS with Coolify delivers the same developer experience as platforms charging 10-100x more.

The Real Cost Breakdown

Here is what our typical client infrastructure costs on Coolify:

ComponentMonthly Cost
Hetzner VPS (4 vCPU, 8GB RAM)$18
Backblaze B2 backups$0.15
Domain name (amortized)$1
Uptime monitoring (BetterStack)$0 (free tier)
Total$19.15

Compare that to Vercel Pro ($20/user/month + overages), Railway ($5/service + usage), or Heroku ($25-250/dyno). The math is not even close.

We have been running client applications on Coolify for over two years. Across all projects, our aggregate uptime is 99.94%. The 0.06% downtime was caused by a Hetzner datacenter network issue, not Coolify. For a $20/month setup, that is remarkable.

F

Fametoll Team

بناء حلول رقمية تدفع نمو الأعمال. تابع مدونتنا لرؤى حول تطوير الويب واتجاهات التكنولوجيا وأفضل الممارسات.

شارك المقال

مستعد لإنشاء شيء مذهل؟

دعنا نناقش كيف يمكننا مساعدتك في إحياء مشروعك.

ابدأ مشروعًا