Skip to content

Image validation, automation, and other tools for Public Cloud providers

License

Notifications You must be signed in to change notification settings

stacksfoundation/stacks-machine-images

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stacks Blockchain Image building tools

Apache license Pull Requests Welcome

This repository contains resources for creating a standalone instance of the stacks-blockchain with postgres and the stacks-blockchain-api

Requirements

Supported Providers

⚠️ PR's Welcome for other providers

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 version
  • image_name defines the name of the resulting snapshot, which by default is stacks-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.

  1. 01-docker.sh - Installs Docker, docker-compose and required packages.
  2. 02-stacks-blockchain.sh - Clones stacks-blockchain-docker and creates the unit file.
  3. 02-ufw.sh - Configures simple Firewall.
  4. 03-bns.sh - Downloads and extracts BNS data and enables the env var for the API.
  5. 90-cleanup-no_dd.sh - Cleans the built system/logs without zeroing the disk.
  6. 90-cleanup.sh - Cleans the built system/logs and zeroes the disk.
  7. 99-img-check.sh - Checks the snapshot for any build artifacts.

Disable BNS data (Optional)

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

Disable NFT/FT metadata (Optional)

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

DigitalOcean

Readme

Packer Template

$ packer build ./packer/digitalocean/debian.json

Sample Output

AWS

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.

Readme

Packer Template

$ packer build ./packer/aws/debian.json

Sample Output