Skip to content

Conversation

@trillium
Copy link
Member

@trillium trillium commented Jun 26, 2025

Fixes #1860

What changes did you make and why did you make them?

Improved Backend Deployment Process:

  • Added a way to track which version of code is running on the server
  • Updated the automated deployment tools to use newer, more reliable versions
  • Added better logging so we can see what's happening during deployments
  • Improved the build process to be faster and more reliable

Enhanced Docker Setup:

  • Added version tracking to the production server setup
  • Created a file that stores build information inside the server
  • Made it easier to identify which code version is running

Better Health Check System:

  • Added a new function that can find the current code version in multiple ways:
    • First, it checks for a version number set during deployment
    • If that's not available, it reads from a build information file
    • As a last resort, it uses Git commands (useful for local development)
  • Updated the health check page to show the current version and when it was built
  • Added backup methods so the system still works even if some information is missing

You can test the health check endpoint with these commands:

# Check development environment
curl https://dev.vrms.io/api/healthcheck

# Check production environment
curl https://vrms.io/api/healthcheck
# Results:# Check development environment
curl https://dev.vrms.io/api/healthcheck
I'm Alive! Build: bbba8ae - 2025-06-26T19:24:46.576Z%

➜ # Check production environment                                    
curl https://vrms.io/api/healthcheck
I'm Alive!%                                  

Why these changes were made:

  • Fixes problems with the automated deployment system
  • Makes it easy to see which version of the code is running on each server
  • Helps developers quickly identify and fix deployment issues
  • Updates the deployment process to use current best practices
  • Provides reliable version tracking across all environments (development, staging, production)

Screenshot of actions panel:

Backend Build and Deploy Screenshot

Builds successfully when triggered with backendBuild

image

This change affects backend infrastructure and health check endpoint response only - no visual changes to the website frontend."

@trillium trillium requested a review from Copilot June 26, 2025 19:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds build version tracking to the health check endpoint by pulling a SHA from multiple sources, updates the Docker build to embed that SHA into a file and environment, and ensures the CI workflow passes the SHA through to build and deploy steps.

  • Introduce getBuildInfo() in the health check controller and include its output in the /isAlive response with a timestamp.
  • Extend Dockerfile.prod to accept a BUILD_SHA build argument, set it as an environment variable, and write it to a BUILD_INFO file.
  • Enhance the GitHub Actions workflow to capture BUILD_SHA, update action versions, debug-build variables, and pass the SHA into the Docker build and ECS deploy.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
backend/controllers/healthCheck.controller.js Added getBuildInfo() and enriched /isAlive response with build info
backend/Dockerfile.prod Added BUILD_SHA arg, ENV BUILD_SHA, and BUILD_INFO file write
.github/workflows/aws-backend-deploy.yml Captured BUILD_SHA, upgraded actions, and wired it through build/deploy
Comments suppressed due to low confidence (1)

backend/controllers/healthCheck.controller.js:6

  • The new getBuildInfo() function has multiple code paths (env var, file read, Git fallback). It would be valuable to add unit tests covering each scenario (valid SHA, missing file, Git unavailable, etc.).
function getBuildInfo() {

Comment on lines 41 to 43
HealthCheckController.isAlive = (_, res) => {
const buildInfo = getBuildInfo();
res.status(200).send(`I'm Alive! Build: ${buildInfo} - ${new Date().toISOString()}`);
Copy link

Copilot AI Jun 26, 2025

Choose a reason for hiding this comment

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

Calling getBuildInfo() on every request performs synchronous file I/O and possibly spawns Git processes each time. Consider reading and caching the build info once at startup to avoid per-request overhead.

Suggested change
HealthCheckController.isAlive = (_, res) => {
const buildInfo = getBuildInfo();
res.status(200).send(`I'm Alive! Build: ${buildInfo} - ${new Date().toISOString()}`);
cachedBuildInfo = getBuildInfo();
HealthCheckController.isAlive = (_, res) => {
res.status(200).send(`I'm Alive! Build: ${cachedBuildInfo} - ${new Date().toISOString()}`);

Copilot uses AI. Check for mistakes.
Copy link
Member

@JackHaeg JackHaeg left a comment

Choose a reason for hiding this comment

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

Thanks so much for making these changes, @trillium! This looks good. Approved :)

@trillium trillium merged commit 330a0ca into development Jun 26, 2025
3 of 5 checks passed
@trillium trillium deleted the backendBuild branch June 26, 2025 21:47
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.

Fix Backend Build Action

3 participants