Skip to main content

Deployment Overview

Building an application is only part of the journey. Once your application is ready, it must be deployed to a production environment where users can access it reliably, securely, and efficiently. This guide provides a high-level overview of deploying Bejibun applications and introduces the concepts you’ll encounter throughout the deployment process. More detailed deployment guides are available later in the documentation.

What Is Deployment?

Deployment is the process of moving your application from a development environment to a server where it can serve real users. During deployment, your application typically goes through several stages:
Development


Version Control


Build Process


Deployment


Production Server


Users
A successful deployment should be:
  • Repeatable
  • Reliable
  • Secure
  • Observable
  • Easy to maintain

Deployment Goals

Every production deployment should aim to achieve the following objectives.

Reliability

Applications should remain available and stable. Goals include:
  • Minimal downtime
  • Automatic recovery
  • Consistent performance
  • Stable infrastructure

Security

Production systems must protect sensitive data. Common security measures include:
  • HTTPS
  • Secure credentials
  • Environment variables
  • Firewall configuration
  • Access controls

Performance

Applications should respond quickly under load. Common optimization strategies include:
  • Caching
  • Database optimization
  • Compression
  • Reverse proxies
  • CDN integration

Observability

You cannot fix problems you cannot see. Production environments should provide:
  • Logging
  • Error reporting
  • Monitoring
  • Health checks
  • Metrics collection

Production Environment Architecture

A typical Bejibun deployment may look like:
                Internet


             Load Balancer


              Reverse Proxy
                 (Nginx)


              Bejibun App

       ┌─────────────┼─────────────┐
       ▼             ▼             ▼
   Database       Redis        Storage
Not every application requires this level of infrastructure, but understanding the architecture helps as applications grow.

Runtime Requirements

Bejibun is built specifically for Bun. Production servers should have:
ComponentRecommended
BunLatest Stable
LinuxUbuntu LTS or equivalent
DatabasePostgreSQL, MySQL, SQLite
CacheRedis
Reverse ProxyNginx or Caddy
Always keep dependencies updated to receive security patches and performance improvements.

Preparing for Production

Before deploying, review your application configuration.

Disable Debug Mode

Development:
APP_DEBUG=true
Production:
APP_DEBUG=false
Debug information should never be exposed publicly.

Set Production Environment

APP_ENV=production
Many framework features behave differently depending on the current environment.

Configure Application URL

APP_URL=https://api.example.com
This allows the framework to generate correct URLs and links.

Environment Variables

Production environments should never store secrets in source code. Instead:
DB_PASSWORD=

JWT_SECRET=

API_KEY=
should be provided through secure environment management systems. Examples include:
  • Server environment variables
  • Container secrets
  • Cloud secret managers
  • CI/CD pipelines

Database Preparation

Before serving traffic, ensure your database is ready. Run migrations:
bun ace migrate:latest
If necessary, seed initial data:
bun ace db:seed
Always verify migrations in a staging environment before applying them to production systems.

Starting the Application

A production application is typically started using:
bun start
Example:
APP_ENV=production bun start
Your deployment platform may manage this process automatically.

Process Management

Production applications should not rely on terminal sessions remaining open. Instead, use a process manager. Examples:
PM2
Systemd
Docker
Kubernetes
Benefits include:
  • Automatic restarts
  • Crash recovery
  • Process monitoring
  • Log management
Example workflow:
Application Crash


Process Manager


Automatic Restart

Reverse Proxies

Most production deployments place a reverse proxy in front of the application. Example:
User


Nginx


Bejibun
Benefits:
  • HTTPS termination
  • Compression
  • Static file serving
  • Load balancing
  • Security controls
Popular options:
  • Nginx
  • Caddy
  • Traefik

HTTPS

All production applications should use HTTPS. Benefits include:
  • Encrypted traffic
  • Improved security
  • Browser trust
  • Better SEO
Example:
https://example.com
instead of:
http://example.com
Certificates can be obtained through providers such as:
  • Let’s Encrypt
  • Cloudflare
  • Managed hosting providers

Logging

Logs are essential for diagnosing issues. Common production logs include:
Application Logs

Access Logs

Error Logs

Audit Logs
Example:
storage/logs/
Logs should be monitored regularly and retained according to organizational requirements.

Monitoring

Monitoring helps detect issues before users report them. Common metrics include:
  • CPU usage
  • Memory usage
  • Request latency
  • Error rates
  • Database performance
Example monitoring stack:
Application


Metrics Collector


Dashboard
Monitoring should be considered a production requirement rather than an optional feature.

Health Checks

Health checks allow infrastructure to determine whether an application is functioning correctly. Example route:
Router.get("/health", () => {
  return {
    status: "ok"
  };
});
Response:
{
  "status": "ok"
}
Load balancers and orchestration platforms often rely on health endpoints.

Caching

Caching can significantly improve production performance. Examples:
Database Query Cache

Application Cache

Response Cache

Redis Cache
Benefits:
  • Faster responses
  • Reduced database load
  • Improved scalability
Caching strategies should be evaluated based on application requirements.

Queue Workers

Applications using background jobs must run queue workers separately from the web server. Example:
Web Server


HTTP Requests

Queue Worker


Background Jobs
Typical tasks include:
  • Email delivery
  • Notifications
  • Image processing
  • Data synchronization

File Storage

Production file storage often differs from local development. Development:
Local Disk
Production:
Amazon S3

Cloud Storage

Object Storage
Separating storage from application servers improves scalability and reliability.

Deployment Strategies

There are multiple ways to deploy a Bejibun application.

Traditional Servers

Ubuntu
 ├── Nginx
 ├── Bun
 └── Database
Best for:
  • VPS hosting
  • Dedicated servers
  • Simple deployments

Docker

Docker Container
 ├── Bejibun
 └── Bun Runtime
Benefits:
  • Consistent environments
  • Simplified deployments
  • Easy scaling

Kubernetes

Cluster
 ├── Pods
 ├── Services
 └── Ingress
Best for:
  • Large-scale systems
  • High availability
  • Enterprise workloads

Platform-as-a-Service

Examples:
Railway
Fly.io
Render
DigitalOcean App Platform
Benefits:
  • Simplified infrastructure
  • Automated deployments
  • Managed environments

CI/CD Pipelines

Modern deployments are often automated. Typical workflow:
Git Push


Tests


Build


Deploy
Benefits:
  • Faster releases
  • Reduced human error
  • Consistent deployments
Common platforms include:
  • GitHub Actions
  • GitLab CI
  • Jenkins
  • CircleCI

Production Checklist

Before going live, verify the following:

Application

  • Debug mode disabled
  • Environment set to production
  • Health checks configured
  • Logging enabled

Security

  • HTTPS enabled
  • Secrets stored securely
  • Access controls configured
  • Dependencies updated

Database

  • Migrations executed
  • Backups configured
  • Monitoring enabled

Infrastructure

  • Process manager configured
  • Reverse proxy configured
  • Monitoring configured
  • Alerts configured

Common Mistakes

Avoid the following:

Running in Debug Mode

APP_DEBUG=true
in production.

Committing Secrets

Never commit:
DB_PASSWORD=
JWT_SECRET=
API_KEY=
to version control.

Skipping Backups

Every production database should have an automated backup strategy.

Deploying Without Monitoring

Production systems should always have visibility into application health and performance.

What’s Next?

This guide introduced the core concepts of deploying a Bejibun application. Detailed deployment instructions are covered later in the documentation, including:
  • Bun Runtime Deployment
  • Docker Deployment
  • Nginx Configuration
  • Reverse Proxy Setup
  • Production Optimization
  • Monitoring & Logging
With deployment fundamentals covered, you’re ready to continue exploring the framework’s core concepts and internal architecture.