Skip to content

Deploying Gokapi

Introduction

Gokapi is a lightweight, self-hosted file sharing server that allows you to share files with expiring links. Similar to the discontinued Firefox Send, Gokapi lets you upload files and share them with customizable download limits and expiration dates, ensuring your shared files don’t remain accessible forever.

Built with Go for excellent performance and minimal resource usage, Gokapi runs as a single binary with no external dependencies. The server supports multiple storage backends including local storage, AWS S3, and Backblaze B2, making it flexible for various deployment scenarios.

Key highlights of Gokapi:

  • Expiring Links: Files automatically expire after a set time or number of downloads
  • Download Limits: Set maximum download counts for each shared file
  • Password Protection: Optionally encrypt files with passwords
  • Multiple Storage Backends: Support for local storage, AWS S3, and Backblaze B2
  • Admin-Only Uploads: Only administrators can upload files (no public upload)
  • End-to-End Encryption: Optional client-side encryption for sensitive files
  • API Access: Full API for automation and integration
  • Single Binary: No dependencies, easy deployment
  • Lightweight: Minimal resource usage
  • 100% Open Source: Licensed under AGPL-3.0

This guide walks through deploying Gokapi on Klutch.sh using Docker, configuring storage options, and sharing files securely.

Why Deploy Gokapi on Klutch.sh

Deploying Gokapi on Klutch.sh provides several advantages for file sharing:

Simplified Deployment: Klutch.sh automatically detects your Dockerfile and builds Gokapi without complex orchestration. Push to GitHub and your file sharing server deploys automatically.

Persistent Storage: Attach persistent volumes for your uploaded files and database. Files survive container restarts.

HTTPS by Default: Klutch.sh provides automatic SSL certificates for secure file transfers.

GitHub Integration: Connect your configuration repository directly from GitHub. Updates trigger automatic redeployments.

Scalable Resources: Allocate CPU and memory based on expected file sizes and traffic.

Custom Domains: Assign a custom domain for professional file sharing links.

Always-On Availability: Your file sharing server remains accessible 24/7.

Prerequisites

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

  • A Klutch.sh account
  • A GitHub account with a repository for your Gokapi configuration
  • Basic familiarity with Docker and containerization concepts
  • (Optional) AWS S3 or Backblaze B2 credentials for cloud storage

Understanding Gokapi Architecture

Gokapi is designed for simplicity:

Go Backend: Written in Go for performance and a single binary deployment.

SQLite Database: Stores file metadata, download counts, and expiration information.

Storage Options: Supports local filesystem, AWS S3, and Backblaze B2.

Admin Interface: Web-based interface for uploading and managing files.

API: RESTful API for automation and external integrations.

Preparing Your Repository

To deploy Gokapi on Klutch.sh, create a GitHub repository containing your Dockerfile.

Repository Structure

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

Creating the Dockerfile

Create a Dockerfile in the root of your repository:

FROM f0rc3/gokapi:latest
# Set environment variables
ENV GOKAPI_PORT=53842
ENV GOKAPI_EXTERNAL_URL=${GOKAPI_EXTERNAL_URL}
# Create data directory
RUN mkdir -p /app/data /app/data/files
# Expose the web interface port
EXPOSE 53842
# The base image includes the default entrypoint

Advanced Dockerfile with S3 Storage

For cloud storage backends:

FROM f0rc3/gokapi:latest
# Application Configuration
ENV GOKAPI_PORT=53842
ENV GOKAPI_EXTERNAL_URL=${GOKAPI_EXTERNAL_URL}
ENV GOKAPI_CONFIG_DIR=/app/data
ENV GOKAPI_DATA_DIR=/app/data
# AWS S3 Configuration (optional)
ENV AWS_REGION=${AWS_REGION}
ENV AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
ENV AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
ENV AWS_BUCKET=${AWS_BUCKET}
# Create data directory
RUN mkdir -p /app/data
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:53842/ || exit 1
# Expose the web interface port
EXPOSE 53842

Creating the .dockerignore File

Create a .dockerignore file:

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

Environment Variables Reference

VariableRequiredDefaultDescription
GOKAPI_PORTNo53842Port to listen on
GOKAPI_EXTERNAL_URLYes-External URL for share links
GOKAPI_CONFIG_DIRNo./dataDirectory for configuration
GOKAPI_DATA_DIRNo./dataDirectory for uploaded files
AWS_REGIONNo*-AWS region for S3 storage
AWS_ACCESS_KEY_IDNo*-AWS access key
AWS_SECRET_ACCESS_KEYNo*-AWS secret key
AWS_BUCKETNo*-S3 bucket name

*Required if using S3 storage

Deploying Gokapi on Klutch.sh

