From 15efe5b51b6989ccf63fbc263889edfb4940448c Mon Sep 17 00:00:00 2001 From: strandedturtle Date: Thu, 25 Jun 2026 17:02:07 +0000 Subject: [PATCH] fix: serve client SPA from the correct path in the Docker image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- server/Dockerfile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/Dockerfile b/server/Dockerfile index 4c8271e..8dbfe7b 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -34,9 +34,13 @@ RUN apk add --no-cache docker-cli docker-cli-compose WORKDIR /app -COPY --from=server-deps /app/node_modules ./node_modules -COPY server/package*.json ./ -COPY server/src ./src +# Mirror the repo's relative layout (server/src, client/dist) rather than +# flattening server/src to /app/src — index.js derives the client dist path +# from __dirname relative to its own location, and that math must match +# between local dev (run from the repo) and this image. +COPY --from=server-deps /app/node_modules ./server/node_modules +COPY server/package*.json ./server/ +COPY server/src ./server/src COPY --from=client-builder /app/client/dist ./client/dist EXPOSE 5000 @@ -46,4 +50,4 @@ EXPOSE 5000 HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ CMD node -e "fetch('http://127.0.0.1:'+(process.env.PORT||5000)+'/api/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))" -CMD ["node", "src/index.js"] +CMD ["node", "server/src/index.js"]