At this day you have many choices to create new droplets, let see what we got so far via DigitalOceanā¦
- DigitalOceanās dashboard
- DigitalOceanās API
- DigitalOceanās CLI
For CI/CD sake weāll need to āship itā without GUI anyhow so we have to choose between API or CLI there. Far as I try, they serve you well with simple purposes like ā¦
- Create snapshot (for faster deployment process)
- Create droplets from image (including snapshot)
After mess with API and CLI youāll end up with plenty of builders, templates, variables, provisioners shell scripts and youāll have to repeat this again for other platforms. And yes this will take our times to maintain it allā¦
Good news! Packer is do just that!
Prerequisites
1. Homebrew for install Packer
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2. Packer
brew install packer
To create snapshot with Packerā¦
1. Create snapshot config name it snap.json
You can leave provisioners part empty, above itās just an examples.
2. Run it with your DigitalOcean API token.
DO_TOKEN=YOUR_TOKEN_HERE packer build snap.json
It will create temporary droplet for usā¦
And it will make snapshot then destroy temporary droplets after thatā¦
3. Done!
Now we got ubuntuz-1498983641 snapshot with ID = 26016450, letās use it!
To create droplet from snapshot.
- Create droplets config file named droplets.json
2. Create drop.sh shell script file
3. Run drop.sh with required parameters name, snapshot ID (from previous step)
DO_TOKEN=YOUR_TOKEN_HERE . drop.sh foo 26016450
And itās done! No more dashboard! Happy packing!
Note (ref)
Donāt miss a chance to get free $10 for DigitalOcean ā 2 months free hosting!
And do claim your cheapest .io name before itās gone at NameCheap.