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.mdCreating the Dockerfile
Create a Dockerfile for Opengist:
FROM ghcr.io/thomiceli/opengist:latest
# Create directories for persistent dataRUN mkdir -p /opengist-data
# Environment configurationENV OG_LOG_LEVEL=infoENV OG_EXTERNAL_URL=""ENV OG_HTTP_PORT=6157ENV OG_SSH_GIT_ENABLED=false
# Expose the web interface portEXPOSE 6157
# Use the default entrypointCMD ["opengist"]Advanced Dockerfile with SSH
To enable Git SSH access:
FROM ghcr.io/thomiceli/opengist:latest
# Create directories for persistent dataRUN mkdir -p /opengist-data
# Environment configurationENV OG_LOG_LEVEL=infoENV OG_EXTERNAL_URL=""ENV OG_HTTP_PORT=6157ENV OG_SSH_GIT_ENABLED=trueENV OG_SSH_PORT=2222
# Expose portsEXPOSE 6157EXPOSE 2222
CMD ["opengist"]Environment Variables Reference
| Variable | Default | Description |
|---|---|---|
OG_EXTERNAL_URL | - | Public URL for your instance |
OG_HTTP_PORT | 6157 | HTTP server port |
OG_SSH_GIT_ENABLED | false | Enable Git over SSH |
OG_SSH_PORT | 2222 | SSH server port |
OG_LOG_LEVEL | info | Logging verbosity |
OG_DB_FILENAME | opengist.db | SQLite 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:
- Select HTTP as the traffic type
- Set the internal port to 6157
Push Your Repository to GitHub
Initialize and push your repository:
git initgit add Dockerfile .dockerignore README.mdgit commit -m "Initial Opengist configuration"git remote add origin https://github.com/yourusername/opengist-deploy.gitgit push -u origin mainCreate 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:
Set Environment Variables
Configure your Opengist instance:
| Variable | Value |
|---|---|
OG_EXTERNAL_URL | https://your-app-name.klutch.sh |
OG_LOG_LEVEL | info |
Attach Persistent Volumes
Add persistent storage:
| Mount Path | Recommended Size | Purpose |
|---|---|---|
/opengist-data | 20 GB | Git 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:
- Click “Register” to create an account
- Enter username and password
- 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:
- Click “New Gist”
- Enter a description (optional)
- Add file name and content
- Add additional files if needed
- Choose visibility (public, unlisted, private)
- Click “Create”
Git Operations
Clone a paste:
git clone https://your-app-name.klutch.sh/username/paste-id.gitPush updates:
cd paste-id# Make changesgit add .git commit -m "Update paste"git pushEmbedding 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.pyOAuth Authentication
GitHub OAuth
Configure GitHub authentication:
-
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
-
Add environment variables:
| Variable | Value |
|---|---|
OG_GITHUB_CLIENT_KEY | Your GitHub Client ID |
OG_GITHUB_SECRET | Your GitHub Client Secret |
GitLab OAuth
Configure GitLab authentication:
- Create an OAuth Application on GitLab
- Set callback URL to
https://your-app-name.klutch.sh/oauth/gitlab/callback - Add environment variables:
| Variable | Value |
|---|---|
OG_GITLAB_CLIENT_KEY | Your GitLab Application ID |
OG_GITLAB_SECRET | Your GitLab Secret |
Gitea OAuth
For self-hosted Gitea:
| Variable | Value |
|---|---|
OG_GITEA_CLIENT_KEY | Your Gitea Client ID |
OG_GITEA_SECRET | Your Gitea Client Secret |
OG_GITEA_URL | Your 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
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
curl https://your-app-name.klutch.sh/api/gistsBackup 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:
- Stop the Opengist container
- Replace the data directory with your backup
- 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
- Opengist GitHub Repository
- Opengist Documentation
- Opengist Docker Image
- Klutch.sh Persistent Volumes
- Klutch.sh Deployments
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.