Sign inSign up

ericwang2006/photosilo

By ericwang2006

Updated 3 days ago

Self-hosted, mobile-first photo/video album. | 自托管、移动端友好的照片/视频相册。

Image
Content management system
Databases & storage
0

4.3K

ericwang2006/photosilo repository overview

PhotoSilo — Self-hosted Photo / Video Album

PhotoSilo is a mobile-first, self-hosted photo & video album built in Go, with a front-end that mimics the phone gallery experience. One binary, no complex dependencies.

Features
  • Phone-gallery browsing: thumbnail grid with infinite scroll / pagination; folder / list views, name / shooting-date sorting (folders always first)
  • Favorites (收藏夹): long-press or right-click any folder / file, or tap the star in the viewer, to favorite it; favorites are stored per-user in the SQLite favorites DB and appear in the virtual 「收藏夹」folder on the home screen
  • High-performance thumbnails: reads embedded EXIF thumbnails first; generates and caches the rest as BLOBs in a single SQLite database with automatic time/capacity-based cleanup — no clutter of tiny files
  • Video support: bundled ffmpeg generates video thumbnails automatically
  • Full EXIF info: date taken, camera, lens, aperture, shutter, ISO, GPS, etc.
  • Fullscreen viewer: touch swipe / keyboard arrows to switch
  • Multi-user & auth: bcrypt hashes, HttpOnly + SameSite session cookie, login required
  • Pure Go, no CGO: single binary, low memory footprint — great for home NAS / Raspberry Pi
  • Multi-arch: linux/amd64 & linux/arm64
Quick Start
docker run -d -p 8080:8080 \
  -v /path/to/photos:/data \
  ericwang2006/photosilo

A default config is generated on first start (account admin / admin). Open http://<host>:8080 in your browser.

Note

The auto-generated config sets `photo_dir` to `"."`, which resolves to `/app` inside the container — so the command above browses `/app`, **not** `/data`. To serve the photos you mounted at `/data`, add the persistence setup below and set `"photo_dir": "/data"` in the config.

By default the thumbnail cache, favorites and the config all live inside the container and are lost when the container is recreated:

  • thumbnail cache → /tmp/photosilo-thumbs-<hash>/thumbs.db
  • favorites → /tmp/photosilo-favs-<hash>/favs.db
  • config → /app/photosilo.json

First generate a valid config file on the host (the image auto-creates one with admin/admin — just print it):

docker run --rm ericwang2006/photosilo cat /app/photosilo.json > /path/to/config.json

Then point photo_dir at /data and give the thumbnail / favorites DBs persistent paths:

{
  "photo_dir": "/data",
  "port": 8080,
  "thumb_db": "/thumb/thumbs.db",
  "thumb_max_age_days": 30,
  "thumb_max_size_gb": 10,
  "fav_db": "/thumb/favs.db",
  "users": [
    { "username": "admin", "password_hash": "<keep it from the generated file, don't hand-edit>", "is_admin": true }
  ]
}

Run:

docker run -d -p 8080:8080 \
  -v /path/to/photos:/data \
  -v /path/to/cache:/thumb \
  -v /path/to/config.json:/app/photosilo.json \
  ericwang2006/photosilo

Now thumbnails, favorites and the config survive container restarts / re-creation.

Note

Because the config file now exists, the container will **not** auto-run `init` anymore — the config must contain at least one valid user (the `password_hash` from the generated file is a proper bcrypt hash, keep it). To add more users later, run `photosilo adduser` inside the running container (config reloads automatically, no restart needed).

中文说明

PhotoSilo — 自托管的照片 / 视频相册

PhotoSilo 是一款移动端友好的自托管照片 / 视频相册程序,采用 Go 编写,前端仿手机相册交互。无需任何复杂依赖,一个二进制即可运行。

核心特性
  • 手机相册式浏览:缩略图网格 + 触底分页加载;支持文件夹 / 列表视图,按文件名 / 拍摄日期排序(文件夹始终在前)
  • 收藏夹:长按或右键文件夹 / 文件、或在查看器里点星标即可收藏;收藏按用户保存在服务端 SQLite 收藏数据库中,首页虚拟「收藏夹」文件夹可快速直达
  • 高性能缩略图:优先读取照片内嵌 EXIF 缩略图;缺失时服务端生成并以 BLOB 形式缓存在单个 SQLite 数据库中,自动按时间 / 容量清理,不产生海量小文件
  • 视频支持:镜像内置 ffmpeg,自动生成视频缩略图
  • 完整 EXIF 查看:拍摄时间、相机、镜头、光圈、快门、ISO、GPS 等
  • 全屏查看器:触控滑动 / 键盘方向键切换
  • 多用户 + 登录鉴权:bcrypt 密码哈希,会话 Cookie(HttpOnly + SameSite),访问需登录
  • 纯 Go + 无 CGO:单二进制、低内存占用,适合家用 NAS / 树莓派
  • 多架构:支持 linux/amd64linux/arm64
快速开始
docker run -d -p 8080:8080 \
  -v /path/to/photos:/data \
  ericwang2006/photosilo

首次启动自动生成配置,默认账号 admin / admin,浏览器访问 http://<主机>:8080 即可。

Note

自动生成的配置 `photo_dir` 为 `"."`,即容器内的 `/app`——上面这条命令实际浏览的是 `/app`,**并不是** `/data`。要让挂载到 `/data` 的照片生效,请按下面的「持久化(推荐)」方式设置 `"photo_dir": "/data"`。
持久化(推荐)

缩略图缓存、收藏夹和配置默认都在容器内部,容器一旦重建就会丢失:

  • 缩略图缓存 → 容器内 /tmp/photosilo-thumbs-<hash>/thumbs.db
  • 收藏夹 → 容器内 /tmp/photosilo-favs-<hash>/favs.db
  • 配置 → 容器内 /app/photosilo.json

先在宿主机生成一份有效配置(镜像会自动生成含 admin/admin 的配置,直接打印出来即可):

docker run --rm ericwang2006/photosilo cat /app/photosilo.json > /path/to/config.json

然后把 photo_dir 指向 /data,并为缩略图 / 收藏数据库指定持久化路径:

{
  "photo_dir": "/data",
  "port": 8080,
  "thumb_db": "/thumb/thumbs.db",
  "thumb_max_age_days": 30,
  "thumb_max_size_gb": 10,
  "fav_db": "/thumb/favs.db",
  "users": [
    { "username": "admin", "password_hash": "<保持生成文件里的内容,不要手改>", "is_admin": true }
  ]
}

启动容器:

docker run -d -p 8080:8080 \
  -v /path/to/photos:/data \
  -v /path/to/cache:/thumb \
  -v /path/to/config.json:/app/photosilo.json \
  ericwang2006/photosilo

这样缩略图缓存、收藏夹和配置都能在容器重启 / 重建后保留。

Note

因为配置文件已存在,容器**不会再自动执行 `init`**——配置里必须包含至少一个有效用户(生成的 `password_hash` 是合法的 bcrypt 哈希,保留即可)。之后要加用户,在运行中的容器里执行 `photosilo adduser` 即可(配置会自动重载,无需重启)。

Tag summary

Content type

Image

Digest

sha256:aa4b4c4b1

Size

53.7 MB

Last updated

3 days ago

docker pull ericwang2006/photosilo