Both approaches you described are working solutions with own pros and cons. The right choice depends on your needs.
1. Pre-baked Template (manual, but reliable)
Pros:
- Fast VM startup since dependencies are already installed
- Ability to fine-tune the VM environment for each release
Cons:
- Requires manual image creation and configuration for every release
When to use:
- If you have very infrequent releases
- If you just a chill guy and don't want to bother about automation (e.g., demo environments, pet projects, etc.)
2. Lightweight Template & Startup Script (automated, but dependent)
Pros:
- Zero manual actions required when releasing a new app version
Cons:
- Slower startup since each new VM must install dependencies
- Instance creation depends on dependency availability (the startup script might fail)
When to use:
- If you have frequent releases and don’t anticipate breaking changes in the environment
- If you can tolerate dependency installation time for each new instance
However, I cannot fail to mention that the approaches above only make sense for stateful apps where local data persistence.
From your description, it’s unclear whether your «simple app running on Node.js» is stateful or not. If it’s stateless, consider using Cloud Run or App Engine, depending on your specific requirements (scalable by design, minimal maintenance, and most likely much cheaper than MIG).