fix: serve client SPA from the correct path in the Docker image#5
Merged
Conversation
server/src/index.js derives the client dist directory from __dirname
relative to its own location, expecting the on-disk layout to match the
repo (server/src and client/dist as siblings under one root). The
Dockerfile instead flattened server/src to /app/src, so that math
overshot to /client/dist instead of /app/client/dist — the running
container always logged "No client build found" and served nothing for
non-API routes ("Cannot GET /" in the browser, though /api/health still
worked fine).
Fix the image layout to mirror the repo instead of changing the path
math, so local dev and the container resolve identically.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/api/healthworking fine.server/src/index.jsresolves the client dist directory aspath.join(__dirname, '..', '..', 'client', 'dist'), assumingserver/srcandclient/distare siblings under one root. The Dockerfile flattenedserver/srcto/app/src, so that math landed on/client/distinstead of/app/client/dist— matching the log line the user saw (No client build found at /client/dist)./app/server/src,/app/client/dist) instead of changing the path math, so local dev and the container resolve identically.Test plan
cd server && node --test— 60/60 passingcd client && npm run build— clean build__dirnamemath resolves to/app/client/distfor the new image layout and<repo>/client/distfor local dev (script-checked, no Docker daemon available in this environment):edgeafter merge and confirm the dashboard loads in browserGenerated by Claude Code