As you can see, it depends on several piece of infrastructure, mainly:
As you can see, BTCPay depends on several piece of infrastructure, mainly:
* A lightweight block explorer (NBXplorer),
* A database (Postgres, or SQLite),
* A full node (Bitcoin Core)
Setting up the dependencies might be time consuming, this repository is meant to give working example of `docker-compose` file which will setup everything for you.
There is more dependencies, if you support more than just Bitcoin. (C-Lightning, LitecoinD etc...)
Setting up the dependencies correctly in a production environment might be time consuming.
The [Production](Production) `docker-compose` files are used for production environment. It adds NGinx as a reverse proxy and [Let's Encrypt and DockerGen](https://github.com/gilyes/docker-nginx-letsencrypt-sample) to automatically configure HTTPS.
The production `docker-compose` is used under the hood to deploy an instance of BTCPay on Microsoft Azure in one click:
This repository is meant to setup your environment easily.
[![Deploy to Azure](https://azuredeploy.net/deploybutton.svg)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fbtcpayserver%2Fbtcpayserver-azure%2Fmaster%2Fazuredeploy.json)
The [Production-NoReverseProxy](Production-NoReverseProxy) `docker-compose` files are used for environment which are already behind a reverse proxy. It exposes BTCPayServer directly on port 80.
# How to use this?
# About accessing services inside those docker compose
## For complete noobs
Several scripts are provided to access the internal of your docker-service:
If you have no knowledge of Linux administration or Docker, we advise you to host BTCPay on Microsoft Azure by opening an account then clicking here
* `litecoin-cli.sh`
* `bitcoin-cli.sh`
* `litecoin-lightning-cli.sh`
* `bitcoin-lightning-cli.sh`
[![Deploy to Azure](https://azuredeploy.net/deploybutton.svg)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fbtcpayserver%2Fbtcpayserver-azure%2Fmaster%2Fazuredeploy.json)
We also provide powershell `.ps1` scripts if you are on windows.
Follow this video
You can use it easily:
[![BTCPay - One Click Setup](http://img.youtube.com/vi/Bxs95BdEMHY/mqdefault.jpg)](http://www.youtube.com/watch?v=Bxs95BdEMHY "BTCPay - One Click Setup")
```
./bitcoin-cli.sh getblockcount
```
This installation is convenient but will cost you around 60 USD per month.
After all your nodes are synched and you confirm things work fine, you can fine tune save additional money by following [this guide](https://github.com/btcpayserver/btcpayserver-doc/blob/master/PennyPinching.md), and drop to 30 or 40 USD per month.
# For docker noobs <aname="fornoobs"/>
## For technical user
If you are a docker noob here is how you would create a HTTPS ready server.
If, for some reason, you don't want or can't use the Azure deployment explained above then you can install BTCPayServer on your own instance.
First step is to make sure you have a domain name pointing to your host, and that port `443` and `80` and externally accessible.
Let's assume it is `btcpay.example.com`.
Clone the repository:
```
You also want to support litecoin, bitcoin and clightning and having HTTPS automatically configured by nginx.
docker-compose -f "$(pwd)/Production/docker-compose.btc-ltc.yml" up -d
```
* Install Docker
* Install Docker-Compose
* Make sure BTCPay starts at reboot via upstart or systemd
* Setup environment variables to use BTCPay utilities
* Add BTCPay utilities in /usr/bin
* Start BTCPay
Wait a little bit, then you can now browse `https://btcpay.example.com/`.
# Tooling <aname="tooling"/>
A wide range of tooling get available on your system when btcpay is installed:
* `bitcoin-cli.sh` access your bitcoin node instance
* `bitcoin-lightning-cli.sh` access your clighning node instance
* `changedomain.sh` change the domain of your BTCPayServer
* `btcpay-update.sh` update BTCPay to the latest version
* `btcpay-setup.sh` change the settings of your server (run `. ./btcpay-setup.sh` to get more information about additional parameters, run `. ./btcpay-setup.sh -i` to setup again your btcpay server)
# Under the hood
## Prebuilt docker-compose
For your custom need, you will find some working example of `docker-compose` file which will setup everything for you.
The [Production](Production) `docker-compose` files are used for production environment. It adds NGinx as a reverse proxy and [Let's Encrypt and DockerGen](https://github.com/gilyes/docker-nginx-letsencrypt-sample) to automatically configure HTTPS.
The production `docker-compose` is used under the hood to deploy an instance of BTCPay on Microsoft Azure in one click:
# About generate-docker-compose
[![Deploy to Azure](https://azuredeploy.net/deploybutton.svg)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fbtcpayserver%2Fbtcpayserver-azure%2Fmaster%2Fazuredeploy.json)
The files in `Production` and `Production-NoReverseProxy` are generated by a dotnet program located in `docker-compose-generator`.
It is meant to generate a wide range a configuration from `docker-compose-generator/docker-fragments` without repeating myself.
The [Production-NoReverseProxy](Production-NoReverseProxy) `docker-compose` files are used for environment which are already behind a reverse proxy. It exposes BTCPayServer directly on port 80.
# No docker-compose suit my need, what should I do?
## Generated docker-compose
All `docker-compose` files in [Production](Production) and [Production-NoReverseProxy](Production-NoReverseProxy) are generated by running the [build-pregen.sh](build-pregen.sh) (or [build-pregen.ps1](build-pregen.ps1)) scripts from the fragments located in [docker-compose-generator/docker-fragments](docker-compose-generator/docker-fragments).
@ -87,9 +110,9 @@ To configure your custom docker-compose, the following environment variables are
* `BTCPAYGEN_SUBNAME`: The sub name of the generated docker-compose file, where the full name will be `Generated/docker-compose.SUBNAME.yml` (Default: `generated`)
Then, running [build.sh](build.sh) (or [build.ps1](build.ps1)) will then generate a `docker-compose.generated.yml` in the root folder of this repository.
For example, if you want `btc` and `ltc` support with `nginx` and `clightning` inside `Generate/docker-compose.custom.yml`:
Then, running [build.sh](build.sh) (or [build.ps1](build.ps1)) will then generate a `docker-compose.generated.yml` in the [Generated](Generated) folder of this repository.
For example, if you want `btc` and `ltc` support with `nginx` and `clightning` inside `Generated/docker-compose.custom.yml`:
Note: The first run might take a while, but next run are instantaneous.
1. Support for your crypto on [NBitcoin](https://github.com/MetacoSA/NBitcoin/tree/master/NBitcoin.Altcoins)/[NBxplorer](https://github.com/dgarage/NBXplorer)/[BTCPay Server](https://github.com/btcpayserver/btcpayserver). (Take example on other coins)
2. Create your own docker image ([Example for BTC](https://hub.docker.com/r/nicolasdorier/docker-bitcoin/))
3. Create a docker-compose fragment ([Example for BTC](docker-compose-generator/docker-fragments/bitcoin.yml))
4. Add your Crypto Definition ([Example for BTC](docker-compose-generator/src/CryptoDefinition.cs))
Congratulation!
Now if you want to test, DOT NOT USE `build.sh`, because this utility is a pre-built docker image.
Instead, install [.NET Core 2.1 SDK](https://www.microsoft.com/net/download/windows) then run:
```bash
BTCPAYGEN_CRYPTO1="xxx"
BTCPAYGEN_SUBNAME="test"
cd docker-compose-generator/src
dotnet run
```
This will generate your docker-compose in the `Generated` folder, which you can then try by yourself.
Note that BTCPayServer developers will not spend time testing your image, so make sure it works.
# For docker noobs <aname="fornoobs"/>
If you are a docker noob here is how you would create a HTTPS ready server.
First step is to make sure you have a domain name pointing to your host, and that port `443` and `80` and externally accessible.