Deploying dars across multiple environments

When deploying the same dar across multiple environment, I think it would be critical that the full package id be the same across the environments. In this way, the client code would reference the same <package_name>-<package_id> across all environments. That way the package-id could be checked into source code. Otherwise would the package id be set in an environment variable?

What is the best way to ensure this is the case?

Is it normal that the dar would be compiled on a single build server, and then the identical dar is deployed to all servers? Or would it be normal to run daml build on all servers?

Is it possible that daml build on the same source code compiles to a different package id? For example if the sdk version is different or there are other environment differences, would that produce a different package id?

DAR compilation is deterministic (in single-threaded mode which is the default) so if you don’t change source which includes your daml.yaml file and therefore the SDK version, you can safely recompile on different environments. So something ilke checking out the same commit of a repo and running daml build there on different servers is perfectly reasonable.

Alternatively a staged build pipeline is also a reasonable option just to avoid duplicated work but that’s somewhat independent of Daml.