Hi Guys! I have a question about best practises in...
# getting-started
d
Hi Guys! I have a question about best practises in my scenario. Currently, we serve many smaller apps which already run on their own using a docker compose (typically nginx + app + postgres), and they are quite similar in deployment. Practically, the deployment can be the same, except for maybe some environment variables. Is it possible we could reuse a stack (each with it’s own dev + staging + production) environment for each app? Would it be possible to have a single git repository containing this pulumi code?
l
If you consider the apps to be one thing with different flavours, then yes, you could use one project with multiple stacks to achieve this. The only downside would be that you'd need lots of stacks: app1-dev, app1-staging, app1-europe, app1-apac, then app2-, app3-, etc. It would become a bit messy to track.
A more common way of achieving this would be to put your reusable code in a ComponentResource(s) and have a project for each app use that code. Each project would have its own stacks.
You could put your ComponentResource(s) in a shared language resource: a jar, dll, NPM package, or whatever.
d
Thanks! I was indeed leaning more towards that approach, and currently have a stack per app. The reusable code I just listed in a separate package using tsconfig’s references 🙂
s
We (Pulumi) have a series of blog posts (starting with https://www.pulumi.com/blog/iac-recommended-practices-code-organization-and-stacks/) that may help.