Deploying bin
Introduction
bin is a minimal, self-hosted pastebin service that provides a clean and simple way to share code snippets, logs, and text. With no unnecessary features, bin focuses on doing one thing well: storing and sharing text.
Built for speed and simplicity, bin offers syntax highlighting, expiring pastes, and a straightforward API. It’s perfect for developers and teams who want a private paste service without the bloat of larger solutions.
Key highlights of bin:
- Minimal Design: Clean interface focused on pasting and sharing
- Syntax Highlighting: Automatic language detection and highlighting
- Expiring Pastes: Set pastes to expire after a duration
- Raw View: Access raw text for easy copying
- API Access: Simple API for programmatic paste creation
- No Account Required: Anonymous paste creation
- Burn After Reading: One-time view pastes
- Private Pastes: Control paste visibility
- Fast Performance: Lightweight and quick
- Self-Hosted: Complete control over your data
This guide walks through deploying bin on Klutch.sh using Docker.
Why Deploy bin on Klutch.sh
Deploying bin on Klutch.sh provides several advantages:
Private Sharing: Share sensitive code snippets without third-party access.
HTTPS by Default: Secure paste sharing with automatic SSL.
Always Available: Your paste service runs 24/7.
Simple Deployment: Minimal configuration required.
Custom Domain: Use your own domain for a branded service.
Persistent Storage: Pastes survive container restarts.
Prerequisites
Before deploying bin on Klutch.sh, ensure you have:
- A Klutch.sh account
- A GitHub account with a repository for your configuration
- Basic understanding of Docker and containerization
Understanding bin Architecture
bin is intentionally simple:
Web Server: Handles paste creation and viewing.
File Storage: Stores pastes as files on disk.
Syntax Highlighter: Provides code highlighting.
Preparing Your Repository
Create a GitHub repository for your bin deployment.
Repository Structure
bin-deploy/├── Dockerfile└── .dockerignoreCreating the Dockerfile
Create a Dockerfile for bin:
FROM rust:alpine AS builder
# Install build dependenciesRUN apk add --no-cache musl-dev
# Clone and build binWORKDIR /buildRUN apk add --no-cache git \ && git clone https://github.com/w4/bin.git . \ && cargo build --release
# Runtime imageFROM alpine:latest
# Install runtime dependenciesRUN apk add --no-cache ca-certificates
# Copy binaryCOPY --from=builder /build/target/release/bin /usr/local/bin/bin
# Create directoriesWORKDIR /opt/binRUN mkdir -p /opt/bin/data
# Environment variablesENV BIN_LISTEN=0.0.0.0:8080ENV BIN_DATABASE_PATH=/opt/bin/data
# Expose portEXPOSE 8080
# Volume for dataVOLUME ["/opt/bin/data"]
# Start binCMD ["bin"]Environment Variables Reference
| Variable | Required | Default | Description |
|---|---|---|---|
BIN_LISTEN | No | 0.0.0.0:8080 | Address and port to listen on |
BIN_DATABASE_PATH | No | ./data | Path to store pastes |
BIN_MAX_PASTE_SIZE | No | 1MB | Maximum paste size |
BIN_ID_LENGTH | No | 6 | Length of paste IDs |
Deploying bin on Klutch.sh
- Select HTTP as the traffic type
- Set the internal port to 8080
Push Your Repository to GitHub
Initialize and push your configuration to GitHub.
Create a New Project on Klutch.sh
Navigate to the Klutch.sh dashboard and create a new project named “bin” or “pastebin”.
Create a New App
Within your project, create a new app and connect your GitHub repository.
Configure HTTP Traffic
Set up HTTP for the web interface:
Attach Persistent Volumes
Add storage for pastes:
| Mount Path | Recommended Size | Purpose |
|---|---|---|
/opt/bin/data | 5 GB | Paste storage |
Deploy Your Application
Click Deploy to build and start bin.
Access Your Pastebin
Once deployment completes, access bin at https://your-app-name.klutch.sh.
Using bin
Creating Pastes
Create a paste through the web interface:
- Navigate to your bin URL
- Paste or type your content
- Click “Save”
- Copy the generated URL
Syntax Highlighting
bin automatically detects language, or specify manually:
- Add file extension to URL:
/paste-id.py - Syntax highlighting applies automatically
Raw View
Access raw paste content:
- Add
/rawto the URL - View plain text without highlighting
API Usage
Create pastes programmatically:
# Create a pastecurl -X POST https://your-bin.klutch.sh \ -d "Hello, World!"
# Create with expirationcurl -X POST https://your-bin.klutch.sh \ -H "X-Expires: 3600" \ -d "Expires in 1 hour"Command Line Integration
Add a shell function for easy pasting:
# Add to ~/.bashrc or ~/.zshrcbin() { curl -sS -X POST https://your-bin.klutch.sh --data-binary "@${1:--}"}
# Usagecat file.txt | binbin < script.shecho "Hello" | binConfiguration Options
Expiring Pastes
Configure default expiration:
- Set
X-Expiresheader with seconds - Pastes automatically deleted after expiration
Burn After Reading
Create one-time pastes:
- Set
X-Burnheader totrue - Paste deleted after first view
Maximum Size
Control paste size limits:
- Set
BIN_MAX_PASTE_SIZEenvironment variable - Rejects pastes exceeding limit
Troubleshooting Common Issues
Paste Not Saving
Solutions:
- Check paste size is within limits
- Verify storage volume is mounted
- Review server logs for errors
Syntax Highlighting Not Working
Solutions:
- Verify file extension is recognized
- Try specifying language explicitly
- Check JavaScript is enabled in browser
404 on Paste Access
Solutions:
- Verify paste ID is correct
- Check if paste has expired
- Confirm paste was successfully created
Additional Resources
Conclusion
Deploying bin on Klutch.sh gives you a minimal, fast pastebin service for sharing code and text. With syntax highlighting, expiring pastes, and a simple API, bin provides everything you need for quick text sharing without the complexity of larger solutions.