OpenStock is an open-source alternative to expensive market platforms. Track real-time prices, set personalized alerts, and explore detailed company insights — built openly, for everyone, forever free.
feat: add Railway deployment config
cosmind-rusufc94d9e9e316
diff --git a/.dockerignore b/.dockerignorenew file mode 100644index 0000000..b67a2db--- /dev/null+++ b/.dockerignore@@ -0,0 +1,11 @@+node_modules+.next+out+build+coverage+.git+.idea+.vercel+.env*+npm-debug.log*+*.tsbuildinfodiff --git a/Dockerfile b/Dockerfileindex 39d6678..6072473 100644--- a/Dockerfile+++ b/Dockerfile@@ -17,6 +17,11 @@ RUN npm install# Copy all project filesCOPY . .+# NEXT_PUBLIC_* variables are inlined at build time, so they must be available+# during `npm run build` (Railway passes service variables as build args)+ARG NEXT_PUBLIC_FINNHUB_API_KEY+ENV NEXT_PUBLIC_FINNHUB_API_KEY=$NEXT_PUBLIC_FINNHUB_API_KEY+# Build the Next.js applicationRUN npm run build# Or if using pnpm:diff --git a/README.md b/README.mdindex 9907d88..fe2b93f 100644--- a/README.md+++ b/README.md@@ -58,15 +58,16 @@ Note: OpenStock is community-built and not a brokerage. Market data may be delay4. 🔋 [Features](#features)5. 🤸 [Quick Start](#quick-start)6. 🐳 [Docker Setup](#docker-setup)-7. 🔐 [Environment Variables](#environment-variables)-8. 🧱 [Project Structure](#project-structure)-9. 📡 [Data & Integrations](#data--integrations)-10. 🌍 [Market Support](#market-support)-11. 🧪 [Scripts & Tooling](#scripts--tooling)-12. 🤝 [Contributing](#contributing)-13. 🛡️ [Security](#security)-14. 📜 [License](#license)-15. 🙏 [Acknowledgements](#acknowledgements)+7. 🚂 [Deploy on Railway](#deploy-on-railway)+8. 🔐 [Environment Variables](#environment-variables)+9. 🧱 [Project Structure](#project-structure)+10. 📡 [Data & Integrations](#data--integrations)+11. 🌍 [Market Support](#market-support)+12. 🧪 [Scripts & Tooling](#scripts--tooling)+13. 🤝 [Contributing](#contributing)+14. 🛡️ [Security](#security)+15. 📜 [License](#license)+16. 🙏 [Acknowledgements](#acknowledgements)## ✨ Introduction <a name="introduction"></a>@@ -244,6 +245,33 @@ volumes:mongo-data:```+## 🚂 Deploy on Railway <a name="deploy-on-railway"></a>++OpenStock ships with a [`railway.json`](railway.json) so it can be deployed on [Railway](https://railway.com) using the existing `Dockerfile`, with a healthcheck on `/sign-in` and automatic restarts on failure.++1) Create a new project on Railway and add a **MongoDB** database (`+ New → Database → MongoDB`).+2) Add a service from this GitHub repository (`+ New → GitHub Repo`). Railway detects `railway.json` and builds with the `Dockerfile`.+3) In the service **Variables**, set:++```env+MONGODB_URI=${{MongoDB.MONGO_PUBLIC_URL}}+BETTER_AUTH_SECRET=${{secret(32)}}+BETTER_AUTH_URL=https://${{RAILWAY_PUBLIC_DOMAIN}}+NEXT_PUBLIC_FINNHUB_API_KEY=your_finnhub_key+GEMINI_API_KEY=your_gemini_api_key+INNGEST_SIGNING_KEY=your_inngest_signing_key+NODEMAILER_PASSWORD=your_gmail_app_password+```++4) Under **Settings → Networking**, generate a public domain, then redeploy.++Notes+- `NEXT_PUBLIC_FINNHUB_API_KEY` is inlined at build time; Railway passes it to the Docker build as a build arg, so redeploy after changing it.+- Use `MONGO_PUBLIC_URL` (not `MONGO_URL`): `next build` connects to MongoDB while collecting page data, and Railway's private network is not available during builds.+- For scheduled jobs (daily summaries, alerts), add your Railway domain as an app in the [Inngest dashboard](https://app.inngest.com) pointing to `https://<your-domain>/api/inngest`.+- See [Environment Variables](#environment-variables) for the optional variables (Adanos, MiniMax, Kit, etc.).+## 🔐 Environment Variables <a name="environment-variables"></a>Create `.env` at the project root. Choose either a hosted MongoDB (Atlas) URI or the local Docker URI.diff --git a/railway.json b/railway.jsonnew file mode 100644index 0000000..0b4122d--- /dev/null+++ b/railway.json@@ -0,0 +1,13 @@+{+ "$schema": "https://railway.com/railway.schema.json",+ "build": {+ "builder": "DOCKERFILE",+ "dockerfilePath": "Dockerfile"+ },+ "deploy": {+ "healthcheckPath": "/sign-in",+ "healthcheckTimeout": 300,+ "restartPolicyType": "ON_FAILURE",+ "restartPolicyMaxRetries": 10+ }+}