Closed nareshbhatia closed 2 years ago
Don't build your own proxy image. Instead mount the volume with the proxy configuration file. This saves a lot of time when building the image and makes it easier for documentation purposes.
This then makes it no different from an .env file (or environmental configuration) and hence you can just specify http://proshop-catalog:3001
as the proxy_pass. See how much easier it is now?
You are also unnecessarily exposing the ports in your Docker Compose. Instead create a Docker network.
This example is for vue and fastapi, but the principle remain for the both points: https://github.com/nguqtruong/nginx-fastapi-vuejs/blob/master/docker-compose.yml
Thank you for the pointers. Let me try this.
Thanks @themegaphoenix. I have fixed this using your suggestions.
http://proshop-catalog:3001
. Please see my new docker-compose.yaml.3. I didn't create a custom Docker network because I was able to address all services by simply using their service names, e.g.
http://proshop-catalog:3001
. Please see my new docker-compose.yaml.
Slight correction. By default, docker-compose creates a network for each compose file: https://runnable.com/docker/docker-compose-networking#:~:text=Docker%20Compose%20sets%20up%20a,other%20container%20on%20the%20network.
Good work!
For further improvements see this: https://stackoverflow.com/a/42174904
You can specify the build or the image name, and either build all the images (docker-compose build
) or run the prebuilt images (docker-compose up
, if the images are not found then it will build them anyway)
Thanks @themegaphoenix, I find your pointers and links very very useful.
Nginx configuration is currently setup with hard-coded URLs for catalog and cart apps, e.g.
http://192.168.86.247:3001/catalog
(see proxy/default.conf). Could not figure out a way to specify these dynamically.There is a concept of substituting environment variables in Ngnix config from docker-compose however I could not make it work.