Let's look at an example of running HashiCorp Packer to build a virtual machine instance image that is preconfigured with your application:
{
variables : {
do_api_token : {{env `DIGITALOCEAN_ACCESS_TOKEN`}} ,
region : fra1 ,
packages : "customer"
version : 1.0.3
},
builders : [
{
type : digitalocean ,
api_token : {{user `do_api_token`}} ,
image : ubuntu-20-04-x64 ,
region : {{user `region`}} ,
size : 512mb ,
ssh_username : root
}
],
provisioners: [
{
type : file ,
source : ./{{user `package`}}-{{user `version`}}.deb ,
destination : /home/ubuntu/
},
{
type : shell ,
inline :[
dpkg -i /home/ubuntu/{{user `package`}}-{{user `version`}}.deb
]
}
]
}
In the preceding code, we provide the required credentials and region and employ a builder to prepare an instance from the Ubuntu image for us. The instance...