LangGraph Build Fails Locally? Build the Docker Image on a Server Instead
This gives Western developers a concrete fallback when LangGraph's local Docker build fails on Macs due to image registry issues, plus a clean nginx recipe for exposing a chat front end to a localhost-only model API.
A Mac user hit repeated failures with langgraph build because Docker could not download images, and mirror source changes did not fix it. The workaround is to build the Docker image on a remote server, where langgraph itself does not need to be installed.
The official langgraph dockerfile command generates a Dockerfile and docker-compose.yml. Regenerating that Dockerfile is required whenever langgraph.json changes, otherwise the image drifts from the configuration. docker-compose up -d then starts Redis, PostgreSQL, the custom image, and environment variables in one step.
The post then wires a Vite-based chat front end to the server. An nginx config serves the built dist files, proxies /lg/ to a localhost-only model API on port 8123, and includes streaming-friendly settings like proxy_buffering off. It also blocks common scanner paths and returns a custom 429 response for rate limiting.
LangGraph's official CLI assumes Docker can pull images, but on systems with restricted registry access the failure is not easily fixed by changing mirrors, so a server-side build is a pragmatic alternative.
The regeneration requirement for the Dockerfile ties the build closely to langgraph.json, meaning config changes must be remembered to avoid stale images.
Serving a chat UI with nginx and a localhost-only model API is a common pattern for keeping the model endpoint private while still allowing a public front end.
The author's use of AI-generated code for the front end suggests that the main technical friction in this stack is the infrastructure setup, not the chat UI itself.
Let me add three more pitfalls you'll hit later. First, during build, pulling the image is done by your local Docker daemon, and changing pip or npm sources has zero effect on it—what you need to change is Settings → Docker Engine → registry-mirrors in Docker Desktop, and it only takes effect after Apply & Restart. Likewise, the HTTPS_PROXY you export in your shell isn't read by the daemon; you have to fill it in under Resources → Proxies separately. That's probably the real reason 'changing mirrors didn't work.' Second, your nginx buffer parameters are right, but you're missing proxy_http_version 1.1: the default is 1.0, which sends 'Connection: close' upstream and breaks streaming anyway. Also bump proxy_read_timeout from the default 60 seconds to 600 seconds, otherwise a longer graph gets cut off after a minute and the frontend only sees half a sentence, with no error—very hard to debug. Third, the Dockerfile in the directory is a generated artifact; you've already written that it must be regenerated when langgraph.json changes, but conversely don't hand-edit it—the next regeneration will overwrite it. Dependency changes should go into langgraph.json, or be appended after generation.
Wow, all useful stuff, thanks for the guidance 🙏🏻