Skip to content

Deploying Opengist

Introduction

Opengist is a self-hosted pastebin powered by Git, offering a modern alternative to services like GitHub Gist. Every paste is a Git repository, providing full version history, the ability to clone pastes, and seamless integration with standard Git workflows. Built with Go, Opengist is lightweight, fast, and easy to deploy.

Unlike traditional pastebins that store text in databases, Opengist leverages Git’s powerful versioning capabilities. You can track changes, revert to previous versions, and even push updates directly via Git. The clean web interface supports syntax highlighting for hundreds of languages, making it perfect for sharing code snippets.

Key highlights of Opengist:

  • Git-Backed Storage: Every paste is a Git repository with full history
  • Syntax Highlighting: Support for 250+ languages via Chroma
  • Multiple Files: Create pastes with multiple files like GitHub Gist
  • Version History: View diffs and revert to previous versions
  • Git Clone/Push: Clone pastes and push updates using Git
  • User Accounts: Optional authentication with local accounts or OAuth
  • Public and Private Pastes: Control visibility of your snippets
  • Embed Support: Embed pastes in other websites
  • Search: Full-text search across your pastes
  • Lightweight: Single binary with minimal resource requirements

This guide walks through deploying Opengist on Klutch.sh using Docker, configuring authentication, and setting up your pastebin for production use.

Why Deploy Opengist on Klutch.sh

Deploying Opengist on Klutch.sh provides several advantages:

Simplified Deployment: Klutch.sh automatically builds and deploys your pastebin. Push to GitHub, and your paste service deploys without manual intervention.

Persistent Storage: Attach persistent volumes for Git repositories and database. Your pastes and their history survive container restarts.

HTTPS by Default: Klutch.sh provides automatic SSL certificates, ensuring secure access to your pastebin and Git operations.

GitHub Integration: Store configuration in Git for version-controlled infrastructure. Update by pushing changes.

Always-On Availability: Your pastebin runs 24/7, ready for sharing snippets whenever you need.

Custom Domains: Use your own domain for professional, branded paste URLs.

Scalable Resources: Allocate resources based on expected storage and traffic.

Prerequisites

Before deploying Opengist on Klutch.sh, ensure you have:

  • A Klutch.sh account
  • A GitHub account with a repository for your Opengist configuration
  • Basic familiarity with Docker and containerization concepts
  • (Optional) OAuth credentials for GitHub, GitLab, or Gitea authentication

Understanding Opengist Architecture

Opengist has a simple architecture:

Go Backend: Handles HTTP requests, Git operations, and business logic. Written in Go for performance and easy deployment.

SQLite Database: Stores user accounts, paste metadata, and search indexes. Lightweight and requires no external database server.

Git Storage: Each paste is stored as a bare Git repository on the filesystem.

Web Interface: Clean, responsive frontend for creating and viewing pastes.

Preparing Your Repository

Create a GitHub repository containing your Dockerfile and configuration.

Repository Structure

opengist-deploy/
├── Dockerfile
├── .dockerignore
└── README.md

Creating the Dockerfile

Create a Dockerfile for Opengist:

FROM ghcr.io/thomiceli/opengist:latest
# Create directories for persistent data
RUN mkdir -p /opengist-data
# Environment configuration
ENV OG_LOG_LEVEL=info
ENV OG_EXTERNAL_URL=""
ENV OG_HTTP_PORT=6157
ENV OG_SSH_GIT_ENABLED=false
# Expose the web interface port
EXPOSE 6157
# Use the default entrypoint
CMD ["opengist"]

Advanced Dockerfile with SSH

To enable Git SSH access:

FROM ghcr.io/thomiceli/opengist:latest
# Create directories for persistent data
RUN mkdir -p /opengist-data
# Environment configuration
ENV OG_LOG_LEVEL=info
ENV OG_EXTERNAL_URL=""
ENV OG_HTTP_PORT=6157
ENV OG_SSH_GIT_ENABLED=true
ENV OG_SSH_PORT=2222
# Expose ports
EXPOSE 6157
EXPOSE 2222
CMD ["opengist"]

Environment Variables Reference

VariableDefaultDescription
OG_EXTERNAL_URL-Public URL for your instance
OG_HTTP_PORT6157HTTP server port
OG_SSH_GIT_ENABLEDfalseEnable Git over SSH
OG_SSH_PORT2222SSH server port
OG_LOG_LEVELinfoLogging verbosity
OG_DB_FILENAMEopengist.dbSQLite database filename
OG_HOME-Home directory for Opengist data
OG_GITHUB_CLIENT_KEY-GitHub OAuth client ID
OG_GITHUB_SECRET-GitHub OAuth client secret
OG_GITLAB_CLIENT_KEY-GitLab OAuth client ID
OG_GITLAB_SECRET-GitLab OAuth client secret
OG_GITEA_CLIENT_KEY-Gitea OAuth client ID
OG_GITEA_SECRET-Gitea OAuth client secret
OG_GITEA_URL-Self-hosted Gitea instance URL

Deploying Opengist on Klutch.sh

