Skip to content

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:

Preparing Your Repository

Create a GitHub repository containing your Dockerfile for Pastefy deployment.

Repository Structure

pastefy-deploy/
├── Dockerfile
└── .dockerignore

Creating the Dockerfile

Create a Dockerfile in the root of your repository:

FROM interaapps/pastefy:latest
# Set environment variables
ENV HTTP_SERVER_PORT=80
ENV HTTP_SERVER_CORS=*
# Database configuration (using embedded H2 by default)
ENV DATABASE_DRIVER=${DATABASE_DRIVER:-h2}
# For MySQL/MariaDB
ENV 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 configuration
ENV SERVER_URL=${SERVER_URL}
# Create data directory for H2 database
RUN mkdir -p /data
# Expose the web interface port
EXPOSE 80
# Use the default entrypoint

Creating the .dockerignore File

Create a .dockerignore file:

.git
.github
*.md
LICENSE
.gitignore
*.log
.DS_Store
.env
.env.local

Environment Variables Reference

VariableRequiredDefaultDescription
DATABASE_DRIVERNoh2Database driver (h2, mysql, mariadb)
DATABASE_HOSTNo-Database hostname (for MySQL/MariaDB)
DATABASE_PORTNo3306Database port
DATABASE_NAMENo-Database name
DATABASE_USERNo-Database username
DATABASE_PASSWORDNo-Database password
SERVER_URLNo-Public URL of your Pastefy instance
HTTP_SERVER_PORTNo80HTTP server port
HTTP_SERVER_CORSNo*CORS allowed origins
REQUIRE_AUTHNofalseRequire authentication for creating pastes
ENCRYPTION_DEFAULTNofalseEnable encryption by default
LOGIN_REQUIRED_FOR_READNofalseRequire login to view pastes

Deploying Pastefy on Klutch.sh

    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:

    • Select HTTP as the traffic type
    • Set the internal port to 80

    Set Environment Variables

    Add the following environment variables:

    VariableValue
    SERVER_URLhttps://your-app-name.klutch.sh
    DATABASE_DRIVERh2 (or mysql for external database)

    For MySQL/MariaDB, also add:

    VariableValue
    DATABASE_HOSTYour database host
    DATABASE_NAMEDatabase name
    DATABASE_USERDatabase username
    DATABASE_PASSWORDDatabase password

    Attach Persistent Volumes (for H2)

    If using the embedded H2 database:

    Mount PathRecommended SizePurpose
    /data5 GBH2 database storage

    Deploy Your Application

    Click Deploy to start the build process. Klutch.sh will:

    • Detect your Dockerfile automatically
    • Build the container image
    • Attach the persistent volumes
    • Start the Pastefy container
    • Provision an HTTPS certificate

    Access Pastefy

    Once deployment completes, access your Pastefy instance at https://your-app-name.klutch.sh.

Using Pastefy

Creating a Paste

  1. Navigate to your Pastefy instance
  2. Enter or paste your content
  3. Select the language for syntax highlighting (or let it auto-detect)
  4. Optionally set a title and expiration
  5. Click Create to generate a shareable link

Encrypted Pastes

For sensitive content:

  1. Enable encryption before creating the paste
  2. Content is encrypted in your browser
  3. The decryption key is part of the URL fragment
  4. Only users with the full URL can decrypt the paste

Organizing with Folders

If user accounts are enabled:

  1. Create an account or log in
  2. Create folders for organization
  3. Save pastes to specific folders
  4. Manage and search your paste history

Multi-Paste

Combine multiple files in one paste:

  1. Click the + button to add tabs
  2. Name each tab with the filename
  3. Add content to each tab
  4. Share all files with a single URL

API Access

Pastefy provides a REST API for automation:

Terminal window
# Create a paste
curl -X POST "https://your-pastefy-instance/api/v2/paste" \
-H "Content-Type: application/json" \
-d '{"content": "Hello World", "title": "My Paste"}'
# Get a paste
curl "https://your-pastefy-instance/api/v2/paste/{paste_id}"

CLI Usage

Use the Pastefy CLI for command-line sharing:

Terminal window
# Install
npm install -g pastefy-cli
# Configure
pastefy config --server https://your-pastefy-instance
# Share a file
cat myfile.txt | pastefy
# Share from clipboard
pastefy --clipboard

Customization

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 pastes
  • LOGIN_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.