Next.js Discord

Discord Forum

nginx / docker dependency loop

Unanswered
Short-eared Owl posted this in #help-forum
Open in Discord
Short-eared OwlOP
I've got two docker-compose files and two separate repos.

cms compose contains my content management system and database.

my frontend (next) docker-compose contains nextjs, nginx and certbot.

during the build phase of the frontend docker-compose, build fails because it cannot access the cms container while the container is building and the build fails due to the cms hostname not being found. (as far as I understand, during the container build, you cannot use the docker network?) So basically, it feels like frontend cannot build unless it can access the cms and it cannot access the cms because nginx requires each container to be reachable in order to start.

What can I do in order to resolve this? Using an external docker network doesn't work, as docker network is unavailable during container build.

Is there a way to make your nextjs application build, even if the server fetches fail? Once build succeeds and docker networks are online, it'll have no problem fetching data from the cms.

4 Replies