Sign inSign up

dockette/viewdoc

Sponsored OSS

By dockette

โ€ขUpdated about 2 months ago

Image
0

5.9K

dockette/viewdoc repository overview

โ Dockette / Viewdoc

๐Ÿ“„ ๐ŸŽž๏ธ ๐Ÿ–ผ๏ธ Browser-embeddable remote viewer for PDFs, office docs, audio, video, and images. A small Go control-center fronts a fixed pool of Kasmโ  / LinuxServer Webtopโ  desktop containers โ€” pass ?url=... and the file opens in the right app inside an iframe.

๐Ÿ•น f3l1x.ioโ  | ๐Ÿ’ป f3l1xโ  | ๐Ÿฆ @xf3l1xโ 

GitHub Actions Docker Hub pulls GitHub Sponsors Support/Discussions


Kasm desktop viewer Webtop desktop viewer


โ Why

Embedding rich file viewers in your product is a thousand papercuts: PDF.js for some types, an office viewer for others, a media player for the rest โ€” each with its own quirks, sandbox story, and asset list. Viewdoc skips it. Open a real desktop in a tab, let the desktop open the file with its native app, and stream the pixels back. One iframe, every file type.

flowchart LR
    browser["Browser<br/>localhost:8080/?url=โ€ฆ"]

    subgraph cc["control-center (Go)"]
        proxy["reverse-proxy<br/>/slot/{i}/*"]
        api["POST /api/slot/{i}/params"]
    end

    subgraph viewer["viewer-i (Kasm / Webtop)"]
        novnc["KasmVNC :6901<br/>or Webtop :3000"]
        sidecar["sidecar :7000"]
        hook["viewdoc.sh"]
        apps["chromium ยท vlc ยท xdg-open"]
    end

    browser -->|iframe src=/slot/i/| proxy
    browser -->|"{url:โ€ฆ}"| api
    proxy -->|HTTP + WS| novnc
    api -->|POST /params| sidecar
    sidecar -->|fork| hook
    hook -->|dispatch by ext| apps

โ Quickstart

docker compose build
docker compose up -d

open https://localhost:8443/                                   # iframe + URL bar + slot tabs
open "https://localhost:8443/?url=https://example.com/x.pdf"   # auto-opens in slot 0
curl -sk https://localhost:8443/healthz                        # {"ready":4,"total":4}

Default pool (VIEWER_SLOTS): 2ร— Kasm + 2ร— Webtop.

โ File Types

The dispatcher routes by extension:

GroupExtensionsOpens with
Mediamp4, mkv, webm, mov, avi, mpeg, mpg, m4v, 3gp, 3g2, ts, mts, m2ts, vob, wmv, asf, divx, ogv, mp3, wav, flac, ogg, m4a, aac, opus, mka, wma, aiff, ape, midVLC
Web / docspdf, html, htmChromium (new window)
Imagespng, jpg, jpeg, gif, webp, svg, bmpChromium (new window)
Officedoc, docx, odt, rtf, xls, xlsx, ods, csv, ppt, pptx, odpLibreOffice
Archiveszip, 7z, rar, tar, gz, tgz, bz2, tbz2, xz, txzXarchiver (downloaded locally first)
EmailemlClaws Mail (downloaded locally first)
Capturespcap, pcapng, capWireshark (downloaded locally first)
Otheranything elsexdg-open (desktop default)

โ Services

The system exposes two HTTP services. The control-center is the public entrypoint; the sidecar runs inside every viewer image on the compose network.

