main 3d2ccc4

Self-hosted ephemeral media sharing with auto-transcoding and rich embeds.


Upload videos, audio, and images and get shareable links that expire. Compatible MP4 H.264/AAC videos are published directly; other video sources are encoded to H.264/AAC in the browser when WebCodecs support is complete, with an automatic FFmpeg server fallback. The original is optional: direct and fallback paths reuse the uploaded source, while a client-encoded MP4 keeps the selected source as a separate asset when requested. Shared links render with Open Graph and Twitter Card tags for previews in chat apps and social media.

Single-user, single-binary, single Docker container. SQLite for storage, FFmpeg for conversion.

Deploy

Sharm needs to run on a server with a public domain for share links and embeds to work.

Create a docker-compose.yml on your server:

services:
  sharm:
    image: ghcr.io/bnema/sharm:latest
    ports:
      - "7890:7890"
    environment:
      - DOMAIN=sharm.example.com
      - BEHIND_PROXY=true
    volumes:
      - sharm-data:/data
    restart: unless-stopped

volumes:
  sharm-data:
docker compose up -d

Point your reverse proxy at port 7890 and open https://sharm.example.com. On first launch, create the account from the deployed URL. Only one user can be registered. When BEHIND_PROXY=true, Sharm only trusts forwarded client headers from the networks listed in TRUSTED_PROXY_CIDRS.

Configuration

Variable Default Description
DOMAIN localhost:7890 Domain used in share URLs and embeds
PORT 7890 HTTP port
MAX_UPLOAD_SIZE_MB 500 Max upload size in MB
DEFAULT_RETENTION_DAYS 7 Days before shared links expire
DATA_DIR /data Where uploads, converted files, and the DB live
BEHIND_PROXY false Set to true when running behind a reverse proxy
TRUSTED_PROXY_CIDRS 127.0.0.0/8,::1/128 Comma-separated networks allowed to supply X-Real-IP or X-Forwarded-For
SECRET_KEY (auto-generated) Key for signing session tokens. Generated and persisted to DATA_DIR/.secret_key if not set

Reverse Proxy

Nginx example:

server {
    listen 80;
    server_name sharm.example.com;

    location / {
        proxy_pass http://localhost:7890;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Development

Requires Go 1.26+, Node.js 24+, FFmpeg, and the code generation tools sqlc, templ, and mockery. make build installs the pinned browser dependencies and bundles the client video Worker locally.

cp .env.example .env
make deps generate   # download deps, generate code
make dev             # run with hot reload (requires air)

Or build and run manually:

make build
make run

Run tests:

make test
make test-race

Run the complete browser upload flow in disposable Docker volumes:

make test-e2e

The end-to-end test generates H.264/AAC and WebM fixtures with FFmpeg. Playwright verifies direct upload, runtime WebCodecs capability selection, client H.264 encoding when the browser exposes an encoder, and the automatic server fallback otherwise. The test removes its containers, volumes, generated secret key, and fixtures afterward.

Client encoding runs in a same-origin Web Worker and produces a fast-start MP4 with H.264 video and AAC audio. Its input-size limit follows the deployment's MAX_UPLOAD_SIZE_MB setting, duration follows the server's six-hour media limit, and output is bounded to 1920×1920 with roughly 1080p pixel count. The server remains authoritative: every result is inspected with ffprobe, and any unsupported browser, input codec, resource limit, or runtime failure falls back to server-side FFmpeg.

make help lists all available targets.

Project Structure

internal/
  domain/       Core types: Media, User, Job, Probe
  port/         Interfaces (MediaStore, MediaConverter, JobQueue, etc.)
  adapter/
    http/       Handlers, middleware, templates, rate limiting
    storage/    SQLite implementation
    converter/  FFmpeg implementation
  service/      Business logic (MediaService, AuthService, Worker pool)

Follows hexagonal architecture. Domain and ports have no dependency on adapters. Swap SQLite for Postgres, or FFmpeg for another converter, without touching business logic.

Docker Build

# current platform
make docker-build

# multi-platform (amd64 + arm64) and push
make docker-buildx-push

Set REGISTRY in .env or as an env var (defaults to ghcr.io/bnema).

Contributing

make deps generate   # set up
make dev             # hack on it
make check           # fmt + vet + test before submitting

Mocks are auto-generated from .mockery.yml. Do not edit them by hand.

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. On pages with a side panel: into the panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit; in a file, click a line number to select it, shift-click for a range
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 2

Tags 14

↑↓ moveenter openesc close