Follow these steps to deploy your Opengist pastebin:

    Push Your Repository to GitHub

    Initialize and push your repository:

    Terminal window
    git init
    git add Dockerfile .dockerignore README.md
    git commit -m "Initial Opengist configuration"
    git remote add origin https://github.com/yourusername/opengist-deploy.git
    git push -u origin main

    Create a New Project on Klutch.sh

    Navigate to the Klutch.sh dashboard and create a new project named “opengist” or “pastebin”.

    Create a New App

    Within your project, create a new app. Connect your GitHub account and select the repository containing your Opengist Dockerfile.

    Configure HTTP Traffic

    In the deployment settings:

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

    Set Environment Variables

    Configure your Opengist instance:

    VariableValue
    OG_EXTERNAL_URLhttps://your-app-name.klutch.sh
    OG_LOG_LEVELinfo

    Attach Persistent Volumes

    Add persistent storage:

    Mount PathRecommended SizePurpose
    /opengist-data20 GBGit repositories and database

    Deploy Your Application

    Click Deploy to start the build process.

    Access Opengist

    Once deployment completes, access your pastebin at https://your-app-name.klutch.sh. Create your first account to get started.

Initial Configuration

Creating Your Account

On first access:

  1. Click “Register” to create an account
  2. Enter username and password
  3. Your account is created and logged in

Admin Configuration

The first registered user becomes admin. Access admin settings to configure:

  • Disable user registration
  • Require authentication to view pastes
  • Configure default paste visibility

Using Opengist

Creating Pastes

Create new pastes through the web interface:

  1. Click “New Gist”
  2. Enter a description (optional)
  3. Add file name and content
  4. Add additional files if needed
  5. Choose visibility (public, unlisted, private)
  6. Click “Create”

Git Operations

Clone a paste:

Terminal window
git clone https://your-app-name.klutch.sh/username/paste-id.git

Push updates:

Terminal window
cd paste-id
# Make changes
git add .
git commit -m "Update paste"
git push

Embedding Pastes

Embed pastes in other websites:

<script src="https://your-app-name.klutch.sh/username/paste-id.js"></script>

Or embed specific files:

<script src="https://your-app-name.klutch.sh/username/paste-id.js?file=main.py"></script>

Raw Content

Access raw file content:

https://your-app-name.klutch.sh/username/paste-id/raw/filename.py

OAuth Authentication

GitHub OAuth

Configure GitHub authentication:

  1. Create an OAuth App on GitHub:

    • Go to Settings > Developer settings > OAuth Apps
    • Set callback URL to https://your-app-name.klutch.sh/oauth/github/callback
  2. Add environment variables:

VariableValue
OG_GITHUB_CLIENT_KEYYour GitHub Client ID
OG_GITHUB_SECRETYour GitHub Client Secret

GitLab OAuth

Configure GitLab authentication:

  1. Create an OAuth Application on GitLab
  2. Set callback URL to https://your-app-name.klutch.sh/oauth/gitlab/callback
  3. Add environment variables:
VariableValue
OG_GITLAB_CLIENT_KEYYour GitLab Application ID
OG_GITLAB_SECRETYour GitLab Secret

Gitea OAuth

For self-hosted Gitea:

VariableValue
OG_GITEA_CLIENT_KEYYour Gitea Client ID
OG_GITEA_SECRETYour Gitea Client Secret
OG_GITEA_URLYour Gitea instance URL

Advanced Configuration

Restricting Access

Control who can view and create pastes:

  • Require login to view any pastes
  • Disable public registration
  • Use OAuth for controlled access

Customization

Customize the appearance:

  • Opengist supports custom CSS
  • Configure through environment variables
  • Brand with your organization’s style

API Usage

Creating Pastes via API

Terminal window
curl -X POST https://your-app-name.klutch.sh/api/gists \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"description": "My paste",
"visibility": "public",
"files": {
"hello.py": {
"content": "print(\"Hello, World!\")"
}
}
}'

Listing Pastes

Terminal window
curl https://your-app-name.klutch.sh/api/gists

Backup and Restore

Backing Up Data

The /opengist-data directory contains:

  • SQLite database with user accounts and metadata
  • Git repositories for all pastes

Back up this directory regularly to prevent data loss.

Restoring Data

To restore from backup:

  1. Stop the Opengist container
  2. Replace the data directory with your backup
  3. Restart the container

Troubleshooting Common Issues

Cannot Clone Pastes

Symptoms: Git clone fails with authentication errors.

Solutions:

  • Verify the paste is public or you’re authenticated
  • Check the external URL configuration
  • Ensure HTTPS is properly configured

Pastes Not Displaying

Symptoms: Blank page or error when viewing pastes.

Solutions:

  • Check database file exists and is readable
  • Verify Git repositories exist in data directory
  • Review application logs for errors

OAuth Login Failing

Symptoms: Cannot log in with OAuth provider.

Solutions:

  • Verify callback URL matches exactly
  • Check client ID and secret are correct
  • Ensure OAuth app is not rate limited

Search Not Working

Symptoms: Search returns no results.

Solutions:

  • Verify search index is built
  • Check database file is not corrupted
  • Restart container to rebuild index

Additional Resources

Conclusion

Deploying Opengist on Klutch.sh provides a powerful, Git-backed pastebin for sharing code snippets. With full version history, multi-file support, and Git clone/push capabilities, Opengist goes beyond simple text sharing.

The combination of persistent storage for Git repositories and automatic HTTPS makes Klutch.sh an excellent platform for hosting Opengist. Whether sharing code with colleagues or maintaining a personal snippet collection, your self-hosted pastebin provides the features and control that public services cannot match.

Start sharing code snippets today with the confidence that your data is under your control and backed by Git’s reliable versioning.