Skip to content

Commit 6e8ff5c

Browse files
committed
Switch from Render to Railway deployment
- Remove all Render-related configuration files (render.yaml, DEPLOYMENT.md) - Add Railway configuration files (railway.json, railway.toml for both services) - Update Vite config to remove Render-specific base path logic - Create comprehensive Railway deployment documentation - Railway provides native Java/Maven support and no cold starts
1 parent 33a5f51 commit 6e8ff5c

10 files changed

Lines changed: 45640 additions & 1239 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ server/src/main/resources/firebase_config.json
2222
# mac
2323
.DS_Store
2424

25+
.vercel

RAILWAY_DEPLOYMENT.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# LanguageGO Railway Deployment Guide
2+
3+
## Prerequisites
4+
- GitHub account
5+
- Railway account (free): https://railway.app
6+
- Firebase project with service account key
7+
- Clerk account for authentication
8+
9+
## Step 1: Set up Firebase Service Account
10+
1. Go to your Firebase Console: https://console.firebase.google.com
11+
2. Select your project
12+
3. Go to Project Settings > Service Accounts
13+
4. Click "Generate new private key"
14+
5. Save the JSON file securely - you'll need its contents for environment variables
15+
16+
## Step 2: Deploy to Railway
17+
18+
### Deploy the Java Backend
19+
1. Go to https://railway.app and sign in with GitHub
20+
2. Click "New Project" → "Deploy from GitHub repo"
21+
3. Select `FloppyDoval/LanguageGO`
22+
4. Railway will detect multiple services, choose to deploy the **backend first**
23+
5. Configure the backend service:
24+
- **Root Directory**: `server`
25+
- Railway should auto-detect it's a Java/Maven project
26+
- **Start Command**: `java -cp target/classes:target/lib/* edu.brown.cs.student.main.server.Server`
27+
28+
6. **Environment Variables** (in Railway dashboard):
29+
- `FIREBASE_CREDENTIALS`: Paste the entire contents of your Firebase service account JSON
30+
- `PORT`: Railway will automatically set this
31+
32+
7. Deploy and note the generated URL (e.g., `https://your-backend-name.railway.app`)
33+
34+
### Deploy the React Frontend
35+
1. In the same Railway project, click "New Service"
36+
2. Choose "GitHub Repo" and select the same repository
37+
3. Configure the frontend service:
38+
- **Root Directory**: `client`
39+
- Railway should auto-detect it's a Node.js project
40+
- Build command will be automatically detected: `npm run build`
41+
- Start command: `npm run serve` (or Railway will serve the built files)
42+
43+
4. **Environment Variables**:
44+
- `VITE_API_URL`: Use the backend URL from step 7 above
45+
- `VITE_CLERK_PUBLISHABLE_KEY`: Your Clerk publishable key from Clerk dashboard
46+
- `NODE_ENV`: `production`
47+
48+
5. Deploy the frontend
49+
50+
## Step 3: Verify Deployment
51+
1. **Backend Health Check**: Visit `https://your-backend-url/ping` - should return "pong"
52+
2. **Frontend**: Visit your frontend URL - should load the application
53+
3. **API Integration**: Test that frontend can communicate with backend
54+
55+
## Step 4: Configure CORS (if needed)
56+
Your Java server already has CORS configured to allow all origins (`*`). For production, you might want to restrict this to your frontend domain only.
57+
58+
## Environment Variables Summary
59+
60+
### Backend Service
61+
- `FIREBASE_CREDENTIALS`: Your complete Firebase service account JSON
62+
- `PORT`: (Automatically set by Railway)
63+
64+
### Frontend Service
65+
- `VITE_API_URL`: Your Railway backend URL
66+
- `VITE_CLERK_PUBLISHABLE_KEY`: Your Clerk publishable key
67+
- `NODE_ENV`: `production`
68+
69+
## Local Development
70+
Use the provided script:
71+
```bash
72+
./start-local.sh
73+
```
74+
75+
## Troubleshooting
76+
- **Build Failures**: Check Railway logs in the dashboard
77+
- **503 Errors**: Backend might be starting up (Railway has no cold starts)
78+
- **API Connection Issues**: Verify `VITE_API_URL` points to correct backend URL
79+
- **Firebase Issues**: Ensure `FIREBASE_CREDENTIALS` is properly formatted JSON
80+
- **Maven Issues**: Railway should automatically detect Java 17 from `pom.xml`
81+
82+
## Railway Advantages
83+
- ✅ Native Java/Maven support
84+
- ✅ No cold starts (unlike Render free tier)
85+
- ✅ Automatic deployments on Git push
86+
- ✅ Built-in database options
87+
- ✅ Easy environment variable management
88+
- ✅ Generous free tier ($5/month credit)
89+
90+
## Production Considerations
91+
- Consider using Railway's database services for production data
92+
- Set up custom domains for your services
93+
- Monitor usage to stay within free tier limits
94+
- Configure proper CORS origins for security

client/railway.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[build]
2+
builder = "NIXPACKS"
3+
4+
[deploy]
5+
startCommand = "npm start"

client/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { defineConfig, loadEnv } from "vite";
55
export default defineConfig(({ mode }) => {
66
const env = loadEnv(mode, process.cwd(), "");
77
return {
8-
base: process.env.NODE_ENV === 'production' && process.env.GITHUB_PAGES ? "/LanguageGO/" : "/",
8+
base: process.env.GITHUB_PAGES ? "/LanguageGO/" : "/",
99
build: {
1010
outDir: "build",
1111
},

0 commit comments

Comments
 (0)