This guide will show you how to set up OpenGist – an open-source alternative to GitHub Gist – using Portainer for easy deployment and management.
What is OpenGist?
OpenGist is a self-hosted pastebin service powered by Git, designed as an open-source alternative to GitHub Gist. All snippets are stored in a Git repository and can be read and/or modified using standard Git commands or through the intuitive web interface.
Unlike traditional pastebin services, OpenGist leverages Git’s version control capabilities, making it ideal for developers who want to track changes to their code snippets over time. The Git integration means you can clone, pull, and push changes to your snippets using familiar Git workflows, making collaboration and code management seamless.
OpenGist was developed by Thomas Miceli and released under the AGPL-3.0 license, ensuring it remains free and open-source. It’s built using Go for the backend and utilizes modern web technologies for the frontend, resulting in a lightweight yet powerful application.
Key Features
- Visibility Control: Create public (visible to everyone), unlisted (accessible only via direct link), or private (visible only to you) snippets
- Git Integration: Initialize, clone, pull, and push snippets via Git over HTTP or SSH
- Syntax Highlighting: Support for numerous programming languages with automatic language detection
- Markdown & CSV Support: Rich rendering of markdown files and formatted display of CSV data
- Search Functionality: Search code within snippets and browse by user, likes, or forks
- Organization: Add topics to snippets for better categorization
- Embedding: Embed snippets in other websites with a simple iframe code
- Version Control: Track changes with a comprehensive revision history
- Social Features: Like and fork snippets from other users
- Export Options: Download raw files or entire snippets as ZIP archives
- Authentication Options: Support for OAuth2 login with GitHub, GitLab, Gitea, and OpenID Connect
- Customization: Extensive configuration options for adapting to your specific needs
- API Access: RESTful API for programmatic interaction with your OpenGist instance
With its focus on simplicity, performance, and Git integration, OpenGist provides a powerful yet easy-to-use platform for storing, sharing, and collaborating on code snippets.
Installing OpenGist with Portainer
Prerequisites
- A server with Docker installed
- Portainer CE/BE already set up and running
If you don’t have Portainer yet, you can install it with:
1 2 3 4 5 6 7 8 9 |
docker volume create portainer_data docker run -d -p 8000:8000 -p 9443:9443 --name portainer \ --restart=always \ -v /var/run/docker.sock:/var/run/docker.sock \ -v portainer_data:/data \ portainer/portainer-ce:latest |
Access Portainer at https://your-server-ip:9443
Deployment Steps
- Log in to Portainer Access your Portainer instance and log in with your credentials.
- Create a Stack for OpenGist
- Navigate to the Stacks section in the left sidebar
- Click on + Add stack
- Give your stack a name (e.g., “opengist”)
- Select “Web editor” as the build method
- Paste the following Docker Compose configuration:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
version: '3' services: opengist: image: ghcr.io/thomiceli/opengist:1.9 container_name: opengist restart: unless-stopped ports: - "6157:6157" # HTTP port - "2222:2222" # SSH port, can be removed if you don't use SSH volumes: - opengist_data:/opengist environment: # Add any configuration options here # OG_LOG_LEVEL: info volumes: opengist_data: |
- Deploy the Stack Click on Deploy the stack button
- Access OpenGist After deployment completes, access OpenGist at http://your-server-ip:6157
Basic Configuration Options
You can add environment variables to customize your OpenGist installation:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
environment: # General settings OG_BASE_URL: https://opengist.example.com # User permissions UID: 1001 GID: 1001 # Authentication options OG_DISABLE_REGISTRATION: false OG_OAUTH_GITHUB_ENABLED: true |
For a complete list of configuration options, check the official documentation.
Managing Your OpenGist Deployment
Portainer makes it easy to:
- View logs: Navigate to Containers → OpenGist → Logs
- Update the container: Go to Stacks → OpenGist → Editor, update the image tag, click “Update the stack”
- Monitor resources: Check real-time CPU, memory, and network usage