#Layered Builds
A build can take its source from another build's output. This is how you compose a stack of modules, each layering on top of a previous one:
flowchart LR
Cloud[Debian cloud image] --> Base[base build<br/>installs guest tools]
Base --> Web[web build<br/>adds nginx]
Base --> DB[db build<br/>adds postgres]
Web --> WebApp[webapp build<br/>adds your app]
vms:
- name: builder
source:
buildRef:
name: base-debian # name of the previous build
vmName: builder # required if base has multiple VMs
provisioners:
- type: shell
shell:
inline: |
sudo apt-get install -y postgresql
The referenced build must already be in Succeeded state — otherwise the layered build fails immediately. So your build order matters: run the base build first and wait for it to succeed, then run the layered build that references it.