Managed Platforms (Dokploy, Coolify)
Self-hosted platforms give you full control over your infrastructure while providing a deployment experience similar to Vercel or Netlify. CruzJS works with any platform that can build and run Docker containers.
Dokploy
Section titled “Dokploy”Dokploy is an open-source, self-hosted PaaS. Install it on any VPS and deploy CruzJS with automatic builds, SSL, and monitoring.
- Provision a VPS (DigitalOcean Droplet, Hetzner, etc.) with at least 2 GB RAM.
- Install Dokploy on the VPS:
Terminal window curl -sSL https://dokploy.com/install.sh | sh - Open the Dokploy dashboard at
https://your-vps-ip:3000and create your admin account.
Create the Application
Section titled “Create the Application”- In the Dokploy dashboard, click Create Project, then Add Application.
- Connect your Git repository (GitHub, GitLab, or Bitbucket).
- Set the build method to Dockerfile — Dokploy detects and builds your multi-stage
Dockerfile. - Under Environment Variables, add your configuration:
DATABASE_URL=postgres://cruz:password@postgres:5432/cruzdbREDIS_URL=redis://redis:6379AUTH_SECRET=your-secret-keyS3_ENDPOINT=http://minio:9000S3_BUCKET=uploadsS3_ACCESS_KEY=minioadminS3_SECRET_KEY=minioadmin
- Under Domains, add your domain. Dokploy provisions SSL via Let’s Encrypt automatically.
- Click Deploy.
Attach Databases
Section titled “Attach Databases”Dokploy can manage PostgreSQL and Redis as services alongside your app:
- In the same project, click Add Database and choose PostgreSQL.
- Dokploy creates a managed PostgreSQL container with persistent volumes.
- Copy the internal connection string and use it as
DATABASE_URL. - Repeat for Redis if you need cache and queue support.
Dokploy handles backups, restarts, and volume management for these database services.
Migrations
Section titled “Migrations”Run migrations after each deploy via the Dokploy terminal or a post-deploy hook:
# In the Dokploy terminal for your applicationnpx cruz db migrateOr add a post-deploy command in the application settings to run migrations automatically.
Coolify
Section titled “Coolify”Coolify is another open-source PaaS with a polished UI and built-in database management.
- Install Coolify on your server:
Terminal window curl -fsSL https://cdn.coollabs.io/coolify/install.sh | bash - Open the dashboard and complete initial setup.
Deploy with Docker Compose
Section titled “Deploy with Docker Compose”Coolify works well with docker-compose.yml. Use the compose file from the Docker adapter docs as your starting point.
- In Coolify, click Add New Resource and select Docker Compose.
- Connect your GitHub repository.
- Coolify detects
docker-compose.ymland deploys all services (app, PostgreSQL, Redis, MinIO). - Configure environment variables in the Coolify dashboard — these override values in the compose file.
- Set your domain under Settings > Domain. Coolify handles SSL automatically.
Use Coolify’s Built-in Databases
Section titled “Use Coolify’s Built-in Databases”Instead of defining databases in your compose file, you can use Coolify’s managed databases:
- Click Add New Resource > Database > PostgreSQL.
- Coolify provisions a PostgreSQL instance with automatic backups.
- Copy the internal URL and set it as
DATABASE_URLin your app’s environment. - Do the same for Redis if needed.
This separates database lifecycle from application deployments, which is safer for production.
Migrations in Coolify
Section titled “Migrations in Coolify”Add a pre-deploy command in your application settings:
npx cruz db migrateCoolify runs this command inside the container before routing traffic to the new version.
General VPS Deployment
Section titled “General VPS Deployment”For a minimal setup without a platform, deploy directly with Docker Compose and a reverse proxy.
Deploy Script
Section titled “Deploy Script”Create a deploy script on your server:
#!/bin/bashset -e
cd /opt/cruz-appgit pull origin maindocker compose up -d --build
# Run migrations after the new containers are healthydocker compose exec app npx cruz db migrate
echo "Deployment complete."SSH Deploy from CI
Section titled “SSH Deploy from CI”Trigger the script from your local machine or CI:
ssh deploy@my-server "cd /opt/cruz-app && bash deploy.sh"Add a deploy key to your server so it can pull from your private repository:
# On the serverssh-keygen -t ed25519 -f ~/.ssh/deploy_key -N ""# Add the public key as a deploy key in your GitHub repo settingsNginx Reverse Proxy
Section titled “Nginx Reverse Proxy”Put Nginx in front of your CruzJS app for SSL termination:
server { listen 80; server_name app.example.com; return 301 https://$server_name$request_uri;}
server { listen 443 ssl http2; server_name app.example.com;
ssl_certificate /etc/letsencrypt/live/app.example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/app.example.com/privkey.pem;
location / { proxy_pass http://127.0.0.1:3000; 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; }}Obtain certificates with Certbot:
sudo apt install certbot python3-certbot-nginxsudo certbot --nginx -d app.example.comCertbot auto-renews certificates via a systemd timer.
Watchtower (Auto-Update)
Section titled “Watchtower (Auto-Update)”Watchtower monitors your running containers and automatically pulls and restarts them when a new image is pushed to the registry.
# Add to docker-compose.ymlservices: watchtower: image: containrrr/watchtower volumes: - /var/run/docker.sock:/var/run/docker.sock environment: WATCHTOWER_POLL_INTERVAL: 300 # Check every 5 minutes WATCHTOWER_CLEANUP: "true" # Remove old images restart: unless-stoppedThis is useful for simpler deployments where you push a new image to a registry and want the server to pick it up automatically. For production, pair Watchtower with a CI pipeline that builds and pushes images on every merge to main.