Deploy codex

Create High-Quality Open-Source Projects.

Deploy codex

mongo

mongo:4

Just deployed

/data/db

Just deployed

/usr/src/app/uploads

Deploy and Host Codex on Railway

Codex is an open-source, modern documentation, note-taking, and content publishing platform designed for organizing knowledge, managing documents, and collaborating effectively. This Railway template deploys a two-tier architecture featuring the Codex Web Application (codex) connected to a dedicated MongoDB Database (mongo) with persistent file uploads and database storage.


About Hosting Codex

Hosting Codex on Railway runs two connected container services:

  • Codex Web Application (codex): Core application built from OpenSource-Templates/codex (branch main). It manages document editing, user authentication, and web page rendering. It mounts a persistent volume at /usr/src/app/uploads for user-uploaded assets, listens on port 3000, and connects securely to MongoDB via Railway's private network.
  • MongoDB Database (mongo): NoSQL database container running mongo:4. It mounts a persistent volume at /data/db to guarantee data durability across container updates, listening internally on port 27017 with root authentication enabled (authSource=admin).

Common Use Cases
  • Self-hosted team documentation & wiki: Build, organize, and host internal knowledge bases and product documentation.
  • Personal note-taking & publishing portal: Maintain structured notes, technical guides, and public articles under your custom domain.
  • Media-rich document management: Upload images, files, and attachments securely stored on dedicated persistent storage.
  • Decoupled cloud architecture: Fully managed Node.js web app paired with an isolated, authenticated MongoDB database.

Dependencies for Codex Hosting
  • Codex application repo: OpenSource-Templates/codex (main branch)
  • MongoDB image: mongo:4
  • Two persistent volumes:
    • Uploads volume mounted at /usr/src/app/uploads on codex
    • Database volume mounted at /data/db on mongo
  • Railway public domain attached to the codex web service on port 3000
  • Auto-generated secrets: Authentication password (APP_CONFIG_auth_password), auth secret token (APP_CONFIG_auth_secret), and MongoDB root password (MONGO_INITDB_ROOT_PASSWORD)

Upstream: Codex Repository · MongoDB Documentation

Implementation Details
ServiceSourceRoleInternal PortVolume Mount
codexOpenSource-Templates/codexWeb App & Document Engine3000/usr/src/app/uploads
mongomongo:4MongoDB Database Store27017/data/db

Topology
ServiceRoleVolumePublicNotes
codexWeb Frontend & API/usr/src/app/uploadsYes (Port 3000)Connects to mongo via private URI
mongoDocument Database/data/dbTCP Proxy (Port 27017)Authenticates via authSource=admin
Volumes (drives) — what to mount
ServiceMount pathWhat is stored
codex/usr/src/app/uploadsUploaded images, documents, attachments, and media files
mongo/data/dbMongoDB database collections, indexes, document data, and user accounts

Warning: Do not remove or detach the persistent volumes mounted on codex or mongo — deleting /data/db will permanently erase all documents and user accounts, while removing /usr/src/app/uploads will delete uploaded media files.


Quick Start
  1. Click the Deploy on Railway button above.
  2. Sign in (or create a free Railway account) and click Deploy.
  3. Wait 1–2 minutes for both the mongo database and codex web application services to provision.
  4. Retrieve your auto-generated login secret from the codex service → Variables tab (APP_CONFIG_auth_password).
  5. Open the codex service → Settings → Networking and click the generated public domain URL.
  6. Access your Codex instance and log in to begin creating documents and managing content.

Configuration
Codex Application Variables (codex)
VariableDefault / SourceDescription / Notes
APP_CONFIG_database_drivermongodbDatabase driver selection
APP_CONFIG_database_mongodb_urimongodb://${{mongo.MONGO_INITDB_ROOT_USERNAME}}:${{mongo.MONGO_INITDB_ROOT_PASSWORD}}@${{mongo.RAILWAY_PRIVATE_DOMAIN}}:27017/?authSource=adminPrivate MongoDB connection string
APP_CONFIG_auth_passwordAuto-generated secret (16 chars)Administrative authentication password
APP_CONFIG_auth_secretAuto-generated secret (32 chars)Cryptographic secret for signing sessions and JWT tokens
APP_CONFIG_host0.0.0.0Server network binding host
PORT3000Internal port the web application listens on
MongoDB Database Variables (mongo)
VariableDefault / SourceDescription / Notes
MONGO_INITDB_ROOT_USERNAMEmongoRoot administrative database username
MONGO_INITDB_ROOT_PASSWORDAuto-generated secret (16 chars)Root administrative database password
MONGOHOST${{RAILWAY_PRIVATE_DOMAIN}}Internal private network host address
MONGOPORT27017Standard MongoDB database port
MONGOUSER${{MONGO_INITDB_ROOT_USERNAME}}Database username alias
MONGOPASSWORD${{MONGO_INITDB_ROOT_PASSWORD}}Database password alias
MONGO_URLPrivate connection URLInternal MongoDB connection string
DATABASE_URLPrivate connection URLUnified database URL for application linking
Custom Domain
  1. Open the codex service → Settings → Networking → Custom Domain.
  2. Add your custom domain and follow Railway’s DNS configuration instructions.
  3. Railway provisions TLS automatically.
  4. Access your documentation portal securely at https://your.custom.domain.

Updating Codex
  1. Open the codex service → Settings → Source.
  2. Trigger a redeploy or update the repository branch settings.
  3. Click Redeploy.

All application documents inside MongoDB (/data/db) and uploaded media files (/usr/src/app/uploads) will remain safe across updates.


Traps

Common pitfalls and failure modes:

  • Missing /data/db Volume — If the database volume mounted on mongo is deleted or detached, all articles, collections, user records, and settings will be permanently wiped on container restart.
  • Missing /usr/src/app/uploads Volume — If the uploads volume on codex is detached, uploaded images and file attachments will disappear during redeployments.
  • Database Readiness Delay — On initial deployment, if the codex container initializes before mongo finishes setting up the admin database user, restart the codex deployment once MongoDB health checks pass.
  • Auth Password Loss — Make sure to note your auto-generated APP_CONFIG_auth_password from the codex variables tab, as it is generated securely at initial deploy time.

Why Deploy Codex on Railway?

Railway provides an effortless platform for running multi-container stacks. Hosting Codex on Railway gives you private service networking between Node.js and MongoDB, automated SSL certificate generation, persistent storage volumes, auto-generated secret keys, and simple single-click deployments.



Template Content

More templates in this category

View Template
Rocky Linux
Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀

codestorm
47
View Template
Foundry Virtual Tabletop
A Self-Hosted & Modern Roleplaying Platform

Lucas
71
View Template
Letta Code Remote
Run a Letta Code agent 24/7. No inbound ports, just deploy.

Letta
51