This repository contains resources for creating a standalone instance of the stacks-blockchain with postgres and the stacks-blockchain-api
Common files used by all providers are located at the base of this repo, like files and scripts.
Specific configurations for each provider are located under the packer directory, with providers each having their own folder, like ./packer/digitalocean
.
To start adapting these templates for your own image, you can customize some variables in ./packer/<provider>/debian.json
:
apt_packages
lists the APT packages to install on the build Droplet.application_version
defines the stacks-blockchain versionimage_name
defines the name of the resulting snapshot, which by default isstacks-blockchain-X.X.X.X
with a UNIX timestamp appended.
You can also modify these variables at runtime by using the -var
flag.
Note that the paths in the templates are set so that you'll need to invoke the packer
command from the root of this repo.
The scripts folder contains the scripts packer
uses to setup the host.
- 01-docker.sh - Installs Docker, docker-compose and required packages.
- 02-stacks-blockchain.sh - Clones stacks-blockchain-docker and creates the unit file.
- 02-ufw.sh - Configures simple Firewall.
- 03-bns.sh - Downloads and extracts BNS data and enables the env var for the API.
- 90-cleanup-no_dd.sh - Cleans the built system/logs without zeroing the disk.
- 90-cleanup.sh - Cleans the built system/logs and zeroes the disk.
- 99-img-check.sh - Checks the snapshot for any build artifacts.
In 03-bns.sh, comment the following lines:
echo "=== Enable stacks-blockchain-api BNS data ==="
sed -i -e 's|# BNS_IMPORT_DIR|BNS_IMPORT_DIR|' /opt/stacks-blockchain-docker/.env
echo "=== Downloading BNS Data ==="
BNS_IMPORT_DIR="/opt/stacks-blockchain-docker/persistent-data/bns-data" /opt/stacks-blockchain-docker/scripts/setup-bns.sh
In 02-stacks-blockchain.sh, comment the following lines:
echo "=== Enable stacks-blockchain-api fungible metadata ==="
sed -i -e 's|# STACKS_API_ENABLE_FT_METADATA|STACKS_API_ENABLE_FT_METADATA|' /opt/stacks-blockchain-docker/.env
echo "=== Enable stacks-blockchain-api non-fungible metadata ==="
sed -i -e 's|# STACKS_API_ENABLE_NFT_METADATA|STACKS_API_ENABLE_NFT_METADATA|' /opt/stacks-blockchain-docker/.env
$ packer build ./packer/digitalocean/debian.json
AWS template uses a slightly different cleanup script than DigitalOcean, specifically there is no dd
to zero the disk before the image is created. With this included, the process frequently timed out.
$ packer build ./packer/aws/debian.json