Deploy PiGallery2
Fast directory-first photo and video gallery you self-host
pigallery2
Just deployed
/app/data
Deploy and Host self hosted PiGallery2 (Storage) on Railway
This template deploys PiGallery2, an MIT-licensed, directory-first photo and video gallery, as one Railway service with one persistent volume. It is independent community packaging of bpatrik/pigallery2 3.8.0 (Copyright 2016 bpatrik), not affiliated with or endorsed by PiGallery2.
About Hosting PiGallery2 open-source software on Railway (self hosted PiGallery2 template)
This template runs the unmodified upstream bpatrik/pigallery2 3.8.0 image, packaged as ghcr.io/onepush-dev/pigallery2:3.8.0 with a small start script that writes the first config on boot.
Railway handles the container, the public domain on port 8080, the /heartbeat health check and automatic restarts.
Why Deploy PiGallery2, the self-hosted directory-first photo and video gallery on Railway
Self-hosting PiGallery2 keeps your originals in folders you control, and it reads those folders as they are rather than importing them into a database you cannot leave.
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying PiGallery2 on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Railway vs Other Hosting Providers and VPS for PiGallery2 self hosting
Running PiGallery2 yourself means choosing where the gallery, database and photo volume live.
| Provider | What You Get with Railway | What You Get with the Other Provider |
|---|---|---|
| DigitalOcean | A deployed service with a persistent volume at /app/data and a /heartbeat health check. | A droplet you size, secure and maintain, with Docker and volumes set up by you. |
| AWS | One service with the volume, port 8080 and restart policy set by the template. | Broad networking and storage options, but you assemble the instance and routing yourself. |
| Hetzner | Managed deployment from one template with no inputs and a generated admin password. | Low-cost servers where you install Docker, the image and backups yourself. |
Choose Railway when you want the gallery running without operating a server.
Common Use Cases for hosted PiGallery2
- Browsing a folder tree as it is: Point PiGallery2 at your photo folders and it shows the structure exactly as you keep it, with no import step and no database lock-in.
- Searching and organizing a shared family archive: Use search and albums to find events quickly, then share selected albums through sharing links with relatives who do not need an account.
- Collecting photos from others: Enable browser uploads for admins so guests or team members can add files straight into the library from any device.
- Mapping and tagging a larger library: Turn on the optional map, faces and video transcoding features in Settings when your collection grows, and add OIDC sign-in if you already run an identity provider.
- Keeping everything on one volume: Photos, thumbnails and the SQLite database all sit on a single Railway volume at /app/data, which makes sizing and backing up the library straightforward.
Dependencies for PiGallery2 Docker hosted on Railway
This template runs one service built from the upstream PiGallery2 image, with a single persistent volume for everything the app writes. You deploy it with zero inputs.
Deployment Dependencies for Managed PiGallery2 Service
The template creates one public service named pigallery2 listening on port 8080, with one volume mounted at /app/data, health check /heartbeat with a 300 second timeout, and restart Always. Keep one replica, because config, photos and the database live on that volume.
Implementation Details for PiGallery2
ghcr.io/onepush-dev/pigallery2:3.8.0 is the unmodified upstream bpatrik/pigallery2:3.8.0 image plus railway/start.sh. On first boot the start script writes config.json with admin as an upstream enforced user whose password comes from the generated PIGALLERY2_ADMIN_PASSWORD, stored hashed, so the default admin/admin account is never created. Photos live at /app/data/images, thumbnails and transcoded video at /app/data/tmp, and SQLite at /app/data/db. Uploads are enabled for admins. Changing the password variable later has no effect; change it in Settings, Users.
How does PiGallery2 compare against other tools
PiGallery2 vs a hosted photo library (Hosted Photo Library Alternative)
- Ownership of files: PiGallery2 reads your folders as they are and keeps photos on the Railway volume at /app/data/images. A hosted library stores its own copy in its own system.
- Setup effort: A hosted library is ready once you sign up, while PiGallery2 needs a deploy, a sign-in with the generated admin password and a first round of indexing.
- Ecosystem and polish: Hosted libraries often win on mobile apps and automatic device backup. PiGallery2 covers search, albums, sharing links and browser uploads, but it is a smaller project.
PiGallery2 vs browsing folders only on a shared drive (Shared Drive Browsing Alternative)
- Browsing experience: PiGallery2 adds thumbnails, search, a map view and albums on top of the same folder structure.
- Access control: PiGallery2 has user accounts with roles, so you can share a gallery without handing out the whole drive.
- Simplicity: A shared drive needs no extra service, so it fits occasional file access without any gallery view.
PiGallery2 with Docker vs Railway (Docker Self-Hosting Alternative)
- Control: Running the upstream Docker image yourself gives full control of the host, networking and backups, while Railway manages the host and public domain.
- Cost model: Your own hardware is a fixed cost you already pay, whereas Railway is usage-based and depends on RAM, CPU and volume size.
- Maintenance: On Railway the health check, restart policy and volume are preconfigured, but you still keep one replica and size the volume for your library.
How to use PiGallery2 on Railway?
Follow these steps on your first day after the deploy finishes. The steps assume one service, named pigallery2, with its volume mounted at /app/data.
- Open the public Railway domain for the pigallery2 service in your browser.
- Sign in as admin with the value of PIGALLERY2_ADMIN_PASSWORD from the service Variables tab. The default admin/admin account is never created.
- Upload photos from the browser, or copy them into /app/data/images on the volume, with one folder per album.
- Index the library from Settings, Indexing, or just browse a folder and it will be indexed on demand.
- Size the volume for your library before you add much media, because photos and thumbnails both live on it. Keep one replica, and watch the health check at /heartbeat.
Health check path: /heartbeat
Photos: /app/data/images
Thumbnails: /app/data/tmp
Database: /app/data/db
How to self host PiGallery2 on other VPS Services (PiGallery2 self hosting guide)
Clone the Repository
Start by getting the packaging source and the upstream project onto your machine or server.
git clone --branch 3.8.0 https://github.com/bpatrik/pigallery2.git
cd pigallery2
Install Dependencies
Use Docker, which is the upstream recommended way to run PiGallery2. Make sure Docker is installed and running on your VPS before you continue.
Configure Environment Variables
Create one persistent data directory on the host for config, the SQLite database and your photos. Replace your-domain with the host you plan to serve from.
mkdir -p /srv/pigallery2/data
Start the PiGallery2 Application
Use the upstream flow: upstream: run the documented pigallery2 container with a persistent data directory for config, database and photos; see the upstream repository.
Pricing and License of PiGallery2 (PiGallery2 pricing)
PiGallery2 is MIT open-source software, so you can self-host it without any licensing fee.
PiGallery2 hosted vs self hosted comparison (Pricing, features, costs, and more)
This template packages the MIT licensed PiGallery2 software, and no hosted photo library plan prices are quoted here.
Monthly cost of self hosting PiGallery2 on Railway
Railway bills by resource use, so the monthly total moves with memory, CPU and the size of the volume holding your photos and thumbnails.
System Requirements for Hosting PiGallery2 on a VPS
A self hosted VPS needs enough memory to index and serve your library, enough CPU for thumbnails and video transcoding, and disk space for photos, thumbnails and the database. Size storage for the full library, because originals and generated thumbnails share the same volume.
Frequently Asked Questions (FAQs)
How do I sign in to PiGallery2 after deploying?
Open your Railway domain and sign in with the username admin and the password stored in the PIGALLERY2_ADMIN_PASSWORD variable.
Is the default admin/admin account created?
No. Trying admin/admin will fail. On first boot the start script creates admin as an upstream enforced user with the generated password, and that password is stored hashed.
Where do my photos live?
Your photos are stored in /app/data/images on the Railway volume. Thumbnails are generated in /app/data/tmp and the SQLite database sits in /app/data/db.
Can I change the admin password by editing the variable later?
No. Change the password inside the app under Settings, Users instead.
What should I back up?
Back up the /app/data volume, since it holds your config, database, photos and thumbnails together.
Is this affiliated with or endorsed by PiGallery2?
No. This is independent community packaging of bpatrik/pigallery2 3.8.0 (MIT, Copyright 2016 bpatrik), not affiliated with or endorsed by PiGallery2.
Template Content
pigallery2
ghcr.io/onepush-dev/pigallery2:3.8.0