Skip to content

Deploying a Picoshare App

Introduction

Picoshare is a lightweight self-hosted file sharing service written in Go. Deploying Picoshare with a Dockerfile on Klutch.sh provides reproducible builds, managed secrets, and persistent storage for uploads—all configured from klutch.sh/app. This guide covers installation, repository prep, a production-ready Dockerfile, deployment steps, Nixpacks overrides, sample API usage, and production tips.


Prerequisites

  • A Klutch.sh account (sign up)
  • A GitHub repository containing your Picoshare Dockerfile (GitHub is the only supported git source)
  • Storage sizing for uploaded files and logs

For onboarding, see the Quick Start.


Architecture and ports

  • Picoshare serves HTTP on internal port 3000; choose HTTP traffic.
  • Persistent storage is required for file uploads and metadata.

Repository layout

picoshare/
├── Dockerfile # Must be at repo root for auto-detection
└── README.md

Keep secrets out of Git; store them in Klutch.sh environment variables.


Installation (local) and starter commands

Validate locally before pushing to GitHub:

Terminal window
docker build -t picoshare-local .
docker run -p 3000:3000 \
-e PICO_PASSWORD=changeme \
picoshare-local

Dockerfile for Picoshare (production-ready)

Place this Dockerfile at the repo root; Klutch.sh auto-detects it (no Docker selection in the UI):

FROM mtlynch/picoshare:latest
ENV PORT=3000
EXPOSE 3000
CMD ["/picoshare"]

Notes:

  • Pin the image tag (e.g., mtlynch/picoshare:v0.x) for stability; update intentionally.
  • The binary uses PICO_* environment variables for configuration.

Environment variables (Klutch.sh)

Set these in Klutch.sh before deploying:

  • PORT=3000
  • PICO_PASSWORD=<strong-admin-password>
  • Optional storage override: PICO_DATA_DIR=/data
  • Optional base URL: PICO_BASE_URL=https://example-app.klutch.sh

If you deploy without the Dockerfile and need Nixpacks overrides (rare for Go binaries):

  • NIXPACKS_START_CMD=/picoshare

Attach persistent volumes

In Klutch.sh storage settings, add mount paths and sizes (no names required):

  • /data — uploaded files and metadata.
  • /var/log/picoshare — optional logs if written to disk.

Ensure these paths are writable inside the container.


Deploy Picoshare on Klutch.sh (Dockerfile workflow)

  1. Push your repository—with the Dockerfile at the root—to GitHub.
  2. Open klutch.sh/app, create a project, and add an app.
  3. Select HTTP traffic and set the internal port to 3000.
  4. Add the environment variables above, including a strong PICO_PASSWORD.
  5. Attach a persistent volume for /data (and /var/log/picoshare if used) sized for your uploads and logs.
  6. Deploy. Your Picoshare instance will be reachable at https://example-app.klutch.sh; attach a custom domain if desired.

Sample API usage

Upload a file:

Terminal window
curl -X POST "https://example-app.klutch.sh/api/upload" \
-H "Authorization: Bearer <PICO_PASSWORD>" \
-F "file=@/path/to/file.txt"

List files:

Terminal window
curl -X GET "https://example-app.klutch.sh/api/files" \
-H "Authorization: Bearer <PICO_PASSWORD>"

Health checks and production tips

  • Add an HTTP probe to / or /api/files for readiness (requires auth if locked down).
  • Enforce HTTPS at the edge; forward internally to port 3000.
  • Keep PICO_PASSWORD in Klutch.sh secrets; rotate it regularly.
  • Monitor /data usage; resize before it fills.
  • Pin image versions and test upgrades in staging; back up data before updates.

Picoshare on Klutch.sh combines reproducible Docker builds with managed secrets, persistent storage, and flexible HTTP/TCP routing. With the Dockerfile at the repo root, port 3000 configured, and storage persisted, you can deliver lightweight, secure file sharing without extra YAML or workflow overhead.