What Splitting a Docker Image Actually Costs You (SPA Routing, CORS, and Five More Surprises)
A few weeks into DevOps work on our team's chama (savings-group) app, I made a call that seemed simple on paper: ship the Go backend and the React frontend as one combined Docker image, let the backend serve both the API and the static files. It worked. Then, later, the team moved to two separate images instead, one for the backend, one for the frontend behind nginx. That second move is what this…
The original plan to combine the Go backend and React frontend into one Docker image seemed simple. However, it revealed several unexpected consequences once they moved to separate images. First, the nginx server handling the frontend had to address the same routing issue the backend previously solved. Second, enabling CORS became necessary when the services ran on different ports.
Third, the frontend needed to know the backend's URL, which required setting an environment variable. Fourth, the decision of which Docker image to use in production differed between the frontend and backend, as the latter requires a platform for long-running processes. Lastly, configuration drift emerged, with database credentials scattered across multiple places, leading to recurring bugs.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.