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

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

If you don’t have an account, Signup for one Here. You get $100 worth of credit to play around with, and if you stay long enough to pay $25, I also get a credit back.

Step 2 — Create a Droplet

Once you are logged in, You will see a “Create” dropdown where you will select “Droplets”.

Select “One-click apps” 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

Once you have a droplet created, we can now login and setup BTCPay server.

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

You will be asked to change your password immediately.

Step 4 — Setup BTCPay Server

One you have logged into the new droplet via SSH, simply run the following commands as root:

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:

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

This add’s the hostname “btcpay-sample.EXAMPLE.com”. You will want to replace this with your own hostname.

export NBITCOIN_NETWORK=”mainnet”

This specifies we are building a mainnet node. Only change this if you are planning on using testnet.

export BTCPAYGEN_CRYPTO1=”btc”

This tells BTCPay we are setting up a BTC Node. For now, we will only be installing BTC as a payment method, with lightning.

export BTCPAYGEN_REVERSEPROXY=”nginx”

This tells BTCPay we will be using nginx as a reverse proxy. Don’t change unless you know what you are doing.

export BTCPAYGEN_LIGHTNING=”lnd”

We specify here which lightning software we wish to use. You can select either “clightning” or “lnd” based on preferences.

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"

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

Once you have entered the following commands, you simply need to run the BTCPay install script:

. ./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)

If you opted to run a full node, Congrats! You have a bit more work to do but you will be able to ensure the integrity of the entire chain!

Log back into your Digital Ocean instance

Select “Create -> Volumes”

Select the custom size of 300GB (At the time of this writing the BTC Blockchain is about 240GB so let's give it some room to grow). Select the droplet you just created to attach it to and then give it a name, let's call it “btcfullchain”, and select automatically format & mount.

Go back to your ssh window where you installed BTCPay.

Run the commanddf and you will now notice that you have a new drive called “btcfullchain” mounted to /mnt/btcfullchain. This is where we will be moving your BTC chain to.

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_datadir
ln -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

*After a few days of testing, I’ve been able to conclude that the current DO offerings will likely not be able to handle 3 or more coins at one time. I’ve tested this out on both the pruned setup, and a 4GB “CPU Intensive” droplet with the same results. If you plan to 3 or more coins, it might be best to look at alternatives.*

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!

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”

Select the custom size of 40GB (Approx $4/month). Select the droplet you just created to attach it to and then give it a name, let’s call it “dogefullchain”, and select automatically format & mount.

Go back to your ssh window where you installed BTCPay.

Run the commanddf and you will now notice that you have a new drive called “dogefullchain” mounted to /mnt/dogefullchain. This is where we will be moving your BTC chain to.

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_datadir
ln -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.