Skip to content

Abhishek-B-R/Deployr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

90 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Deployr: Self-Hosted Vercel Clone

Deployr Banner

Deployr is a full-stack, self-hosted Vercel-like platform that allows you to connect a GitHub repository, specify your build settings, and deploy static/Next.js sites dynamically under a custom subdomain (e.g., yourproject.deployr.live).


๐Ÿš€ Features

  • ๐Ÿง  GitHub Integration โ€” Connect repos, auto-fetch branches, and trigger builds.
  • ๐Ÿ—๏ธ Docker-based CI/CD โ€” Fully containerized build process using Docker.
  • ๐ŸŒ Dynamic Subdomain Routing โ€” Automatic reverse proxying with Nginx to *.deployr.live.
  • โš™๏ธ Environment Variables Support โ€” Easily inject env variables during builds.
  • ๐Ÿ“ฆ R2 Object Storage โ€” Uses Cloudflare R2 for uploading final build output.
  • ๐Ÿ“Š Status Dashboard โ€” Tracks builds with logs, size, and real-time updates.
  • ๐Ÿ” Auth via NextAuth.js โ€” GitHub OAuth + session-protected APIs.
  • ๐Ÿงต Redis Queue โ€” Pushes builds into Redis queue for serialized processing.
  • ๐Ÿ—‚๏ธ PostgreSQL (via Prisma) โ€” Used for storing all metadata.
  • ๐Ÿ“ก WebSocket Updates (wss.deployr.abhishekbr.dev) โ€” Real-time updates over WS.

๐Ÿ“ Folder Structure

apps/
โ”œโ”€โ”€ core/                       # Frontend (Next.js + Tailwind + Shadcn UI)
โ”œโ”€โ”€ docker-cloner/              # Backend API server (Express.js)
โ”œโ”€โ”€ docker-pull-and-builder/    # Consumes Redis queue & builds projects
โ”‚   โ””โ”€โ”€ ws-server/              # WebSocket server for real-time build updates
โ””โ”€โ”€ static-server/              # Serves built frontend projects from R2
    โ””โ”€โ”€ nginx/                  # Config for routing *.deployr.live, api, and ws


๐Ÿงฑ System Architecture

       GitHub
          |
   [Next.js Frontend]
          | Login, Choose Repo
          v
   [Express API Server] <--------- GitHub OAuth
          |
          | Project Creation -> PostgreSQL (Prisma)
          |
          +----> Redis Queue (build-queue)
                        |
                        v
              [docker-builder Worker] ---------> Docker Build
                        |                            |
                                              Inject ENV Vars
                        |                            |
               Uploads final build     <---     R2 Bucket
                        |
                        v
                WebSocket notify clients

๐Ÿ”จ Core Functionalities & Code Highlights

1. GitHub Auth & Repo Selection

  • GitHub OAuth with next-auth
  • Fetch user's repos using their token
  • User selects repo, branch, and configures build settings

2. Project Creation API

  • Stores metadata in PostgreSQL
  • Supports unique repo deployments only, so prevents duplicate project creation
  • Only allows one deployment per GitHub repository
  • Assigns unique slugs using generateSlug()
  • Assigns unique slugs using generateSlug()

3. Queue & Build Worker

  • Pushes project ID to Redis (build-queue)
  • Worker consumes it using brPop
  • Fetches from S3, runs Docker build, injects ENV vars
  • On success: uploads to R2, updates DB & notifies via WebSocket
  • On failure: updates status + pushes failed ID to FailedJobs table
// Redis enqueue logic
await publisher.lPush("build-queue", id);

// If Redis fails, fallback:
await pgClient.query(`INSERT INTO "FailedJobs" (id) VALUES ($1)`, [id]);

4. R2 + Static Hosting

  • Uses @aws-sdk/client-s3 with custom signer for Cloudflare R2
  • Uploads files to output/<project-id>/
  • Nginx static server reads from disk (optionally syncs from R2)

5. Nginx Reverse Proxy

  • SSL termination via Certbot (wildcard + root)
  • Routes:
    • api.deployr.abhishekbr.dev -> API Server (8080)
    • ws.deployr.abhishekbr.dev -> WebSocket Server (8082)
    • *.deployr.live -> Static file server (8081)
server {
  listen 443 ssl;
  server_name api.deployr.abhishekbr.dev;
  proxy_pass http://localhost:8080;
}

server {
  listen 443 ssl;
  server_name ~^(.+)\.deployr\.live$;
  proxy_pass http://localhost:8081;
}

๐Ÿง  Challenges Faced

  • โš ๏ธ DNS Propagation delays: *.deployr.live took hours to propagate globally.
  • โŒ Certbot errors due to SERVFAIL on _acme-challenge DNS records.
  • ๐Ÿ’ฃ Redis crash in production โ€” fallback queue logging in PostgreSQL added.
  • ๐Ÿž AWS SDK error due to accidental misuse of GitHub URL as S3 endpoint.
  • โฑ๏ธ Docker builds occasionally timed out or failed due to memory constraints.
  • ๐ŸŒ Realtime logs rendering took hours to configure and to debug all the occured bugs.
  • ๐ŸŽฎ 3D Visualization โ€” Rendered 3D models using Three.js and React Three Fiber

๐Ÿ“ธ Screenshots

  • Dashboard with list of projects alt text

  • Create project modal with GitHub repo selector alt text

  • Smart framework detection along with customization like editing framework,build command,install command and output directory. alt text

  • Logs viewer with real-time status (via WS) alt text

  • R2 uploads in Cloudflare dashboard alt text

  • Final deployed website - deployr.live alt text


๐Ÿงช Local Setup

git clone https://github.com/Abhishek-B-R/deployr.git
cd deployr
cp .env.example .env   (in each folders)
# Fill in GitHub, Redis, Postgres, R2 credentials

# Start everything
pnpm i
make devBuild

Make sure:

  • You own a wildcard domain (like *.deployr.live) and it points to your server IP
  • Certbot is configured for *.deployr.live + root domain

๐Ÿ“š Tech Stack

Layer Tech
Frontend Next.js, Tailwind CSS, Shadcn/UI
Auth NextAuth.js + GitHub OAuth
Backend API Express.js
DB PostgreSQL + Prisma
Queue Redis
Realtime WebSocket + Node.js
Secure Builds Docker, Docker CLI, Bash
Static Hosting Cloudflare R2 + Nginx

๐Ÿ What's Next?

  • Add GitHub Webhooks to trigger auto-rebuilds on push (Integrate CI-CD pipelines)
  • Enable domain-level custom domain support (like userdomain.com)
  • Rate limiting + per-user quotas

๐Ÿ’ฌ Final Words

This project was built with tons of trial, error, debugging, DNS frustration, and joy. Inspired by Vercel's deployment flow, it's my way of understanding how production systems work end-to-end. Feel free to explore, fork, or contribute.

Made with โค๏ธ by Abhishek B.R. If you liked this, please consider starring โญ the repo.


๐ŸŒŸ Motivation

โœจ "If you can build Vercel in public, you can build anything."

About

A full-stack vercel like platform, that can be used to deploy any frontend applications easily. It is easily self-hostable on your own infrastructure using Docker, giving you complete control over your deployments with dynamic subdomain routing and real-time build logs.

Topics

Resources

Stars

14 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages