2025-10-28 13:05:42 +00:00
# @serve.zone/onebox
2025-11-26 13:51:48 +00:00
> 🚀 Self-hosted Docker Swarm platform with Caddy reverse proxy, automatic SSL, and real-time WebSocket updates
2025-10-28 13:05:42 +00:00
2025-11-26 13:51:48 +00:00
**Onebox** transforms any Linux server into a powerful container hosting platform. Deploy Docker Swarm services with automatic HTTPS, DNS configuration, and Caddy reverse proxy running as a Docker service - all managed through a beautiful Angular web interface with real-time updates.
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
## Issue Reporting and Security
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/ ](https://community.foss.global/ ). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/ ](https://code.foss.global/ ) account to submit Pull Requests directly.
## What Makes Onebox Different? 🎯
2025-11-26 13:51:48 +00:00
- **Caddy Reverse Proxy in Docker** - Production-grade HTTP/HTTPS proxy running as a Swarm service with native service discovery, HTTP/2, HTTP/3, and bidirectional WebSocket proxying
- **Docker Swarm First** - All workloads (including the reverse proxy!) run as Swarm services on the overlay network for seamless service-to-service communication
2025-11-24 19:52:35 +00:00
- **Real-time Everything** - WebSocket-powered live updates for service status, logs, and metrics across all connected clients
- **Single Executable** - Compiles to a standalone binary - just run it, no dependencies
2025-11-25 04:20:19 +00:00
- **Private Registry Included** - Built-in Docker registry with token-based auth and auto-deploy on push
2025-11-26 13:51:48 +00:00
- **Zero Config SSL** - Automatic Let's Encrypt certificates with inline `load_pem` (no volume mounts needed)
2025-11-25 04:20:19 +00:00
- **Cloudflare Integration** - Automatic DNS record management and zone synchronization
- **Modern Stack** - Deno runtime + SQLite database + Angular 19 UI
2025-11-24 19:52:35 +00:00
## Features ✨
### Core Platform
- 🐳 **Docker Swarm Management ** - Deploy, scale, and orchestrate services with Swarm mode
2025-11-26 13:51:48 +00:00
- 🌐 **Caddy Reverse Proxy ** - Production-grade proxy running as Docker service with SNI, HTTP/2, HTTP/3
2025-11-24 19:52:35 +00:00
- 🔒 **Automatic SSL Certificates ** - Let's Encrypt integration with hot-reload and renewal monitoring
2025-11-25 04:20:19 +00:00
- ☁️ **Cloudflare DNS Integration ** - Automatic DNS record creation and zone synchronization
2025-11-24 19:52:35 +00:00
- 📦 **Built-in Registry ** - Private Docker registry with per-service tokens and auto-update
- 🔄 **Real-time WebSocket Updates ** - Live service status, logs, and system events
### Monitoring & Management
- 📊 **Metrics Collection ** - Historical CPU, memory, and network stats (every 60s)
2025-11-25 04:20:19 +00:00
- 📝 **Centralized Logging ** - Container logs with streaming and retention policies
2025-11-24 19:52:35 +00:00
- 🎨 **Angular Web UI ** - Modern, responsive interface with real-time updates
- 👥 **Multi-user Support ** - Role-based access control (admin/user)
2025-10-28 13:05:42 +00:00
- 💾 **SQLite Database ** - Embedded, zero-configuration storage
2025-11-24 19:52:35 +00:00
### Developer Experience
- 🚀 **Auto-update on Push ** - Push to registry and services update automatically
- 🔐 **Private Registry Support ** - Use Docker Hub, Gitea, or custom registries
2025-10-28 13:05:42 +00:00
- 🔄 **Systemd Integration ** - Run as a daemon with auto-restart
2025-11-24 19:52:35 +00:00
- 🎛️ **Full CLI & API ** - Manage everything from terminal or HTTP API
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
## Quick Start 🏁
2025-10-28 13:05:42 +00:00
### Installation
```bash
2025-11-24 19:52:35 +00:00
# Download the latest release for your platform
curl -sSL https://code.foss.global/serve.zone/onebox/releases/latest/download/onebox-linux-x64 -o onebox
chmod +x onebox
sudo mv onebox /usr/local/bin/
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
# Or install from npm
2025-10-28 13:05:42 +00:00
pnpm install -g @serve .zone/onebox
```
2025-11-24 19:52:35 +00:00
### First Run
2025-10-28 13:05:42 +00:00
```bash
2025-11-24 19:52:35 +00:00
# Start the server in development mode
onebox server --ephemeral
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
# In another terminal, deploy your first service
2025-10-28 13:05:42 +00:00
onebox service add myapp \
--image nginx:latest \
--domain app.example.com \
2025-11-24 19:52:35 +00:00
--port 80
```
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
### Access the Web UI
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
Open `http://localhost:3000` in your browser.
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
**Default credentials:**
- Username: `admin`
- Password: `admin`
⚠️ **Change the default password immediately after first login! **
### Production Setup
2025-10-28 13:05:42 +00:00
```bash
2025-11-24 19:52:35 +00:00
# Install as systemd service
2025-10-28 13:05:42 +00:00
sudo onebox daemon install
# Start the daemon
sudo onebox daemon start
# View logs
sudo onebox daemon logs
```
2025-11-24 19:52:35 +00:00
## Architecture 🏗️
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
Onebox is built with modern technologies for performance and developer experience:
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
```
┌─────────────────────────────────────────────────┐
2025-11-25 04:20:19 +00:00
│ Angular 19 Web UI │
2025-11-24 19:52:35 +00:00
│ (Real-time WebSocket Updates) │
└─────────────────┬───────────────────────────────┘
│ HTTP/WS
┌─────────────────▼───────────────────────────────┐
│ Deno HTTP Server (Port 3000) │
│ REST API + WebSocket Broadcast │
└─────────────────┬───────────────────────────────┘
│
┌─────────────────▼───────────────────────────────┐
2025-11-26 13:51:48 +00:00
│ Docker Swarm │
│ ┌──────────────────────────────┐ │
│ │ onebox-network (overlay) │ │
│ ├──────────────────────────────┤ │
│ │ onebox-caddy (Caddy proxy) │ │
│ │ HTTP (80) + HTTPS (443) │ │
│ │ Admin API → config updates │ │
│ ├──────────────────────────────┤ │
│ │ Your Services │ │
│ │ (reachable by service name) │ │
│ └──────────────────────────────┘ │
2025-11-24 19:52:35 +00:00
└─────┬───────────────────────────────────────────┘
│
├──► SSL Certificate Manager (Let's Encrypt)
├──► Cloudflare DNS Manager
├──► Built-in Docker Registry
└──► SQLite Database
```
### Core Components
2025-10-28 13:05:42 +00:00
2025-11-25 04:20:19 +00:00
| Component | Description |
|-----------|-------------|
| **Deno Runtime ** | Modern TypeScript with built-in security |
2025-11-26 13:51:48 +00:00
| **Caddy Reverse Proxy ** | Docker Swarm service with HTTP/2, HTTP/3, SNI, and WebSocket support |
| **Docker Swarm ** | Container orchestration (all workloads run as services) |
2025-11-25 04:20:19 +00:00
| **SQLite Database ** | Configuration, metrics, and user data |
| **WebSocket Server ** | Real-time bidirectional communication |
| **Let's Encrypt ** | Automatic SSL certificate management |
| **Cloudflare API ** | DNS record automation |
2025-11-24 19:52:35 +00:00
## CLI Reference 📖
2025-10-28 13:05:42 +00:00
### Service Management
```bash
2025-11-24 19:52:35 +00:00
# Deploy a service
onebox service add <name> --image <image> --domain <domain> [--port <port>] [--env KEY=VALUE]
# Deploy with Onebox Registry (auto-update on push)
onebox service add myapp --use-onebox-registry --domain myapp.example.com
# List services
onebox service list
# Control services
2025-10-28 13:05:42 +00:00
onebox service start <name>
onebox service stop <name>
onebox service restart <name>
2025-11-24 19:52:35 +00:00
# Remove service
onebox service remove <name>
# View logs
onebox service logs <name>
```
### Server Management
```bash
# Start server (development)
onebox server --ephemeral # Runs in foreground with monitoring
# Start server (production)
onebox daemon install # Install systemd service
onebox daemon start # Start daemon
onebox daemon stop # Stop daemon
onebox daemon logs # View logs
2025-10-28 13:05:42 +00:00
```
### Registry Management
```bash
2025-11-24 19:52:35 +00:00
# Add external registry credentials
onebox registry add --url registry.example.com --username user --password pass
# List registries
2025-10-28 13:05:42 +00:00
onebox registry list
2025-11-24 19:52:35 +00:00
# Remove registry
onebox registry remove <url>
2025-10-28 13:05:42 +00:00
```
### DNS Management
```bash
2025-11-24 19:52:35 +00:00
# Add DNS record (requires Cloudflare config)
onebox dns add <domain>
# List DNS records
2025-10-28 13:05:42 +00:00
onebox dns list
2025-11-24 19:52:35 +00:00
# Sync from Cloudflare
2025-10-28 13:05:42 +00:00
onebox dns sync
2025-11-24 19:52:35 +00:00
# Remove DNS record
onebox dns remove <domain>
2025-10-28 13:05:42 +00:00
```
### SSL Management
```bash
2025-11-24 19:52:35 +00:00
# Renew expiring certificates
onebox ssl renew
# Force renew specific domain
2025-10-28 13:05:42 +00:00
onebox ssl force-renew <domain>
2025-11-24 19:52:35 +00:00
# List certificates
onebox ssl list
2025-10-28 13:05:42 +00:00
```
2025-11-24 19:52:35 +00:00
### Configuration
2025-10-28 13:05:42 +00:00
```bash
2025-11-24 19:52:35 +00:00
# Show all settings
onebox config show
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
# Set configuration value
onebox config set <key> <value>
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
# Example: Configure Cloudflare
onebox config set cloudflareAPIKey your-api-key
onebox config set cloudflareEmail your@email .com
onebox config set cloudflareZoneID your-zone-id
2025-10-28 13:05:42 +00:00
```
2025-11-24 19:52:35 +00:00
### System Status
2025-10-28 13:05:42 +00:00
```bash
2025-11-24 19:52:35 +00:00
# Get full system status
onebox status
2025-10-28 13:05:42 +00:00
```
2025-11-24 19:52:35 +00:00
## Configuration 🔧
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
### System Requirements
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
- **Linux** (x64 or ARM64)
- **Docker** installed and running
- **Docker Swarm** initialized (`docker swarm init` )
- **Root/sudo access** for ports 80/443
- **(Optional) Cloudflare account** for DNS automation
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
### Data Locations
2025-10-28 13:05:42 +00:00
2025-11-25 04:20:19 +00:00
| Data | Location |
|------|----------|
| **Database ** | `./onebox.db` (or custom path) |
| **SSL Certificates ** | Managed by CertManager |
| **Registry Data ** | `./.nogit/registry-data` |
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
### Environment Variables
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
```bash
# Database location
ONEBOX_DB_PATH=/path/to/onebox.db
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
# HTTP server port (default: 3000)
ONEBOX_HTTP_PORT=3000
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
# Enable debug logging
ONEBOX_DEBUG=true
```
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
## Development 💻
### Setup
2025-10-28 13:05:42 +00:00
```bash
# Clone repository
git clone https://code.foss.global/serve.zone/onebox
cd onebox
2025-11-25 04:20:19 +00:00
# Start development server (auto-restart on changes)
pnpm run watch
2025-11-24 19:52:35 +00:00
```
### Tasks
```bash
# Development server (auto-restart on changes)
2025-10-28 13:05:42 +00:00
deno task dev
# Run tests
deno task test
2025-11-24 19:52:35 +00:00
# Watch mode for tests
deno task test:watch
# Compile binaries for all platforms
2025-10-28 13:05:42 +00:00
deno task compile
```
2025-11-24 19:52:35 +00:00
### Project Structure
```
onebox/
├── ts/
2025-11-25 04:20:19 +00:00
│ ├── classes/ # Core implementations
│ │ ├── onebox.ts # Main coordinator
2025-11-26 13:51:48 +00:00
│ │ ├── reverseproxy.ts # Reverse proxy orchestration
│ │ ├── caddy.ts # Caddy Docker service management
2025-11-25 04:20:19 +00:00
│ │ ├── docker.ts # Docker Swarm API
│ │ ├── httpserver.ts # REST API + WebSocket
│ │ ├── services.ts # Service orchestration
│ │ ├── certmanager.ts # SSL certificate management
│ │ ├── cert-requirement-manager.ts # Certificate requirements
│ │ ├── ssl.ts # SSL utilities
│ │ ├── registry.ts # Built-in Docker registry
│ │ ├── registries.ts # External registry management
│ │ ├── dns.ts # DNS record management
│ │ ├── cloudflare-sync.ts # Cloudflare zone sync
│ │ ├── daemon.ts # Systemd daemon management
│ │ └── apiclient.ts # API client utilities
2025-11-26 13:51:48 +00:00
│ ├── database/ # Database layer (repository pattern)
│ │ ├── index.ts # Main OneboxDatabase class
│ │ ├── base.repository.ts # Base repository class
│ │ └── repositories/ # Domain-specific repositories
│ │ ├── service.repository.ts
│ │ ├── certificate.repository.ts
│ │ ├── auth.repository.ts
│ │ ├── metrics.repository.ts
│ │ └── ...
2025-11-25 04:20:19 +00:00
│ ├── cli.ts # CLI router
│ ├── types.ts # TypeScript interfaces
│ ├── logging.ts # Logging utilities
│ └── plugins.ts # Dependency imports
2025-11-26 13:51:48 +00:00
├── ui/ # Angular 19 web interface
2025-11-25 04:20:19 +00:00
├── test/ # Test files
├── mod.ts # Main entry point
└── deno.json # Deno configuration
2025-11-24 19:52:35 +00:00
```
### API Endpoints
2025-11-25 04:20:19 +00:00
The HTTP server exposes a comprehensive REST API:
#### Authentication
| Method | Endpoint | Description |
|--------|----------|-------------|
| `POST` | `/api/auth/login` | User authentication (returns token) |
#### Services
| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/services` | List all services |
| `POST` | `/api/services` | Create/deploy service |
| `GET` | `/api/services/:name` | Get service details |
| `PUT` | `/api/services/:name` | Update service |
| `DELETE` | `/api/services/:name` | Delete service |
| `POST` | `/api/services/:name/start` | Start service |
| `POST` | `/api/services/:name/stop` | Stop service |
| `POST` | `/api/services/:name/restart` | Restart service |
| `GET` | `/api/services/:name/logs` | Get service logs |
| `WS` | `/api/services/:name/logs/stream` | Stream logs via WebSocket |
#### SSL Certificates
| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/ssl/list` | List all certificates |
| `GET` | `/api/ssl/:domain` | Get certificate details |
| `POST` | `/api/ssl/obtain` | Request new certificate |
| `POST` | `/api/ssl/:domain/renew` | Force renew certificate |
#### Domains
| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/domains` | List all domains |
| `GET` | `/api/domains/:domain` | Get domain details |
| `POST` | `/api/domains/sync` | Sync domains from Cloudflare |
#### DNS Records
| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/dns` | List DNS records |
| `POST` | `/api/dns` | Create DNS record |
| `DELETE` | `/api/dns/:domain` | Delete DNS record |
| `POST` | `/api/dns/sync` | Sync DNS from Cloudflare |
#### Registry
| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/registry/tags/:service` | Get registry tags for service |
| `GET` | `/api/registry/tokens` | List registry tokens |
| `POST` | `/api/registry/tokens` | Create registry token |
| `DELETE` | `/api/registry/tokens/:id` | Delete registry token |
#### System
| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/status` | System status |
| `GET` | `/api/settings` | Get settings |
| `PUT` | `/api/settings` | Update settings |
| `WS` | `/api/ws` | WebSocket for real-time updates |
2025-11-24 19:52:35 +00:00
### WebSocket Messages
Real-time updates are broadcast via WebSocket:
```typescript
// Service lifecycle updates
{
type: 'service_update',
action: 'created' | 'updated' | 'deleted' | 'started' | 'stopped',
service: { id, name, status, ... }
}
// Service status changes
{
type: 'service_status',
service: { id, name, status, ... }
}
// System status updates
{
type: 'system_status',
status: { docker, reverseProxy, services, ... }
}
```
## Advanced Usage 🚀
### Using the Built-in Registry
```bash
# Deploy a service with Onebox Registry
onebox service add myapp \
--use-onebox-registry \
--domain myapp.example.com \
--auto-update-on-push
# Get the registry token for pushing images
# (Token is automatically created and stored in database)
# Push your image
docker tag myimage:latest localhost:4000/myapp:latest
docker push localhost:4000/myapp:latest
# Service automatically updates! 🎉
```
2025-11-25 04:20:19 +00:00
### Registry Token Management
```bash
# Create a CI/CD token via API
curl -X POST http://localhost:3000/api/registry/tokens \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "github-actions", "type": "ci", "scope": ["myapp"], "expiresIn": "90d"}'
# Use token for docker login
docker login localhost:4000 -u ci -p <token>
```
2025-11-24 19:52:35 +00:00
### Cloudflare DNS Integration
```bash
# Configure Cloudflare (one-time setup)
onebox config set cloudflareAPIKey your-api-key
onebox config set cloudflareEmail your@email .com
onebox config set cloudflareZoneID your-zone-id
# Deploy with automatic DNS
onebox service add myapp \
--image nginx:latest \
--domain myapp.example.com
# DNS record is automatically created!
2025-11-25 04:20:19 +00:00
# Sync all domains from Cloudflare
onebox dns sync
2025-11-24 19:52:35 +00:00
```
### SSL Certificate Management
SSL certificates are automatically obtained and renewed:
2025-11-25 04:20:19 +00:00
- ✅ Certificates are requested when a service with a domain is deployed
- ✅ Renewal happens automatically 30 days before expiry
- ✅ Certificates are hot-reloaded without downtime
- ✅ Force renewal: `onebox ssl force-renew <domain>`
2025-11-24 19:52:35 +00:00
### Monitoring and Metrics
Metrics are collected every 60 seconds (configurable):
```bash
# Set metrics interval (milliseconds)
onebox config set metricsInterval 30000
# View in web UI or query database directly
sqlite3 onebox.db "SELECT * FROM metrics WHERE service_id = 1 ORDER BY timestamp DESC LIMIT 10"
```
## Troubleshooting 🔧
### Docker Swarm Not Initialized
```bash
# Initialize Docker Swarm
docker swarm init
# Verify swarm mode
docker info | grep "Swarm: active"
```
### Port Already in Use
```bash
# Check what's using port 80/443
sudo lsof -i :80
sudo lsof -i :443
# Kill the process or change Onebox ports
onebox config set httpPort 8080
```
### SSL Certificate Issues
```bash
# Check certificate status
onebox ssl list
# Verify DNS is pointing to your server
dig +short yourdomain.com
# Force certificate renewal
onebox ssl force-renew yourdomain.com
```
### WebSocket Connection Issues
2025-11-25 04:20:19 +00:00
- ✅ Ensure firewall allows WebSocket connections
- ✅ Check browser console for connection errors
- ✅ Verify `/api/ws` endpoint is accessible
2025-11-24 19:52:35 +00:00
### Service Not Starting
```bash
# Check Docker logs
docker service logs <service-name>
# Check Onebox logs
onebox daemon logs
# Verify image exists
docker images | grep <image-name>
```
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license ](license ) file within this repository.
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
### Trademarks
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
2025-10-28 13:05:42 +00:00
2025-11-26 13:51:48 +00:00
### Issue Reporting and Security
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/ ](https://community.foss.global/ ). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/ ](https://code.foss.global/ ) account to submit Pull Requests directly.
2025-11-24 19:52:35 +00:00
### Company Information
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
For any legal inquiries or if you require further information, please contact us via email at hello@task .vc.
2025-10-28 13:05:42 +00:00
2025-11-24 19:52:35 +00:00
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.