Hi everyone!
I just discovered Traefik some days ago and I managed to use it in my docker-compose.yaml file to “orchestrate” all my services (db, backend, frontend, redis, grafana tools, traefik, …). Now I have a working setup, I’m thinking about how to organize and deploy it to have both production and staging environments on a same server (because my company only provides me a single server).
After some thinking, I think I have 2 solutions:
- Consider that my docker-compose.yaml file represents a full environment and I deploy it 2 times, one for production, one for staging. Each traefik instances listen to different ports (like 80/443 for prod, 8080/8043 for staging) and I use an nginx instance on the server to route to the right environment according to the domain name (like domain.com for prod, staging.domain.com for staging).
- Optimize the management of my containers by developing the infra containers only once (db, traefik, redis, …) and deploying the app 2 times. In this case, I could have 2 different docker networks ‘prod-network’ and ‘staging-network’.
I like the option (1) because it cleary separates both environments and if I want to test some upgrade of the infra part, I can safely do it in the staging env first, and then update the prod env. But several containers like the db are duplicated which is not so efficient.
I like the option (2) for its efficiency but it looks more complicated to manage, with a risk of conflicts/interference between both environments.
As I have not a lot of experiences in term of devops and I’m solo dev for this project, I would really appreciate your opinions about that. You would probably see some advantages/drawbacks for these 2 solutions that were not clear for me.
Thanks!
Remy