| .gitattributes | ||
| .gitignore | ||
| azuredeploy.json | ||
| btcpay-restart.sh | ||
| btcpay-update.sh | ||
| changedomain.sh | ||
| deployOnAzure.ps1 | ||
| entrypoint.sh | ||
| LICENSE | ||
| README.md | ||
BTCPayServer Azure
Instructions to deploy BTCPay Server in production environment hosted in Microsoft Azure.
The following instructions assume you have Microsoft Azure subscription.
You can see our video for an overview:
Deploy via Microsoft Azure Portal
Click on this button and follow instructions:
Deploy with PowerShell
Step 1: Download and install Azure PowerShell
You can do it by using PowerShell command line or manually via Web Platform Installer or MSI.
Step 2: Authenticate to Azure
In PowerShell, you first need to authenticate to azure:
# This will popup a windows to authenticate to azure
Login-AzureRmAccount
If you have multiple subscriptions, select the one you want:
# List your subscriptions
Get-AzureRmSubscription
# Select the one you want
Get-AzureRmSubscription –SubscriptionId "your subscription" | Select-AzureRmSubscription
Step 3: Run the deployment
Create a new BTCPay Server instance:
.\deployOnAzure.ps1 -ResourceGroupName "myawesomebtcpay" -Network "mainnet"
Valid Network values are:
- mainnet
- testnet
- regtest
For ResourceGroupName, use only alphabetic lower case.
This might take around 5 minutes.
It will print you the DNS name of your server myawesomebtcpay.southcentralus.cloudapp.azure.com, you can browse to it to enjoy your BTCPay instance.
Deploy on Linux
TODO: Write shell scripts using Az tool, other link, other link, best link.
How to change the domain name
By default, you will have a domain name assigned ending with xxx.cloudapp.azure.com. Because Let's Encrypt does not allow us to get HTTPS certificate for the azure.com domain, you need your own domain.
Then, add a CNAME record in your name server pointing to xxx.cloudapp.azure.com.
Connect then with SSH to your VM and run
sudo su -
changedomain.sh blah.example.com
This will change the settings of BTCPay and NGinx to use your domain. Upon restart, a new certificate for your domain will be requested by Let's encrypt.
How to update BTCPay
Just pull the latest changes of the docker-compose and restart the docker service.
sudo su -
btcpay-update.sh
How to restart BTCPay
Reboot docker:
sudo su -
btcpay-restart.sh
Or reboot the server:
sudo su -
reboot
Under the hood
Here are the step on provisioning done by Azure (so you can do it yourelf):
- Azure provision a new virtual machine
- Then copy all the sh files of this repository inside the new virtual machine
- Azure then execute
entrypoint.shpassing the following arguments taken from the wizard:- The initial DNS name
- The network (mainnet, testnet, regtest)
- Let's encrypt email
- Supported crypto currencies separated by '-'
- Docker repository url used for fetching the docker-compose
- The branch of this repository
entrypoint.shdoes the following actions:- Copy the parameters inside
/etc/environmentand/etc/profile.d/btcpay-env.shso they can be accessed via environment variable globally - Add also those parameters in the
.envfile which will be used by thedocker-compose - Install
docker-composeandgit - Clone the
btcpayserver-dockerrepository - Configure upstart in
/etc/init/start_containers.confto startdocker-composeif the machine reboot - Start
docker-composein the directory of the.envas working directory - Create symbolic links to
/usr/binto the otherbtcpay-*.shutility scripts
- Copy the parameters inside
Example of /etc/environment:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
AZURE_DNS="dwoiqdwqb.westeurope.cloudapp.azure.com"
BTCPAY_DOCKER_COMPOSE="/var/lib/waagent/custom-script/download/0/btcpayserver-docker/Production/docker-compose.btc-ltc.yml"
BTCPAY_ENV_FILE="/var/lib/waagent/custom-script/download/0/.env"
DOWNLOAD_ROOT="/var/lib/waagent/custom-script/download/0"
Example of /etc/profile.d/btcpay-env.sh:
export AZURE_DNS="dwoiqdwqb.westeurope.cloudapp.azure.com"
export BTCPAY_DOCKER_COMPOSE="/var/lib/waagent/custom-script/download/0/btcpayserver-docker/Production/docker-compose.btc-ltc.yml"
export DOWNLOAD_ROOT="/var/lib/waagent/custom-script/download/0"
export BTCPAY_ENV_FILE="/var/lib/waagent/custom-script/download/0/.env"
Example of .env file:
BTCPAY_HOST=test-btc-ltc.forkbitpay.ninja
ACME_CA_URI=https://acme-v01.api.letsencrypt.org/directory
NBITCOIN_NETWORK=testnet
LETSENCRYPT_EMAIL=me@example.com
Example of /etc/init/start_containers.conf file:
# File is saved under /etc/init/start_containers.conf
# After file is modified, update config with : $ initctl reload-configuration
description "Start containers (see http://askubuntu.com/a/22105 and http://askubuntu.com/questions/612928/how-to-run-docker-compose-at-bootup)"
start on filesystem and started docker
stop on runlevel [!2345]
# if you want it to automatically restart if it crashes, leave the next line in
# respawn # might cause over charge
script
. /etc/profile.d/btcpay-env.sh
cd "`dirname $BTCPAY_ENV_FILE`"
docker-compose -f "$BTCPAY_DOCKER_COMPOSE" up -d
end script
Note that AZURE_DNS is not really used anywhere except for debugging purpose.
When you want to start/stop docker, for the environment variables in .env to be taken into account, you need to start from its folder:
cd "`dirname $BTCPAY_ENV_FILE`"
docker-compose -f "$BTCPAY_DOCKER_COMPOSE" up
