Deploy Locker | Open-Source File Storage Platform
Railway

Deploy Locker | Open-Source File Storage Platform

An open-source, self-hostable Dropbox or Google Drive alternative.

Deploy Locker | Open-Source File Storage Platform

/var/lib/postgresql/data

Just deployed

/data

Deploy and Host Locker | Open-Source File Storage Platform on Railway

Locker is an open-source, self-hostable file storage platform — a privacy-first alternative to Dropbox and Google Drive. Upload, organise, and share files from your own infrastructure with support for local disk, AWS S3, Cloudflare R2, or Vercel Blob storage. One environment variable to switch providers.

About Hosting Locker

Locker is a Next.js 16 application backed by PostgreSQL with Drizzle ORM. This Railway template deploys the web app alongside a Railway-provisioned PostgreSQL service, with a persistent volume for local file storage. Database migrations run automatically before each deployment via the pre-deploy command. BetterAuth handles authentication with email/password and optional Google OAuth. Blob storage defaults to local disk on the mounted volume; switching to S3, R2, or Vercel Blob requires only a single environment variable change and the corresponding credentials.

Common Use Cases

  • Personal cloud storage — self-host a private Dropbox alternative with full control over where files live, who can access them, and at what cost — no per-seat pricing or vendor lock-in
  • Team file management — create workspaces with role-based access, share files via password-protected links with expiry dates and download limits, and collect uploads from external collaborators without requiring accounts
  • Storage migration — move existing files off Google Drive or Dropbox onto your own S3 bucket or Cloudflare R2 instance, retaining full type-safe API access and in-file search across images and PDFs

Dependencies for Locker

  • Locker GitHub repository — Next.js monorepo source, forked from original repo
  • PostgreSQL — provisioned automatically by this template via Railway's PostgreSQL service
  • Persistent volume mounted at /data — required for local blob storage; switch to S3/R2/Vercel Blob for cloud-backed storage

Deployment Dependencies

Implementation Details

The following environment variables are pre-configured by the template:

# Required
DATABASE_URL=${{Postgres.DATABASE_URL}}              # Auto-wired from Railway PostgreSQL service
BETTER_AUTH_SECRET=${{secret(32)}}                   # Auto-generated at deploy time
BETTER_AUTH_URL=https://${{RAILWAY_PUBLIC_DOMAIN}}   # Public URL for auth callbacks
NEXT_PUBLIC_APP_URL=https://${{RAILWAY_PUBLIC_DOMAIN}} # Baked into the Next.js bundle at build time
 
# Blob storage — defaults to local disk on the mounted volume
BLOB_STORAGE_PROVIDER=local
LOCAL_BLOB_DIR=/data

Optional: Google OAuth — to enable Google sign-in, create OAuth credentials at console.cloud.google.com and add:

GOOGLE_CLIENT_ID=your-client-id
GOOGLE_CLIENT_SECRET=your-client-secret

Optional: cloud storage — to use S3, R2, or Vercel Blob instead of local disk, change BLOB_STORAGE_PROVIDER and add the corresponding credentials:

# AWS S3
BLOB_STORAGE_PROVIDER=s3
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_REGION=us-east-1
S3_BUCKET=locker
 
# Cloudflare R2
BLOB_STORAGE_PROVIDER=r2
R2_ACCOUNT_ID=
R2_ACCESS_KEY_ID=
R2_SECRET_ACCESS_KEY=
R2_BUCKET=locker
R2_PUBLIC_URL=
 
# Vercel Blob
BLOB_STORAGE_PROVIDER=vercel
BLOB_READ_WRITE_TOKEN=

The railway.toml in the repository root sets the build, start, and pre-deploy commands for the monorepo.

Why Deploy Locker on Railway?

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 Locker 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.


Template Content

More templates in this category

View Template
Postgres Backup to Cloudflare R2 (S3-Compatible)
Automated PostgreSQL backups to S3-compatible storage with encryption

Aman
View Template
ReadySet
A lightweight caching engine for Postgres

Milo
View Template
Simple S3
Deploy a S3-compatible storage service with a pre-named bucket.

Joey Chilson