AWS migration: run without Redis, production container, health check - #60
Conversation
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
🟡 Changes recommended
Redis is still effectively mandatory when REDIS_URL is set but unreachable because the session store is configured anyway, and the health endpoint/HEALTHCHECK combination can cause restart loops in that degraded Redis state.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates the backend deployment posture for an AWS host by making Redis optional (to avoid failures when the configured Redis endpoint is unavailable), adding a production-oriented Docker image (with a container health check), and tightening ignored build/artifact files.
Changes:
- Make Redis optional for sessions and stats caching, and expose Mongo/Redis state via
/api/health. - Add a production Dockerfile and
.dockerignoreto reduce image size and improve runtime health reporting. - Extend
.gitignoreto avoid committing Vercel metadata and local env files.
File summaries
| File | Description |
|---|---|
| server/util/RediaClient.js | Adds bounded reconnect and tolerates Redis connection failure at startup. |
| server/index.js | Makes Redis/session store conditional and adds a health endpoint reporting Mongo/Redis state. |
| server/Controllers/StatsController.js | Bypasses stats caching when Redis is disabled/unready. |
| server/Dockerfile | Updates base image, installs prod deps, and adds a Docker HEALTHCHECK. |
| server/.dockerignore | Excludes node_modules, env files, git metadata, and coverage from Docker build context. |
| .gitignore | Ignores .vercel and .env* files to reduce accidental secret commits. |
Review details
- Files reviewed: 5/6 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| const RedisStore = require("connect-redis").default; | ||
| redisClient = require("./util/RediaClient"); | ||
| redisClient.on('error', (err) => console.error('Redis Client Error:', err.message)); | ||
| redisClient.on('connect', () => console.log('✅ Connected to Redis')); | ||
| sessionStore = new RedisStore({ client: redisClient, prefix: config.redisPrefix }); |
| const mongo = mongoose.connection.readyState === 1 ? "ok" : "unavailable"; | ||
| const redis = !redisClient ? "disabled" : redisClient.isReady ? "ok" : "unavailable"; | ||
| const healthy = mongo === "ok" && (redis === "ok" || redis === "disabled"); | ||
| res.status(healthy ? 200 : 503).json({ status: healthy ? "ok" : "degraded", mongo, redis }); | ||
| }); |
Migrates gitforme's backend off Render onto the shared AWS host, and makes the service survive its expired Redis provider.
Changes
server/util/RediaClient.js— Redis becomes optional. Its credits are exhausted and the configured hostname is NXDOMAIN, which previously caused a continuous reconnect-error loop.server/index.js— fall back to in-memory sessions and JWT when Redis is absent;/api/healthreports Mongo and Redis state.server/Controllers/StatsController.js— bypass the cache when Redis is disabled. This path imported Redis directly and returned 500 on the public user-count endpoint even though the session layer was already optional.server/Dockerfile,server/.dockerignore— production image and a build context that excludesnode_modules..gitignore— ignore.verceland local env files.Verification
Deployed at
https://gitforme.13.126.110.170.sslip.ioand passing:/api/health→ 200, Mongo OK/api/stats/user-count→ 200 (live Mongo-backed)/api/auth/verifyUser→ 401 as expected for an unauthenticated requesthttps://gitforme-jbsp.vercel.appreturns the origin with credentials allowed, and the deployed Vercel bundle calls the AWS host.Notes
gitforme.techis expired; the canonical frontend ishttps://gitforme-jbsp.vercel.app..envfiles already committed onmainstill hold live credentials and should be rotated — this PR only stops new ones from being added.🤖 Generated with Claude Code