โ Control Center โ€” :8080 (plain), :8443 (TLS)
โ Endpoints
MethodPathPurpose
GET/UI: iframe + URL bar + slot tabs
GET/healthz{ready, total} reachability summary
GET/api/slotsslot table with per-slot reachability
POST/api/slot/{i}/paramsforwards {params:{url,โ€ฆ}} to slot i
ANY/slot/{i}/*reverse-proxy โ†’ <slot[i]>:port (HTTP + WS)
GET/static/*embedded UI assets
โ Environment
VarDefaultPurpose
LISTEN_ADDR:8080Plain-HTTP bind address
TLS_ADDR(unset)If set, also bind TLS (self-signed cert)
VIEWER_SLOTSviewer-1,viewer-2,viewer-3Comma-separated slot list. See Slot configuration below for the full grammar.
VIEWER_KASM_DEFAULT_PORT6901VNC port used for bare entries and the kasm:// pseudo-scheme.
VIEWER_WEBTOP_DEFAULT_PORT3000VNC port used for the webtop:// pseudo-scheme.
VIEWER_SIDECAR_DEFAULT_PORT7000Sidecar port used when the sidecar half of a slot entry is omitted (or specifies no port).
โ Slot configuration

Each entry in VIEWER_SLOTS has the shape <vnc>[|<sidecar>]. The pipe is optional โ€” omit it when the sidecar lives on the same host as the VNC endpoint (the compose default).

VNC half โ€” accepted forms (port falls back to VIEWER_KASM_DEFAULT_PORT, except webtop:// which uses VIEWER_WEBTOP_DEFAULT_PORT):

InputParsed as
viewer-1http://viewer-1:6901
viewer-1:9000http://viewer-1:9000
http://viewer-1http://viewer-1:6901
https://viewer-1https://viewer-1:6901
https://viewer-1:6901https://viewer-1:6901 (canonical Kasm)
kasm://viewer-1https://viewer-1:6901 (kasm pseudo-scheme = https+kasm)
kasm://viewer-1:9000https://viewer-1:9000
webtop://viewer-1http://viewer-1:3000 (webtop pseudo-scheme = http+webtop)
webtop://viewer-1:9001http://viewer-1:9001

Sidecar half โ€” accepted forms (port falls back to VIEWER_SIDECAR_DEFAULT_PORT; kasm:// / webtop:// are not allowed here):

InputParsed as
(omitted)http://<vnc-host>:7000
viewer-1http://viewer-1:7000
viewer-1:7100http://viewer-1:7100
http://other-host:7100http://other-host:7100
https://sidecar-1:7443https://sidecar-1:7443

Worked examples

# Compose (DNS-friendly, sidecar implicit on same host:7000)
VIEWER_SLOTS="kasm://viewer-kasm-1,kasm://viewer-kasm-2,webtop://viewer-webtop-1,webtop://viewer-webtop-2"

# Equivalent fully-explicit form
VIEWER_SLOTS="https://viewer-kasm-1:6901,https://viewer-kasm-2:6901,http://viewer-webtop-1:3000,http://viewer-webtop-2:3000"

# Nomad / dynamic ports โ€” VNC and sidecar published on different host ports
VIEWER_SLOTS="kasm://10.0.0.5:23456|10.0.0.5:34567,kasm://10.0.0.6:11111|10.0.0.6:22222"

# Override the pool-wide defaults so bare entries become 7901 / 3100 / 7900
VIEWER_KASM_DEFAULT_PORT=7901
VIEWER_WEBTOP_DEFAULT_PORT=3100
VIEWER_SIDECAR_DEFAULT_PORT=7900
VIEWER_SLOTS="kasm://node-1,webtop://node-2"
# โ†’ slot 0 vnc=https://node-1:7901 sidecar=http://node-1:7900
# โ†’ slot 1 vnc=http://node-2:3100  sidecar=http://node-2:7900
โ Sidecar โ€” :7000 (inside each viewer)
โ Endpoints
MethodPathPurpose
GET/healthz{"ok": true}
POST/paramsvalidate + atomically write /tmp/viewdoc.{json,env}, fork viewdoc.sh
โ Environment
VarDefaultPurpose
LISTEN_ADDR:7000Sidecar bind address (fixed by compose convention)

โ Maintenance

See how to contributeโ  to this package. Consider to supportโ  f3l1x. Thank you for using this package.

Tag summary

Content type

Image

Digest

sha256:94dca71d0โ€ฆ

Size

3.6 GB

Last updated

about 2 months ago

docker pull dockette/viewdoc:viewer-kasm

This week's pulls

Pulls:

19

Last week