I'm trying to decide whether it's better to run nginx as its own container, not containing the client app on it. Then run another container that is the client app. And a third will be a container serving a backend API
I found that trying to combine nginx with a client app's code in a Dockerfile or on the same nginx container instance is not very clean. You end up having to use multi-builds in Docker or some other way to first dockerize your client app before you run nginx over it. So thinking about splitting this out into 2 separate containers to keep it clean.
So I'll end up with 3 Dockerfiles and then use Docker compose to run them:
nginx.Dockerfile (Will use the nginx image from dockerhub. Is it possible to tell nginx.conf to point to index.html of my client container via localhost resolution somehow and not look in `/usr/share/nginx/html`?)
client.Dockerfile (ReactJS front-end, dist code from webpack)
backend.Dockerfile (server - RESTful or GraphQL Data API)
Goal:
I'd prefer not to mix/have my client app code in the nginx container. I'd like to decouple that from the nginx container...which is why I'm saying I want 3 containers here to keep things decoupled from one another. I realize my nginx.conf
will need to find where index.html
is of my client app but I want to do so not in the same container.
Put another way, I'm wondering if there's a way to tell nginx.config
via localhost
to find index.html
over say port 80
which is the port my separate client container will be exposing that file from. So instead of having nginx find index.html
in /usr/share/nginx/html
(same container with client app code) can I tell it to look through localhost:80 which is from my client app container? I want my nginx container to run independently of the client code. Or is that completely not possible and I must copy my client app code into /usr/share/nginx/html
and that's the only way, they must live together in the same image and my dreams of decoupling don't make sense?
My client app will still have an expressJS server but just for serving static assets. My backend will be another express API for serving data back up to the client.