📦 Packer ❤ DigitalOcean
At this day you have many choices to create new droplets, let see what we got so far via DigitalOcean…
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!
Packer is a free and open source tool for creating golden images for multiple platforms from a single source…www.packer.io
1. Homebrew for install Packer
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
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…
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!
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.