foldergram/foldergram
关于
可自行部署的照片和视频图库应用,按文件夹组织内容,风格类似 Instagram。
设计与媒体可以做什么
- Instagram-Inspired UI: Enjoy a familiar feed layout, dedicated app folders (profiles), and a media viewer.
- Home feed with Recent, Rediscover, and Random modes.
- A dedicated /reels route with a video-only queue. Settings can default it to Recommended, Recent, or Random.
- A top rail that shows Moments when capture-date coverage is strong, or Highlights when it is not.
实测星标增长
- 24小时
- +3
- 7天
- +5
- 15天
- +20
- 1个月
- +29
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文
Foldergram
Local-first photo and video gallery for your folders, with Instagram-inspired browsing and optional read-only Immich integration.
Website • Documentation • Live Demo • Features • Installation • Configuration • Tech Stack • Contributing
Try the public demo: demo.foldergram.app
Foldergram brings your photos and videos together in a self-hosted gallery with a familiar feed, folder profiles, and a media viewer. Browse multiple local galleries, connect Immich, or use both, with originals kept where they are.
Multiple local galleries
Keep photos and videos across several folders or drives and browse them together in Foldergram. Manage each location in Settings → Sources, with your existing gallery included automatically and originals kept in place. Set up local galleries →
Immich integration
Connect your Immich folders and albums to enjoy Foldergram's browsing experience alongside local media, or use it with Immich alone. The connection is read-only, and your Foldergram likes and saved collections stay local. Connect Immich →
Features
- Instagram-Inspired UI: Enjoy a familiar feed layout, dedicated app folders (profiles), and a media viewer.
- Home feed with
Recent,Rediscover, andRandommodes. - A dedicated
/reelsroute with a video-only queue. Settings can default it toRecommended,Recent, orRandom. - A top rail that shows
Momentswhen capture-date coverage is strong, orHighlightswhen it is not. - Library browsing with App Folder search, sorting, and delete actions.
- App Folder pages with a posts grid and a folder-specific
Reelstab when videos exist. - Shared likes in SQLite for signed-in admin/viewer sessions, plus browser-local favorites in public mode.
- Photo thumbnails and previews, plus on-demand streaming for local videos.
- Carousel posts with 2–20 images, animated images, and videos in one swipeable post.
- Original-media download controls on home feed cards, post detail, and stories, alongside open-original actions.
- Optional role-based local access with admin, viewer, and public browse modes.
- Settings split into
General Settingsfor Home/Reels defaults, language selection, stories and carousel folder modes, and excluded folders, plusScan & Libraryfor scan and rebuild actions. - Phase-aware scan progress for first indexing, derivative migration, and rebuilds.
- A web app manifest plus production service worker registration.
- An optional debounced filesystem watcher in development mode, disabled by default.
- No multi-user accounts, cloud uploads, comments, messaging, or notifications. Local sources need no remote APIs; the optional Immich integration synchronizes remote metadata and fetches media through its read-only API.
How It Works
For local sources, Foldergram maps directly to your filesystem:
- App Folders: Any non-hidden folder under
GALLERY_ROOTthat directly contains supported media becomes one indexed App Folder. In reserved carousel mode, a folder also qualifies when itscarousels/directory has an immediate child containing supported media directly. - Posts: Each supported image or video directly inside an App Folder becomes one indexed post. Media in
AppFolder/carousels/Post name/is grouped into a carousel post in reserved mode. - Nested folders stay separate: Nested local folders are not merged into their parent App Folder. If a nested folder directly contains supported media, it becomes its own App Folder with parent folder name in the route (e.g. /folder/parent-nested).
- Root files are ignored: Files placed directly in
GALLERY_ROOTare ignored. - Folder markers: A regular file named exactly
.nofoldergramexcludes its containing folder and all descendants. A marker directly inGALLERY_ROOTis ignored.
Foldergram uses its SQLite index to list your library and reads originals or generated files when you open media.
Supported Formats
- Images:
.jpg,.jpeg,.png,.webp,.gif,.avif - Opt-in preview: local still HEIC and HEIF.
- Videos:
.mp4,.mov,.m4v,.webm,.mkv
Animated image files keep animation in the post viewer preview and home feed cards. Folder/profile grids and other thumbnail surfaces remain static. Static AVIF files stay on the normal image pipeline; animated AVIF image sequences generate static WebP thumbnails and animated WebP previews.
For source installs, video support and animated AVIF image-sequence processing require ffmpeg and ffprobe. The Docker image installs them inside the container.
Video playback
New local videos use streaming by default. Foldergram plays the original when the browser can handle it. Otherwise, it converts short sections as you watch. This saves space on MP4 previews, though starting or seeking in a video can take longer when it needs conversion.
Videos already in your library keep their current playback after an upgrade. To free space, open Settings → Scan & Library → Switch to streaming and remove video previews and review the estimate before you confirm. Immich playback works as before. See how to switch existing videos.
Installation
One-click hosting with InstaPods
Prefer a hosted setup? You can deploy Foldergram directly on InstaPods.
🐳 The Easy Way (Docker - Recommended)
This is the recommended path for most users. It uses the pre-built GitHub Container Registry (GHCR) image.
- Create a folder for Foldergram and move into it:
mkdir foldergram
cd foldergram
- Download the Compose file:
wget -O docker-compose.yml https://raw.githubusercontent.com/foldergram/foldergram/main/docker-compose.yml
- Create your first gallery folder:
mkdir -p data/gallery/example-album
- Move a few photos or videos into
data/gallery/example-album/to create your first indexed App Folder. - Start the container:
docker compose up -d
Container startup runs pending SQLite migrations automatically before the app opens the library database.
- Open
http://localhost:4141.
In Docker, Foldergram runs in production mode and the app inside the container listens on 4141. If you need a different host port, change the left side of 4141:4141 in docker-compose.yml.
For the default Docker Compose setup, the container uses the image's built-in
production defaults plus the mounted ./data/... volumes. The source-install
.env file is not read inside the container unless you wire that in yourself.
The shipped Compose file uses streaming for new local videos and stores the
temporary cache in ./data/hls-cache. It also sets
IMAGE_DETAIL_SOURCE: preview and DERIVATIVE_MODE: eager.
If you want lazy derivatives or original-backed image detail pages in Docker,
edit those values in docker-compose.yml before starting the container.
If you want Docker to skip unwanted source folders from the first scan, add
GALLERY_EXCLUDED_FOLDERS under the Compose environment: block. For example:
GALLERY_EXCLUDED_FOLDERS: "@eaDir,thumbnails,Archive/cache"
For an optional read-only public demo in Docker, add PUBLIC_DEMO_MODE: "1"
under the Compose environment: block. If the browser-visible origin differs
from the upstream Node host, also set CSRF_TRUSTED_ORIGINS to that public
origin.
If You Already Cloned This Repository
The repository includes:
docker-compose.ymlfor the GHCR imagedocker-compose.local.ymlas a local-build override
To build locally from source instead of pulling from GHCR, run:
docker compose -f docker-compose.yml -f docker-compose.local.yml up -d --build
This command uses the same runtime settings and volumes, but builds the image locally from the repository Dockerfile.
Run from Source
Note: This repository is set up as a workspace.
pnpmis preferred for the best development experience, but standardnpmis also supported if you prefer the default Node toolchain.
Requirements:
- Node.js 22.23.4 or a newer patched Node.js 22 release
npmorpnpmffmpegandffprobeif you want video support or animated AVIF image-sequence processing outside Docker
- Clone the repository:
git clone --branch main https://github.com/foldergram/foldergram.git
cd foldergram
- Create your local env file:
cp .env.example .env
- Install dependencies:
pnpm install
# or
npm install
- Start the development workspace:
pnpm dev
# or
npm run dev
Server startup applies pending SQLite migrations automatically. Use pnpm migrate
to apply them without starting the app.
For existing installations, follow the upgrade instructions to preserve your data and review any Carousel folder migration choice.
Development ports:
- Client: prefers
http://localhost:4141and automatically uses the next free port up to4144 - API:
http://localhost:4140 - Docs:
http://localhost:4145
The Vite client stays within the reserved 4141-4144 range in development, so it can move off 4141 without colliding with the API or docs ports.
If you only want part of the workspace, use:
pnpm dev:serverpnpm dev:clientpnpm dev:docs
For a production build from source:
pnpm build
pnpm start
# or
npm run build
npm start
Then open http://localhost:4141.
Configuration
Default paths come from .env.example:
data/
├─ gallery/ # Original source media
├─ db/
│ └─ gallery.sqlite
├─ thumbnails/ # Thumbnails and video posters
├─ previews/ # Saved previews
└─ hls-cache/ # Temporary video segments
GALLERY_ROOT only needs read access. Foldergram needs write access to
DB_DIR, THUMBNAILS_DIR, PREVIEWS_DIR, and the streaming cache. <DATA_ROOT>/scan-errors is created on
demand and must be writable when skip mode produces scan reports.
| Variable | Default | Description |
|---|---|---|
NODE_ENV |
development |
Runtime mode. |
SERVER_PORT |
4141 |
Production Express port. |
DEV_SERVER_PORT |
4140 |
Express server port during pnpm dev. |
DEV_CLIENT_PORT |
4141 |
Base Vite client port during pnpm dev. The client may use up to 4144. |
DATA_ROOT |
./data |
Root directory for app-managed storage. |
GALLERY_ROOT |
./data/gallery |
Root directory scanned for App Folders. |
GALLERY_EXCLUDED_FOLDERS |
empty | Comma-separated folder exclusion rules such as @eaDir,Archive/cache. |
DB_DIR |
./data/db |
SQLite database directory. Startup migrations target <DB_DIR>/gallery.sqlite. |
THUMBNAILS_DIR |
./data/thumbnails |
Generated thumbnail output directory. |
PREVIEWS_DIR |
./data/previews |
Generated preview output directory. |
VIDEO_DELIVERY_MODE |
streaming |
Use previews to keep saving MP4 previews when new local videos need them. |
HLS_CACHE_DIR |
<DATA_ROOT>/hls-cache |
Temporary video segments. See the video playback settings. |
IMAGE_DETAIL_SOURCE |
preview |
For image detail pages, use generated previews or stream originals. |
DERIVATIVE_MODE |
eager |
Generate derivatives during scans or lazily on first request. |
LOG_VERBOSE |
0 |
Truthy values are 1, true, yes, and on. |
SCAN_MEDIA_ERROR_MODE |
skip |
Use skip to report supported-media failures and continue, or fail. |
GALLERY_WATCH_ENABLED |
false |
Opt in to automatic gallery scans in development after a manual scan or rebuild. Production never watches. |
SCAN_DISCOVERY_CONCURRENCY |
4 |
Folder discovery concurrency. |
SCAN_DERIVATIVE_CONCURRENCY |
4 |
Derivative generation concurrency. |
INITIAL_ADMIN_PASSWORD |
empty | Optional first-time admin password; never replaces a saved password. |
INITIAL_ADMIN_PASSWORD_FILE |
empty | Optional path to a Docker secret containing the initial admin password. |
PUBLIC_DEMO_MODE |
0 |
Blocks library changes in public demos and allows video playback. |
CSRF_TRUSTED_ORIGINS |
empty | Comma-separated extra browser origins allowed for mutating API requests. |
DATA_ROOT is the base path for the app's local storage layout. If you set
only DATA_ROOT, Foldergram will default the other storage paths to
<DATA_ROOT>/gallery, <DATA_ROOT>/db, <DATA_ROOT>/thumbnails,
<DATA_ROOT>/previews, and <DATA_ROOT>/hls-cache. Override individual paths
if you use a different layout.
Per-run full scan error reports are written under <DATA_ROOT>/scan-errors/
when a scan records supported-media failures.
Docker uses the fixed internal container port 4141, and other production
runtimes continue to use SERVER_PORT, which defaults to 4141 in the Docker
image.
For the default Docker Compose setup, runtime variables are defined in
docker-compose.yml. The source-install .env file is
not read directly by the container.
To protect a new Docker or managed-hosting installation before HTTP startup, set INITIAL_ADMIN_PASSWORD in the container environment, or use INITIAL_ADMIN_PASSWORD_FILE with a mounted Docker secret. Never set both. The password is hashed and stored in SQLite; subsequent restarts do not overwrite a password changed in Settings. Empty or absent values preserve passwordless installs, while invalid configured values stop startup. Disabling protection in Settings is blocked while either initial-password option remains configured. Remove it and restart before deliberately disabling protection. See Configuration for a complete Docker Compose named-secret example and Security for details.
Excluded Folders
- Place an empty
.nofoldergramfile inside a folder to exclude that folder and its entire subtree, including stories and carousel posts. The filename is fixed and contents are ignored. - Use
GALLERY_EXCLUDED_FOLDERSto skip unwanted source folders during discovery and rescans. - Rules without a slash match a folder name anywhere in the gallery tree, such as
@eaDirorthumbnails. - Rules with a slash match one exact relative folder path beneath
GALLERY_ROOT, such asArchive/cache. - The Settings sidebar separates app-wide preferences into
General Settings. That section includes the instant language selector plus saved app-language default, stories and carousel folder modes, Home/Reels defaults, and the excluded-folder editor. General Settingscan add or remove custom exclusion rules at runtime. Env-backed rules stay read-only there and still require a restart to change.- After changing excluded folders, stories mode, or carousel mode in
General Settings, follow the action shown inScan & Libraryso indexed folders and posts are classified correctly. Run a full scan normally; use the index rebuild when the gallery location requires one.
For example, Archive and everything below it are excluded, while Trips is indexed:
gallery/
Trips/
photo.jpg
Archive/
.nofoldergram
old-photo.jpg
Nested/
another-photo.jpg
Adding or removing a marker triggers a debounced full scan in development mode.
In Docker and other production deployments, run a scan from Settings -> Scan & Library
after changing a marker. Exclusion soft-deletes existing index records; removing
the marker and scanning again restores them. Originals remain untouched, and
derivatives follow the usual retention and cleanup rules.
Detail Media and Derivative Timing
IMAGE_DETAIL_SOURCE=previewkeeps image detail pages on generated previews.IMAGE_DETAIL_SOURCE=originalmakes image detail pages stream/api/originals/:id.DERIVATIVE_MODE=eagergenerates thumbnails and any required previews during scans.DERIVATIVE_MODE=lazygenerates those files when first requested and saves them for later.SCAN_MEDIA_ERROR_MODE=skipreports supported image and video processing failures, skips those files, and lets the scan finish ascompleted_with_errors.- Directory read failures below a source root also preserve the skipped subtree's index and let readable sibling folders finish indexing and generating derivatives. Source-root read failures still stop the scan.
SCAN_MEDIA_ERROR_MODE=failpreserves fail-fast behavior for those same scan-time media errors.- When a scan records skipped media failures, Foldergram stores a short sample in SQLite, writes the full per-run report under
<DATA_ROOT>/scan-errors/, and shows that report path in the admin Settings view.
Scan for changes checks for new, changed, and missing files. Scan and repair derivatives also checks thumbnails and previews for unchanged files. To free space by removing video previews, use the separate streaming cleanup. Regenerate Thumbnails rebuilds thumbnails and video posters.
Access Protection
Access protection is configured from the Settings page, not from .env.
The current implementation supports:
adminsessions with full accessviewersessions with shared likes but no Settings, Trash, scans, rebuilds, or delete actionsanonymouspublic sessions with browse-only access and browser-local favoritesviewer_access_mode=offfor admin-only accessviewer_access_mode=passwordfor a separate viewer passwordviewer_access_mode=publicfor anonymous browsing plus admin unlock fromMore
Foldergram stores one-way password hashes plus signed session metadata in SQLite. In public mode, anyone who can reach the app can browse immediately, favorites stay in the current browser only, and admins can elevate back into full access from More with the admin password.
Public Demo Deployments
To run Foldergram as a public read-only demo, set the following in .env:
NODE_ENV=production
PUBLIC_DEMO_MODE=1
CSRF_TRUSTED_ORIGINS=https://demo.foldergram.app
In demo mode, people can browse and stream videos without changing the library.
Set CSRF_TRUSTED_ORIGINS if the public URL differs from the origin Foldergram
sees, such as when you use a reverse proxy.
Tech Stack
Backend
- Node.js 22 + Express 5 + TypeScript
- SQLite via
node:sqlite - Sharp for image derivatives
- FFmpeg and FFprobe for video processing
- Chokidar for the development watcher
- Zod for runtime validation
Frontend
- Vue 3
- Vite
- Vue I18n
- Vue Router 4
- Pinia
- UnoCSS
Workspace
pnpmmonorepo
Localization
Client translations live under client/src/locales/.
en.jsonis the canonical source locale and the first place new UI copy should be added.es.json,zh.json, andde.jsonare the shipped Spanish, Chinese, and German translations for the client.client/src/locales/index.tswires locale resolution and the Vue I18n runtime.pnpm --filter @foldergram/client testincludes a locale validation test that checks locale keys againsten.json.
Scripts
| Command | Description |
|---|---|
pnpm dev |
Start the API, client, and docs development servers. |
pnpm dev:server |
Start only the API development server. |
pnpm dev:client |
Start only the Vite client development server. |
pnpm dev:docs |
Start only the VitePress docs development server. |
pnpm build |
Build the server and client for production. |
pnpm build:server |
Build only the server. |
pnpm build:client |
Type-check and build only the client. |
pnpm build:docs |
Build the documentation site. |
pnpm migrate |
Apply pending SQLite migrations without starting the app. |
pnpm start |
Start the production server and serve the built client. |
pnpm test |
Run the server and client unit and integration tests. |
pnpm test:server |
Run only the server tests. |
pnpm test:client |
Run only the client tests. |
pnpm test:browser |
Run the Chromium browser regression tests. |
pnpm rescan |
Scan the configured gallery and update its index. |
Contributing
Contributions are welcome! You can help by reporting bugs, suggesting improvements, improving documentation and translations, or submitting pull requests for fixes, tests, and UI polish.
Start contribution branches from the latest develop and target develop in your pull request. The default branch, main, documents stable releases.
For major features or changes to core behavior such as scanning, indexing, access, or storage, please open an issue or discussion first so we can agree on the approach before you invest time in an implementation.
See CONTRIBUTING.md for local setup, project guidelines, and tips for preparing a pull request.
Community
Join our Discord server to ask questions, share ideas, and connect with other Foldergram users. You can also use GitHub Discussions for feature discussions and longer conversations, or GitHub Issues to report bugs.
Support Foldergram
If you enjoy using Foldergram, consider supporting its development on Patreon. Your support helps me dedicate more time to maintenance, improvements, and new features.
Thank you to everyone who supports, contributes to, and shares Foldergram.
Hosting sponsored by Simafri (managed VPS)
探索相关项目
加载中…