Skip to content

AWS migration: run without Redis, production container, health check - #60

Merged
herin7 merged 3 commits into
mainfrom
aws-migration
Sep 8, 2026
Merged

herin7 merged 3 commits into
mainfrom
aws-migration

Conversation

@herin7

@herin7 herin7 commented Sep 8, 2026

Copy link
Copy Markdown
Owner

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/health reports 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 excludes node_modules.
  • .gitignore — ignore .vercel and local env files.

Verification

Deployed at https://gitforme.13.126.110.170.sslip.io and passing:

  • /api/health → 200, Mongo OK
  • /api/stats/user-count → 200 (live Mongo-backed)
  • /api/auth/verifyUser → 401 as expected for an unauthenticated request
  • CORS from https://gitforme-jbsp.vercel.app returns the origin with credentials allowed, and the deployed Vercel bundle calls the AWS host.

Notes

  • gitforme.tech is expired; the canonical frontend is https://gitforme-jbsp.vercel.app.
  • The .env files already committed on main still hold live credentials and should be rotated — this PR only stops new ones from being added.

🤖 Generated with Claude Code

Copilot AI lite review requested due to automatic review settings September 8, 2026 18:54
@vercel

vercel Bot commented Sep 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
gitforme-jbsp Ready Ready Preview Sep 8, 2026 6:54pm UTC

@herin7
herin7 merged commit eec9145 into main Sep 8, 2026
4 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 .dockerignore to reduce image size and improve runtime health reporting.
  • Extend .gitignore to 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.

Comment thread server/index.js
Comment on lines +25 to +29
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 });
Comment thread server/index.js
Comment on lines +99 to +103
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 });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants