Skip to content

Deploying SnyPy

Introduction

SnyPy is a self-hosted code snippet manager designed for developers who want to organize and access their frequently used code snippets. Instead of searching through old projects or bookmarking Gists, SnyPy provides a centralized place for all your useful code fragments with syntax highlighting, tagging, and search capabilities.

Every developer accumulates useful code patterns, configuration snippets, and reusable functions over time. SnyPy helps you capture and organize this knowledge, making it instantly accessible when you need it.

Key features of SnyPy include:

  • Syntax Highlighting: Support for dozens of programming languages
  • Tag Organization: Flexible tagging for easy categorization
  • Full-Text Search: Quickly find any snippet in your collection
  • Team Sharing: Share snippets with team members
  • REST API: Programmatic access for integrations
  • Keyboard Shortcuts: Fast navigation for power users
  • Markdown Support: Rich descriptions with markdown formatting
  • Language Detection: Automatic language identification
  • Copy to Clipboard: One-click snippet copying
  • Self-Hosted: Complete control over your code collection
  • Open Source: Transparent and customizable

This guide walks through deploying SnyPy on Klutch.sh using Docker.

Why Deploy SnyPy on Klutch.sh

Deploying SnyPy on Klutch.sh provides several advantages:

Simplified Deployment: Klutch.sh handles the build and deployment automatically.

Access Anywhere: Reach your snippets from any device with internet access.

HTTPS by Default: Secure access to your code collection.

Persistent Storage: Your snippets survive restarts and redeployments.

Team Collaboration: Share a snippet library with your team.

Always Available: 24/7 access to your code snippets.

Prerequisites

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

  • A Klutch.sh account
  • A GitHub account with a repository for your configuration
  • A PostgreSQL database
  • Basic familiarity with Docker
  • (Optional) A custom domain

Deploying SnyPy on Klutch.sh

    Create a GitHub Repository

    Create a new GitHub repository for your SnyPy deployment configuration.

    Create Your Dockerfile

    Create a Dockerfile:

    FROM python:3.11-slim
    WORKDIR /app
    RUN apt-get update && apt-get install -y \
    git \
    gcc \
    libpq-dev \
    && rm -rf /var/lib/apt/lists/*
    RUN git clone https://github.com/snypy/snypy-backend.git .
    RUN pip install --no-cache-dir -r requirements.txt
    ENV DJANGO_SETTINGS_MODULE=snypy.settings.production
    ENV DATABASE_URL=${DATABASE_URL}
    ENV SECRET_KEY=${SECRET_KEY}
    ENV ALLOWED_HOSTS=${ALLOWED_HOSTS}
    EXPOSE 8000
    CMD ["gunicorn", "--bind", "0.0.0.0:8000", "snypy.wsgi:application"]

    Push Your Repository to GitHub

    Commit and push your Dockerfile.

    Create a PostgreSQL Database

    Set up a PostgreSQL database for SnyPy.

    Generate a Secret Key

    Create a secure Django secret key for your deployment.

    Create a New Project on Klutch.sh

    Navigate to the Klutch.sh dashboard and create a new project.

    Create a New App

    Create a new app and connect your GitHub repository.

    Configure Environment Variables

    Add the following environment variables:

    VariableValue
    DATABASE_URLpostgresql://user:pass@host/dbname
    SECRET_KEYYour generated secret key
    ALLOWED_HOSTSYour app domain

    Configure HTTP Settings

    Set the traffic type to HTTP and configure the internal port to 8000.

    Attach Persistent Storage

    Add a persistent volume for media files:

    Mount PathRecommended SizePurpose
    /app/media1 GBUploaded files

    Deploy Your Application

    Click Deploy to start the build process.

    Run Migrations

    After deployment, run database migrations to initialize the schema.

    Create Admin User

    Create a superuser account for administration.

    Access SnyPy

    Navigate to your app’s URL and start adding snippets.

Using SnyPy

After deployment, you can:

  1. Create Snippets: Add new code snippets with syntax highlighting
  2. Organize with Tags: Apply tags to categorize your snippets
  3. Search: Use full-text search to find any snippet
  4. Share: Collaborate with team members on snippet collections

Additional Resources

Conclusion

Deploying SnyPy on Klutch.sh gives you a dedicated place for your code snippets accessible from anywhere. Stop searching through old projects and bookmarks—organize your code knowledge in one searchable, shareable location.

Whether you’re a solo developer or part of a team, SnyPy helps you build and maintain a valuable library of reusable code.