22
loading...
This website collects cookies to deliver better user experience
export DIGITALOCEAN_TOKEN="MY_TOKEN"
Don't forget to replace MY_TOKEN with the actual token
Builders
let you create images on various platforms like AWS EC2 and DigitalOcean, while provisioners
let you run commands and manipulate the VM before creating the image.{
"variables": {
"version": "VERSION-OF-YOUR-APP",
"do_token": "{{env `DIGITALOCEAN_TOKEN`}}"
},
"builders": [{
"type": "digitalocean",
"api_token": "{{user `do_token`}}",
"image": "ubuntu-20-04-x64",
"region": "nyc3",
"size": "s-4vcpu-8gb",
"ssh_username": "root",
"droplet_name": "myapp-{{user `version`}}",
"snapshot_name": "myapp-{{user `version`}}-{{timestamp}}"
}],
"provisioners": [{
"type": "file",
"source": "files/one-click-image",
"destination": "/etc/update-motd.d/one-click-image"
}, {
"type": "shell",
"scripts": [
"scripts/my-script.sh"
]
},{
"type": "shell",
"inline": [
COMMANDS HERE
.
.
.
]
}]
}
do-rocketchat
and create a file called builder.json
in it. The file should like following{
"variables": {
"version": "latest",
"do_token": "{{env `DIGITALOCEAN_TOKEN`}}"
},
"builders": [{
"type": "digitalocean",
"api_token": "{{user `do_token`}}",
"image": "ubuntu-20-04-x64",
"region": "nyc3",
"size": "s-1vcpu-1gb",
"ssh_username": "root",
"droplet_name": "rocketchat-{{user `version`}}",
"snapshot_name": "rocketchat-{{user `version`}}-{{timestamp}}"
}],
"provisioners": [ {
"type": "shell",
"inline": [
"sleep 20",
"sudo apt-get update -y",
"sudo apt-get upgrade -y",
"sudo snap install rocketchat-server"
]
}
]
}
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install packer
packer build builder.json