Running BTCPay on Digital Ocean for $10/month (+ how to add other coins)

Mike Olthoff
Mar 4, 2019 · 6 min read
Image for post
Image for post

Last Updated October 4, 2019

Digital Ocean is often my “goto” for small scale deployments that I know I can easily backup via snapshots and redeploy without much hassle. With this, I think it makes perfect sense to have a BTCPay instance on Digital Ocean.

With this guide, we will walk through setting up a new droplet with docker, logging into your server and starting a pruned BTCPay node complete with the lightning network.

As an added bonus, I will also show you how to add additional coins using Digital Ocean’s Block Storage Volumes, basically dynamic drive space you can turn on and off. Adding altcoins is usually fairly cheap as their chains are very small compared to BTC.

Step 1 — Open an account at Digital Ocean

Step 2 — Create a Droplet

Select “Marketplace” from the top bar, and then select “Docker”.

Scroll down to the “Choose a Plan” options and select “Standard”. I suggest selecting the $10 plan as it comes with 2GB of ram and 50GB of hard drive space.

You can optionally add backups if you want weekly backups of your server.

Select your Datacenter of preference and choose a hostname, for this example we will just call it btcpay-sample.

Create the Droplet. You will be emailed login details.

If you haven’t done so, make sure to point setup your DNS to point your chosen domain name to the IP of your new droplet.

Step 3 — Login to the Droplet

(This assumes you know how to login to servers with SSH. If you are using a windows machine, try PuTTY)

Image for post
Image for post

You will be asked to change your password immediately.

Step 4 — Setup BTCPay Server

mkdir BTCPayServer
cd BTCPayServer
git clone https://github.com/btcpayserver/btcpayserver-docker
cd btcpayserver-docker

This will make a BTCPay directory and download the docker files into it.

Here is a breakdown of each line we are going to add next:

Full code:

export BTCPAY_HOST="btcpay-sample.EXAMPLE.com"
export NBITCOIN_NETWORK="mainnet"
export BTCPAYGEN_CRYPTO1="btc"
export BTCPAYGEN_REVERSEPROXY="nginx"
export BTCPAYGEN_LIGHTNING="lnd"
export BTCPAY_ENABLE_SSH=true

export BTCPAY_HOST=”btcpay-sample.EXAMPLE.com”

export NBITCOIN_NETWORK=”mainnet”

export BTCPAYGEN_CRYPTO1=”btc”

export BTCPAYGEN_REVERSEPROXY=”nginx”

export BTCPAYGEN_LIGHTNING=”lnd”

export BTCPAY_ENABLE_SSH=true

  • The Update button in ServerSettings/Maintenance will work properly
  • It allows you to add your own SSH keys to your server if you have access to btcpayserver admin account

We also need to decide if we will be running a FULL Bitcoin node or a pruned node. A pruned node can run for as little as $10/month. If you wish to run a full bitcoin node, we can later add a full 300gb storage volume to our digital ocean droplet for approx an additional $30/month.

If you wish to run a full node, skip to step 5.

If you wish to run a pruned node, simply add the following command to will ensure our node only keeps about 3 months of blocks (Approx 25gb of space):

export BTCPAYGEN_ADDITIONAL_FRAGMENTS="opt-save-storage-xs"

Step 5— Installation

. ./btcpay-setup.sh -i

This process will take between 5–10 minutes.

Once completed, I would also recommend you open the ports needed for your bitcoin node and lightning node to communicate properly to other nodes:

sudo ufw allow 43782
sudo ufw allow 39388
sudo ufw allow 9735

If you have added or plan to add woocommerce to your installation, also open the woocommerce ports:

sudo ufw allow 80
sudo ufw allow 443

Thats it, Installation is now complete. You should now be able to navigate to your chosen domain name! BTCPay should be up and running and downloading the BTC Blockchain!

Step 6 (Full Node Option)

Log back into your Digital Ocean instance

Select “Create -> Volumes”

Go back to your ssh window where you installed BTCPay.

Stop BTCPay while we move the files

~/BTCPayServer/btcpayserver-docker/btcpay-down.sh

Move the Bitcoin data dir to your new drive and then create a symlink to the drive to replace it:

mv /var/lib/docker/volumes/generated_bitcoin_datadir /mnt/btcfullchain/generated_bitcoin_datadirln -s /mnt/btcfullchain/generated_bitcoin_datadir /var/lib/docker/volumes/generated_bitcoin_datadir

Start BTCPay back up

~/BTCPayServer/btcpayserver-docker/btcpay-up.sh

Your server will now be up and running again, and all bitcoin data will be stored on /mnt/btcfullchain. When your drive becomes full as the blockchain becomes bigger, simply shut down btcpay, resize your drive on digital ocean to a larger size and then restart btcpay.


Bonus — Adding Altcoins as needed

The same process as step 6 can be modified to add altcoins in seperate drive partitions as well.

For this example, we will add dogecoin to our server! wow! such coin!

Image for post
Image for post

Dogecoin is approx 34gb of space at the time of this tutorial, so we will create a 40gb drive.

Log back into your Digital Ocean instance

Select “Create -> Volumes”

Go back to your ssh window where you installed BTCPay.

Add Dogecoin(or other alts) to the config for BTCPay and rebuild:

cd ~/BTCPayServer/btcpayserver-docker/
export BTCPAYGEN_CRYPTO2="doge"
. ~/BTCPayServer/btcpayserver-docker/btcpay-setup.sh -i

Stop BTCPay while we move the files

~/BTCPayServer/btcpayserver-docker/btcpay-down.sh

Move the Dogecoin data dir to your new drive and then create a symlink to the drive to replace it:

mv /var/lib/docker/volumes/generated_dogecoin_datadir /mnt/dogefullchain/generated_dogecoin_datadirln -s /mnt/dogefullchain/generated_dogecoin_datadir /var/lib/docker/volumes/generated_dogecoin_datadir

Start BTCPay back up

~/BTCPayServer/btcpayserver-docker/btcpay-up.sh

Your server will now be up and running again, and all dogecoin data will be stored on /mnt/dogefullchain. When your drive becomes full as the blockchain becomes bigger, simply shut down btcpay, resize your drive on digital ocean to a larger size and then restart btcpay.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store