Code Monkey home page Code Monkey logo

opi-on-bitcoin-oracle's Introduction

OPI.network / Bitcoin Oracle integration

This project contains infrastructure code for deploying an OPI node on DigitalOcean using Pulumi. It will create a new DigitalOcean droplet, and mount a volume to it, install bitcoind, OPI softwares such as ord, postgres, and various indexers, and configure it to run. It will also run the restoration script to restore the latest snapshot of the postgres database and ord database. After the restore is complete, it will run all services required.

Contents

The project contains the following files:

  • .envrc - Environment variable definitions
  • .tool-versions - Tool versions
  • deploy/Pulumi.yaml - Pulumi project configuration
  • deploy/package.json - Node.js dependencies
  • deploy/Pulumi.dev.yaml - Pulumi configuration for dev environment
  • configs/ - Configuration scripts

Getting Started

DigitalOcean account

You need an account at DigitalOcean and need to be familiar with

Setup asdf

The project uses asdf to manage tool versions. To use it, install asdf and run asdf install in the project directory. This will install pulumi, pnpm, and nodejs with version specified in .tool-versions

asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
asdf plugin add pulumi
asdf plugin add pnpm  
asdf install

Setup direnv

The project uses direnv to manage environment variables. To use it, install direnv and run direnv allow in the project directory.

Create .envrc.override file in the project directory and add the following:

Install DigitalOcean CLI

# run `doctl compute ssh-key list` to get name and id
export DIGITAL_OCEAN_SSH_KEY_NAME=""
export DIGITAL_OCEAN_SSH_KEY_ID=""
# the path to the SSH private key that maps to the above SSH key name/ID, such as `~/.ssh/id_rsa`
# For automated deployment, do not set password for the private key.
export PRIVATE_KEY_PATH=""
# visit `https://cloud.digitalocean.com/account/api/tokens` to get API key
export DIGITAL_OCEAN_API_KEY=""

# set following name for report to OPI network.
# dashboard url: https://opi.network/
export REPORT_NAME=""

Make sure you run direnv allow so the new environment variables are applied.

Bootstrap Automatically

A bootstrap script is located at tools/bin/bootstrap. After setup above requirements, run bootstrap to initialize the project. It will run the following steps:

  • pnpm install to install dependencies
  • node gen-config.js to generate config.user.yaml file, which will take precedence over config.yaml
  • set digital ocean api key to pulumi secrets.
  • run pulumi up to deploy the infrastructure.
bootstrap

Deploy Manually

  1. Edit file deploy/src/config.yaml to config the settings.
  2. Install dependencies
cd deploy
pnpm install
  1. Set digitalocean token via pulumi config set, make sure you have DIGITAL_OCEAN_API_KEY in your environment variables.
pulumi config set digitalocean:token $DIGITAL_OCEAN_API_KEY --secret
  1. Run pulumi up to deploy the infrastructure.
cd deploy
pulumi up

This will deploy a DigitalOcean droplet with Docker and run the necessary OPI containers. The droplet can be accessed via SSH using the defined SSH key.

Others

ssh config setting

it's recommended to add following to ~/.ssh/config to avoid interrupt ssh connection while provision the instance.

TCPKeepAlive yes
ServerAliveInterval 30
ServerAliveCountMax 4

Resources

opi-on-bitcoin-oracle's People

Contributors

caoer avatar fiftyeightandeight avatar

Stargazers

Mr.Patrix avatar

Watchers

 avatar  avatar  avatar

Forkers

pulumi-ce

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.