Deploying Pastefy
Introduction
Pastefy is a self-hosted, modern pastebin application that enables sharing of code snippets, text, and files with a beautiful interface and powerful features. Designed as a privacy-focused alternative to public pastebin services, Pastefy gives you complete control over your shared content.
Built with Java and Vue.js, Pastefy offers a responsive user experience with features like syntax highlighting, encrypted pastes, folders for organization, and a comprehensive API for integrations.
Key highlights of Pastefy:
- Syntax Highlighting: Automatic language detection with support for 100+ languages
- Encrypted Pastes: Client-side encryption for sensitive content
- Folders: Organize pastes into folders for better management
- User Accounts: Optional user registration for managing pastes
- Raw View: Direct access to raw paste content
- Multi-Paste: Combine multiple files in a single paste
- Expiration: Set automatic expiration for temporary pastes
- API Access: Full REST API for programmatic access
- Embedding: Embed pastes in other websites
- CLI Tool: Command-line interface for quick sharing
- Open Source: Licensed under MIT
This guide walks through deploying Pastefy on Klutch.sh using Docker, configuring the application, and setting up persistent storage.
Why Deploy Pastefy on Klutch.sh
Deploying Pastefy on Klutch.sh provides several advantages:
Simplified Deployment: Klutch.sh automatically detects your Dockerfile and builds Pastefy without complex orchestration. Push to GitHub, and your pastebin deploys automatically.
Data Privacy: Keep your shared content private on your own infrastructure instead of public pastebin services.
HTTPS by Default: Klutch.sh provides automatic SSL certificates for secure paste sharing.
Persistent Storage: Attach persistent volumes for your database. Your pastes survive container restarts and redeployments.
Custom Domains: Use a memorable domain for your Pastefy instance.
Always Available: Access and share pastes from anywhere, anytime.
Prerequisites
Before deploying Pastefy on Klutch.sh, ensure you have:
- A Klutch.sh account
- A GitHub account with a repository for your Pastefy configuration
- Basic familiarity with Docker and containerization concepts
Preparing Your Repository
Create a GitHub repository containing your Dockerfile for Pastefy deployment.
Repository Structure
pastefy-deploy/├── Dockerfile└── .dockerignoreCreating the Dockerfile
Create a Dockerfile in the root of your repository:
FROM interaapps/pastefy:latest
# Set environment variablesENV HTTP_SERVER_PORT=80ENV HTTP_SERVER_CORS=*
# Database configuration (using embedded H2 by default)ENV DATABASE_DRIVER=${DATABASE_DRIVER:-h2}
# For MySQL/MariaDBENV DATABASE_HOST=${DATABASE_HOST}ENV DATABASE_PORT=${DATABASE_PORT:-3306}ENV DATABASE_NAME=${DATABASE_NAME}ENV DATABASE_USER=${DATABASE_USER}ENV DATABASE_PASSWORD=${DATABASE_PASSWORD}
# Server configurationENV SERVER_URL=${SERVER_URL}
# Create data directory for H2 databaseRUN mkdir -p /data
# Expose the web interface portEXPOSE 80
# Use the default entrypointCreating the .dockerignore File
Create a .dockerignore file:
.git.github*.mdLICENSE.gitignore*.log.DS_Store.env.env.localEnvironment Variables Reference
| Variable | Required | Default | Description |
|---|---|---|---|
DATABASE_DRIVER | No | h2 | Database driver (h2, mysql, mariadb) |
DATABASE_HOST | No | - | Database hostname (for MySQL/MariaDB) |
DATABASE_PORT | No | 3306 | Database port |
DATABASE_NAME | No | - | Database name |
DATABASE_USER | No | - | Database username |
DATABASE_PASSWORD | No | - | Database password |
SERVER_URL | No | - | Public URL of your Pastefy instance |
HTTP_SERVER_PORT | No | 80 | HTTP server port |
HTTP_SERVER_CORS | No | * | CORS allowed origins |
REQUIRE_AUTH | No | false | Require authentication for creating pastes |
ENCRYPTION_DEFAULT | No | false | Enable encryption by default |
LOGIN_REQUIRED_FOR_READ | No | false | Require login to view pastes |
Deploying Pastefy on Klutch.sh
- Select HTTP as the traffic type
- Set the internal port to 80
- Detect your Dockerfile automatically
- Build the container image
- Attach the persistent volumes
- Start the Pastefy container
- Provision an HTTPS certificate
Push Your Repository to GitHub
Initialize your repository and push to GitHub with your Dockerfile.
Create a New Project on Klutch.sh
Navigate to the Klutch.sh dashboard and create a new project. Give it a descriptive name like “pastefy” or “pastebin”.
Create a New App
Within your project, create a new app. Connect your GitHub account if you haven’t already, then select the repository containing your Pastefy Dockerfile.
Configure HTTP Traffic
In the deployment settings:
Set Environment Variables
Add the following environment variables:
| Variable | Value |
|---|---|
SERVER_URL | https://your-app-name.klutch.sh |
DATABASE_DRIVER | h2 (or mysql for external database) |
For MySQL/MariaDB, also add:
| Variable | Value |
|---|---|
DATABASE_HOST | Your database host |
DATABASE_NAME | Database name |
DATABASE_USER | Database username |
DATABASE_PASSWORD | Database password |
Attach Persistent Volumes (for H2)
If using the embedded H2 database:
| Mount Path | Recommended Size | Purpose |
|---|---|---|
/data | 5 GB | H2 database storage |
Deploy Your Application
Click Deploy to start the build process. Klutch.sh will:
Access Pastefy
Once deployment completes, access your Pastefy instance at https://your-app-name.klutch.sh.
Using Pastefy
Creating a Paste
- Navigate to your Pastefy instance
- Enter or paste your content
- Select the language for syntax highlighting (or let it auto-detect)
- Optionally set a title and expiration
- Click Create to generate a shareable link
Encrypted Pastes
For sensitive content:
- Enable encryption before creating the paste
- Content is encrypted in your browser
- The decryption key is part of the URL fragment
- Only users with the full URL can decrypt the paste
Organizing with Folders
If user accounts are enabled:
- Create an account or log in
- Create folders for organization
- Save pastes to specific folders
- Manage and search your paste history
Multi-Paste
Combine multiple files in one paste:
- Click the + button to add tabs
- Name each tab with the filename
- Add content to each tab
- Share all files with a single URL
API Access
Pastefy provides a REST API for automation:
# Create a pastecurl -X POST "https://your-pastefy-instance/api/v2/paste" \ -H "Content-Type: application/json" \ -d '{"content": "Hello World", "title": "My Paste"}'
# Get a pastecurl "https://your-pastefy-instance/api/v2/paste/{paste_id}"CLI Usage
Use the Pastefy CLI for command-line sharing:
# Installnpm install -g pastefy-cli
# Configurepastefy config --server https://your-pastefy-instance
# Share a filecat myfile.txt | pastefy
# Share from clipboardpastefy --clipboardCustomization
Appearance
Pastefy supports customization through environment variables:
- Custom branding and colors
- Footer customization
- Feature toggles
Access Control
Configure access policies:
REQUIRE_AUTH=true: Require login to create pastesLOGIN_REQUIRED_FOR_READ=true: Require login to view pastes- Rate limiting for API access
Additional Resources
Conclusion
Deploying Pastefy on Klutch.sh gives you a modern, self-hosted pastebin with syntax highlighting and encryption. The combination of Pastefy’s clean interface and Klutch.sh’s easy deployment means you can share code and text securely without relying on third-party services.
Whether you’re sharing code snippets with teammates, documenting configurations, or creating quick notes, Pastefy provides a privacy-respecting solution under your control.