DEV Community

Discussion on: Deploying containerized NginX to Heroku - how hard can it be?

Collapse
 
narasimha1997 profile image
Narasimha Prasanna HN

Correct me if I'm wrong.
What is the use of deploying nginx and app within the same container? Basically if you're using nginx for load balancing, then it has to be a separate container and the backend microservice can be replicated across machines as containers. So you can achieve load balancing across machines.

Collapse
 
annisalli profile image
Anniina Sallinen • Edited

You are right! The app and load balancer would have a separate containers. In this case we don't have separate application, though.
In the Dockerfile RUN jekyll build generates static HTML pages, and in COPY --from=build-stage /usr/src/app/_site/ /usr/share/nginx/html we copy the generated pages for nginx to use. In nginx config, we tell nginx to serve those pages in

location / {
    root /usr/share/nginx/html;
    index index.html;
  }   
Enter fullscreen mode Exit fullscreen mode

Thus, we don't need any other containers.

Did I answer to your question? 😊

Collapse
 
narasimha1997 profile image
Narasimha Prasanna HN

Yes! Thanks 😀
Maybe I didn't go through the Dockerfile properly. For static sites this is a good approach.