Instructions to deploy Lightning Server in production environment hosted in Microsoft Azure. It included: Bitcoin Core, C-Lightning, Charged, and Let's encrypt.
The following instructions assume you have Microsoft Azure subscription.
You can see the showcase video:
Click on this button and follow instructions:
You can do it by using PowerShell command line or manually via Web Platform Installer or MSI.
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
Create a new C-Lightning server instance:
.\deployOnAzure.ps1 -ResourceGroupName "myawesomelightning" -Network "mainnet"
Valid Network values are:
For ResourceGroupName, use only alphabetic lower case.
This might take around 5 minutes.
It will print you the DNS name of your server myawesomelightning.southcentralus.cloudapp.azure.com
, you can browse to it to enjoy your lightning instance.
TODO: Write shell scripts using Az tool, other link, other link, best link.
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 Lightning and NGinx to use your domain. Upon restart, a new certificate for your domain will be requested by Let's encrypt.
Just pull the latest changes of the docker-compose and restart the docker service.
sudo su -
lightning-update.sh
Reboot docker:
sudo su -
lightning-restart.sh
Or reboot the server:
sudo su -
reboot
lightning-cli.sh
is a bash file which will run lightning-cli
from inside the lightning charged container.
Please check the c-lightning project or type the following command to get help.
sudo su -
lightning-cli.sh help
bitcoin-cli.sh
is a bash file which will run bitcoin-cli
from inside the bitcoind container.
You can type the following command to get help.
sudo su -
bitcoin-cli.sh help
lightning-show.sh
is a bash file which will return you the credential and URL to use to connect to your lightning charge instance.
Please, check the lightning charged project for documentation on this API.
sudo su -
lightning-show.sh
Here are the step on provisioning done by Azure (so you can do it yourelf):
entrypoint.sh
passing the following arguments taken from the wizard:
entrypoint.sh
does the following actions:
/etc/environment
and /etc/profile.d/lightning-env.sh
so they can be accessed via environment variable globally.env
file which will be used by the docker-compose
docker-compose
and git
lightning-charge-azure
repository/etc/init/start_containers.conf
to start docker-compose
if the machine rebootdocker-compose
in the directory of the .env
as working directory/usr/bin
to the other lightning-*.sh
utility scriptsExample 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"
LIGHTNING_DOCKER_COMPOSE="/var/lib/waagent/custom-script/download/0/lightning-charge-azure/Production/docker-compose.btc-ltc.yml"
LIGHTNING_ENV_FILE="/var/lib/waagent/custom-script/download/0/.env"
DOWNLOAD_ROOT="/var/lib/waagent/custom-script/download/0"
Example of /etc/profile.d/lightning-env.sh
:
export AZURE_DNS="dwoiqdwqb.westeurope.cloudapp.azure.com"
export LIGHTNING_DOCKER_COMPOSE="/var/lib/waagent/custom-script/download/0/lightning-charge-azure/Production/docker-compose.btc-ltc.yml"
export DOWNLOAD_ROOT="/var/lib/waagent/custom-script/download/0"
export LIGHTNING_ENV_FILE="/var/lib/waagent/custom-script/download/0/.env"
Example of .env
file:
CHARGED_HOST=test-btc-ltc.forkbitpay.ninja
ACME_CA_URI=https://acme-v01.api.letsencrypt.org/directory
NBITCOIN_NETWORK=testnet
LETSENCRYPT_EMAIL=me@example.com
CHARGED_API_TOKEN=Ajz5AbE5nOy18I2o5dTZr4NyUCxqVpOY
CHARGED_IP=1.2.3.4
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/lightning-env.sh
cd "`dirname $LIGHTNING_ENV_FILE`"
docker-compose -f "$LIGHTNING_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 $LIGHTNING_ENV_FILE`"
docker-compose -f "$LIGHTNING_DOCKER_COMPOSE" up