Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

fix(docker): give the development image the web source it compiles from

Bingxi Zhao (Frank)083ff4fe3dc5
diff --git a/Dockerfile b/Dockerfile
index 73dc72145..7476b9a12 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -443,16 +443,24 @@ ENTRYPOINT ["/app/entrypoint.sh"]
# ============================================
FROM production AS development
-# Re-add full node_modules for development hot-reload
-# (Production uses standalone output which doesn't include full node_modules)
-COPY --from=frontend-builder /app/web/node_modules ./web/node_modules
-COPY --from=frontend-builder /app/web/package.json ./web/package.json
-COPY --from=frontend-builder /app/web/next.config.js ./web/next.config.js
+# `next dev` compiles from source, so the development image needs the whole
+# web tree. This used to cherry-pick node_modules, package.json and
+# next.config.js on top of the production stage — but that stage's ./web is
+# `.next/standalone/`, a compiled server bundle carrying no sources, no
+# tsconfig and no scripts/. So the supervisor program below launched
+# `node scripts/dev.mjs` against a path that never existed, the dev frontend
+# went FATAL, and the image looked broken (#906). Taking the builder's tree
+# wholesale also stops the list from drifting each time web/ grows a
+# top-level entry. `--chown` during the copy avoids re-layering node_modules.
+COPY --chown=deeptutor:deeptutor --from=frontend-builder /app/web ./web
# `next dev` runs as the unprivileged deeptutor user (via `user=deeptutor` in
# the supervisord config) and must create/write its build cache under
# /app/web/.next, so give that user ownership of the web dir and the cache.
-RUN mkdir -p /app/web/.next \
+# The production build copied in above is not reusable by `next dev`, so it
+# starts from an empty cache rather than a half-valid one.
+RUN rm -rf /app/web/.next \
+ && mkdir -p /app/web/.next \
&& chown deeptutor:deeptutor /app/web /app/web/.next
# Install development tools
diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml
index 4f15e8e6a..162668db9 100644
--- a/docker-compose.dev.yml
+++ b/docker-compose.dev.yml
@@ -24,9 +24,12 @@ services:
- ./deeptutor_cli:/app/deeptutor_cli:ro
- ./scripts:/app/scripts:ro
- # Mount frontend source for hot-reload
+ # Mount frontend source for hot-reload. Anything not listed here still
+ # ships inside the image (see the development stage in Dockerfile) — it
+ # just will not hot-reload.
- ./web/app:/app/web/app:ro
- ./web/components:/app/web/components:ro
+ - ./web/features:/app/web/features:ro
- ./web/lib:/app/web/lib:ro
- ./web/hooks:/app/web/hooks:ro
- ./web/context:/app/web/context:ro