Once your repository is prepared, follow these steps to deploy Gokapi:

    Push Your Repository to GitHub

    Initialize your repository and push to GitHub:

    Terminal window
    git init
    git add Dockerfile .dockerignore README.md
    git commit -m "Initial Gokapi deployment configuration"
    git remote add origin https://github.com/yourusername/gokapi-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. Give it a descriptive name like “gokapi” or “file-share”.

    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 Gokapi Dockerfile.

    Configure HTTP Traffic

    Gokapi serves its web interface over HTTP. In the deployment settings:

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

    Set Environment Variables

    In the environment variables section, add:

    VariableValue
    GOKAPI_EXTERNAL_URLhttps://your-app-name.klutch.sh

    For S3 storage, add your AWS credentials.

    Attach Persistent Volumes

    Persistent storage is essential for Gokapi. Add the following volume:

    Mount PathRecommended SizePurpose
    /app/data50 GBConfiguration, database, and uploaded files

    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 Gokapi container
    • Provision an HTTPS certificate

    Complete Initial Setup

    On first launch, Gokapi will guide you through initial setup:

    1. Access https://your-app-name.klutch.sh
    2. Create your admin username and password
    3. Configure storage settings (local or cloud)
    4. Complete the setup wizard

    Access Gokapi

    Once setup completes, access your Gokapi admin panel at https://your-app-name.klutch.sh/admin.

Using Gokapi

Uploading Files

To upload a file:

  1. Log in to the admin panel at /admin
  2. Click Upload File or drag and drop
  3. Configure sharing options:
    • Expiry Time: How long the link remains valid
    • Download Limit: Maximum number of downloads
    • Password: Optional password protection
  4. Click Upload
  5. Copy the generated share link

Sharing Options

Configure how files are shared:

OptionDescription
Expiry DaysNumber of days until the link expires
DownloadsMaximum download count (0 = unlimited)
PasswordOptional password for download access
UnlimitedOverride to allow unlimited time/downloads

Managing Files

View and manage uploaded files:

  1. Navigate to the admin panel
  2. See all uploaded files with:
    • Filename
    • Upload date
    • Downloads remaining
    • Expiry date
  3. Delete files manually if needed
  4. Copy share links for existing files

Password-Protected Files

For sensitive files:

  1. Enable password during upload
  2. Enter a strong password
  3. Share the password separately from the link
  4. Recipients must enter the password to download

API Integration

Gokapi provides an API for automation:

Upload via API

Terminal window
curl -X POST "https://your-app-name.klutch.sh/api/files/add" \
-H "apikey: YOUR_API_KEY" \
-F "file=@/path/to/file.pdf" \
-F "allowedDownloads=5" \
-F "expiryDays=7"

List Files

Terminal window
curl "https://your-app-name.klutch.sh/api/files/list" \
-H "apikey: YOUR_API_KEY"

Delete a File

Terminal window
curl -X DELETE "https://your-app-name.klutch.sh/api/files/delete/FILE_ID" \
-H "apikey: YOUR_API_KEY"

Getting an API Key

  1. Log in to the admin panel
  2. Navigate to Settings
  3. Generate or view your API key

Storage Backends

Local Storage

Default option, stores files on the persistent volume:

GOKAPI_DATA_DIR=/app/data

AWS S3

Store files in Amazon S3:

AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_BUCKET=your-bucket-name

Backblaze B2

Store files in Backblaze B2 (using S3-compatible API):

AWS_REGION=us-west-002
AWS_ACCESS_KEY_ID=your_b2_key_id
AWS_SECRET_ACCESS_KEY=your_b2_application_key
AWS_BUCKET=your-bucket-name
# Set endpoint to B2's S3-compatible URL

Security Considerations

Access Control

  • Strong Admin Password: Use a strong, unique password
  • API Key Security: Treat API keys as sensitive credentials
  • HTTPS Only: Always use HTTPS (automatic on Klutch.sh)

File Security

  • Password Protection: Use passwords for sensitive files
  • Download Limits: Set appropriate limits to prevent abuse
  • Expiration: Always set reasonable expiration times
  • No Public Upload: Only admins can upload (by design)

Data Protection

  • Regular Backups: Back up the data directory
  • Encryption at Rest: Consider S3 bucket encryption
  • Access Logs: Monitor access patterns for anomalies

Troubleshooting Common Issues

Upload Failures

Symptoms: Files fail to upload.

Solutions:

  • Check file size limits
  • Verify disk space on persistent volume
  • Check storage backend connectivity (S3)
  • Review application logs for errors

Symptoms: Recipients cannot access files.

Solutions:

  • Verify GOKAPI_EXTERNAL_URL is set correctly
  • Check file hasn’t expired
  • Verify download limit hasn’t been reached
  • Ensure HTTPS certificate is valid

Admin Login Issues

Symptoms: Cannot access admin panel.

Solutions:

  • Verify you’re using the correct URL (/admin)
  • Check credentials are correct
  • Clear browser cache/cookies
  • Review application logs

S3 Connection Problems

Symptoms: Cannot connect to S3 storage.

Solutions:

  • Verify AWS credentials are correct
  • Check bucket exists and is accessible
  • Verify region setting matches bucket region
  • Test credentials with AWS CLI

Additional Resources

Conclusion

Deploying Gokapi on Klutch.sh gives you a lightweight, secure file sharing server with automatic expiration and download limits. The combination of Gokapi’s simplicity and Klutch.sh’s deployment ease means you can share files securely without complex infrastructure.

With support for multiple storage backends, password protection, and API integration, Gokapi provides enterprise-grade file sharing in a minimal package. Whether you’re sharing documents with clients or distributing files to team members, Gokapi on Klutch.sh delivers reliable, controlled file sharing on your terms.