BTCPay Server deployment explained
By Nicolas Dorier
Main maintainer of
NBitcoin and BTCPay
.NET fanboy
For fun and profit
btcpayserver-docker
Btcpay-
setup.sh
Docker-
Compose-
Generator
Docker
fragments
BTCPAYGEN_
environment
variables
.env file
Btcpay-up.sh
Btcpay-
down.sh
Docker-
compose.gene
rated.yml
Docker images
Shitcoins
Third party
plugins
WoocommerceLibrepatron
Quickbook
plugin
Btcpay-
update.sh
Git pull
Docker-
compose up
Docker-compose up
Docker-compose down
Extensibility
Tooling
Bitcoin-cli.sh
...
Production/nginx.tmpl
Docker-
compose.gene
rated.yml
Environment
variables
in .env fileTOOLING SCRIPTS
SETUP
INFORMATION
A boring bubble
Docker-Hub .circleci/config.yml
Git push --tags
Multi Arch
Manifest Images
ARM32v7 AMD64
Image s github
repo
Qemu
or Cross compile
Raspberry PI
Build.sh
Docker-
Compose-
Generator
Forward based on path
Forward based on
domain
Foreword
• We assume you know what is BTCPay Server
• It is a technical talk, DevOps oriented talk
• Using docker so we don’t have to spend time supporting
esoteric environments
Goals
• Fork us if you want to fork!
• Taking full advantage of BTCPay Server flexibility
• Shilling docker because docker is awesome
Overview
Docker ComposeBitcoin
Core
Postgres
NBXplorer
BTCPay
letsencrypt-nginx-proxy-companion
nginx-gen
Ecommerce + BTCPay plugins
Docker Compose
Bitcoin
Core
Postgres
NBXplorer
BTCPay
letsencrypt-nginx-proxy-companion
nginx-gen
Ecommerce + BTCPay plugins
Docker Compose
Bitcoin
Core
Postgres
NBXplorer
BTCPay
letsencrypt-nginx-proxy-companion
nginx-gen
Ecommerce + BTCPay plugins
CLightning
Lightning
Charge
Docker Compose
Bitcoin
Core
Postgres
NBXplorer
BTCPay
letsencrypt-nginx-proxy-companion
nginx-gen
Ecommerce + BTCPay plugins
CLightning
Lightning
Charge
LIBRE
PATRON
QUICKBOOK
PLUGIN
What is cool
• BTCPay Server is quite flexible
• BTCPay Server supports shitcoin
• BTCPay Server allow third parties to benefit from easy
deployment
What NOT is cool
• BTCPay Server is not flexible enough
• BTCPay Server supports shitcoin
• BTCPay Server allow third parties to benefit from easy
deployment
• You trust me, as the owner of btcpayserver-docker repo
HEY CAN YOU
SUPPORT SHITCOIN
2.0?
RIP BTCPAY! BTCPAY
SUPPORT FRAUD
COINS!1!
YOU ACCEPT MONEY
OF SHITCOINERS? DIE
IN HELL MISERABLE
P*** OF S****.
Hey I will add
ETH support to
BTCPay and
Crowdfund it!!
In main repo:
• Shitcoin OK!
(As long as it has same design
as Bitcoin and you figure out how to do yourself)
• No controversial Shitcoin
(Because I want to spend time coding instead of losing time justifying
why we added your shitcoin)
For shitcoin you need to do by yourself
• Integration to NBitcoin.Altcoins
• Integration to NBXplorer
• Integration to BTCPay
• Dockerizing your node software
• Integration to BTCPay-Docker
• Maintaining it
• We only test if Bitcoin works with BTCPay
• We do not test if we broke a shitcoin
• You are responsible to fix what we broke
• You are responsible to maintain your docker files
Question?
Let’s go deeper
btcpayserver-docker
Btcpay-
setup.sh
Docker-
Compose-
Generator
Docker
fragments
BTCPAYGEN_
environment
variables
.env file
Btcpay-up.sh
Btcpay-
down.sh
Docker-
compose.gene
rated.yml
Docker images
Shitcoins
Third party
plugins
WoocommerceLibrepatron
Quickbook
plugin
Btcpay-
update.sh
Git pull
Docker-
compose up
Docker-compose up
Docker-compose down
Extensibility
Tooling
Bitcoin-cli.sh
...
Production/nginx.tmpl
Docker-
compose.gene
rated.yml
Environment
variables
in .env fileTOOLING SCRIPTS
SETUP
INFORMATION
A boring bubble
Docker-Hub .circleci/config.yml
Git push --tags
Multi Arch
Manifest Images
ARM32v7 AMD64
Image s github
repo
Qemu
or Cross compile
Raspberry PI
Build.sh
Docker-
Compose-
Generator
Forward based on path
Forward based on
domain
All starts with
Btcpay-setup.sh
1. Install docker and docker-compose
2. Run the docker-compose-generator
3. Create variables used by docker-compose in .env file
4. Make sure BTCPay restart after reboot
5. Put tooling scripts in /usr/bin
6. Start the service
Btcpay-setup.sh Btcpay-
setup.sh
Docker-
Compose-
Generator
BTCPAYGEN_
environment
variables
.env file
Extensibility
Tooling
Bitcoin-cli.sh
...
btcpay-docker
Docker fragments
BTCPAYGEN_
variables
Docker-compose-
generator
Generated/docker-compose.generated.yml
Just run
“build.sh“
How is docker-compose.generated.yml
generated?
How is docker-compose.generated.yml
running?
.env
Generated/docker-compose.generated.yml
btcpay-up.sh
Docker Compose
Bitcoin
Core
Postgres
NBXplorer
BTCPay
letsencrypt-nginx-proxy-companion
nginx-gen
Ecommerce + BTCPay plugins
CLightning
Lightning
Charge
LIBRE
PATRON
QUICKBOOK
PLUGIN
How is docker-compose.generated.yml
generated?
Docker-
Compose-
Generator
Docker
fragments
BTCPAYGEN_
environment
variables
Docker-
compose.gene
rated.yml
Extensibility
Environment
variables
in .env file
Build.sh
How is docker-compose.generated.yml
running? (btcpay-up.sh)
.env file
Btcpay-up.sh
Btcpay-
down.sh
Docker-compose up
Docker-compose down
Docker-
compose.gene
rated.yml
Question?
What are those docker fragments?
Docker
fragments
Docker imagesEnvironment
variables
in .env file
Docker-Hub
Docker-
Compose-
Generator
What are those docker fragments?
1. Standard docker-compose files
2. All selected fragments are
merged together by the docker-
compose-generator
3. A fragment can modify any
container configuration
A new container
contains
“image:”
No “image:” are
modifications to an
existing container
Tons of them exists
And you can
create custom
fragments!
Which docker images?
…worst case:
around 37 projects maintained
by different people
All dependency sources
are documented in README.md
(Github + DockerHub links)
As maintainer, how do I update an image?
Update the fragment, and git push. VOILA!
As a user, how do I update?
Run btcpay-update.sh!
Btcpay-
update.sh
Git pull
Docker-
compose up
Docker-
Compose-
Generator SSH
No auto update, because:
1. If it is not broken, don’t update it
2. Would introduce a systemic risk for BTCPay Server
3. Would incentivize hackers to push malicious update
4. I don’t want a sudden flood of thousand of angry merchants
banging to my door
Question?
Tooling and Nginx configuration
Docker
fragments
Shitcoins
Third party
plugins
WoocommerceLibrepatron
Quickbook
plugin
Extensibility
Tooling
Bitcoin-cli.sh
...
Production/nginx.tmpl
Tooling
helpers.sh
Btcpay-update.sh Btcpay-setup.sh
If <container_name> exists
then put <script_name>.sh
in /usr/bin
Nginx configuration
1. Define rules decide to which container to forward
incoming HTTP/S request
2. Can use decide based on path or domain name
Extensibility
Production/nginx.tmpl
Forward based on path
Forward based on
domain
Production/nginx.tmpl
Generated/nginx.tmpl
Copied by btcpay-update.sh/btcpay-setup.sh
Generated by nginx-gen container
default.conf
Can see the default.conf with:
docker exec nginx
cat /etc/nginx/conf.d /default.conf
Path based routing
If it is librepatrons’
domain…
Nginx.tmpl
Opt-add-librepatron.yml
Path based routing
And that the pass is /isso:
Forward to port 8080 of isso container
Nginx.tmpl
Domain based routing
Opt-add-librepatron.yml
Question?
Image creation process
Docker-Hub .circleci/config.yml
Git push --tags
Multi Arch
Manifest Images
ARM32v7 AMD64
Image s github
repo
Qemu
or Cross compile
Raspberry PI
Existing images
Support Raspberry PI
No Raspberry PI
Docker Hub
https://hub.docker.com/r/btcpayserver/bitcoin/tags
Multi Arch image
Architecture specific
image
New image release typical workflow:
1. Git tag –a v1.2.3 –m v1.2.3
2. Git push –tags
3. Drink tea
4. Double check that it has been created on DockerHub
.circleci/config.yml: Build and publish amd64 img
.circleci/config.yml: Build and publish arm32v7 img
.circleci/config.yml: Build and publish manifest img
btcpayserver-docker
Btcpay-
setup.sh
Docker-
Compose-
Generator
Docker
fragments
BTCPAYGEN_
environment
variables
.env file
Btcpay-up.sh
Btcpay-
down.sh
Docker-
compose.gene
rated.yml
Docker images
Shitcoins
Third party
plugins
WoocommerceLibrepatron
Quickbook
plugin
Btcpay-
update.sh
Git pull
Docker-
compose up
Docker-compose up
Docker-compose down
Extensibility
Tooling
Bitcoin-cli.sh
...
Production/nginx.tmpl
Docker-
compose.gene
rated.yml
Environment
variables
in .env fileTOOLING SCRIPTS
SETUP
INFORMATION
A boring bubble
Docker-Hub .circleci/config.yml
Git push --tags
Multi Arch
Manifest Images
ARM32v7 AMD64
Image s github
repo
Qemu
or Cross compile
Raspberry PI
Build.sh
Docker-
Compose-
Generator
Forward based on path
Forward based on
domain
Question?
@BtcPayServer
slack.btcpayserver.org
github.com/btcpayserver
chat.btcpayserver.orgOn mattermost
@BtcPayServer@mastodon.social
On mastodon
Thank you!

Advancing Bitcoin 2019 - BTCPayServer Architecture