Best practice for deploying multiple static files projects

Hello,
I have to deal with a few static files projects (HTML+CSS+JS) served at:

project1.exampe.org
project2.exampe.org
project3.exampe.org

Those are independent codebases with their own git repo. I read that Traefik does not serve static files like a Web server does, so I have to use a Web server (e.g., Ngnix) behind the scenes. Here comes my question: which is the best practice for this scenario

Solution A: Traefik + "n" Nginx containers

Internet
   |
Traefik 
   |-----> Nginx Container 1 (w/ project 1)
   |-----> Nginx Container 2 (w/ project 2)
   |-----> Nginx Container 3 (w/ project 3)

Solution B: Traefik + just a central Nginx container

Internet
   |
Traefik 
   |-----> central Nginx Container (w/ project 1, 2 and 3)

Solution A looks easier but it requires to spin up an Nginx container for each static project. Solution B uses just one Nginx container but it is way more complex (e.g., you need to mount or to copy each codebase into the central Nginx container).

I was wondering if there is a golden rule to set up that kind of environment and, if any, if it is A or B.

Thanks

Traefik will handle both scenarios equally well.

1 Like

Solution A. It is more modular and you can independently deploy projects.

1 Like

Thank you guys for your hints. As pointed out, solution A is way more modular. Any drawbacks in running multiple Nginx containers (e.g., memory usage)?

You can probably limit the memory for each Nginx container to 8MB. docker stats can show you the memory utilization.

1 Like