diff --git a/.gitignore b/.gitignore index c85785c..69ccb05 100644 --- a/.gitignore +++ b/.gitignore @@ -297,3 +297,8 @@ Production/.env .vscode/ *docker-compose.generated.yml +Generated/acme.json +Generated/traefik_logs/ +Generated/error + + diff --git a/Generated/.gitignore b/Generated/.gitignore index 5c11526..2fb9890 100644 --- a/Generated/.gitignore +++ b/Generated/.gitignore @@ -1,2 +1,4 @@ *.yml -*.tmpl \ No newline at end of file +*.tmpl +*.toml +*.json \ No newline at end of file diff --git a/Production-NoReverseProxy/README.md b/Production-NoReverseProxy/README.md index 25de599..0593d45 100644 --- a/Production-NoReverseProxy/README.md +++ b/Production-NoReverseProxy/README.md @@ -1,17 +1,4 @@ -# About those pre-generated docker-compose - -All `docker-compose` files in this folder are generated by running the [build-pregen.sh](build-pregen.sh) (or [build-pregen.ps1](build-pregen.ps1)) script from the fragments located in [docker-compose-generator/docker-fragments](docker-compose-generator/docker-fragments). - -The pre-generated `docker-compose` files only cover `btc`, `ltc`, `clightning` without reverse proxy. - ---- - -We strongly advise you to not use the pre-generated docker-compose of this folder, they are deprecated and kept only for backward compatibility. -Instead use the [build.sh](../build.sh) as documented in (README)(../Readme.md) to generate a docker-compose which fit your needs. - ---- - -This `docker-compose` files can be used for production purpose. +# How to use docker-compose without reverse proxy ![Architecture](https://github.com/btcpayserver/btcpayserver-doc/raw/master/img/Architecture.png) @@ -46,7 +33,8 @@ With Powershell: $env:BTCPAY_ROOTPATH="/test"; $env:BTCPAY_PROTOCOL="http"; $env:BTCPAY_HOST="btcpay.example.com"; -docker-compose -f docker-compose.btc.yml up +.\build.ps1 +docker-compose -f "Generated/docker-compose.generated.yml" up --remove-orphans -d ``` With Linux: @@ -55,7 +43,8 @@ With Linux: export BTCPAY_ROOTPATH="/test" export BTCPAY_PROTOCOL="http" export BTCPAY_HOST="btcpay.example.com" -docker-compose -f docker-compose.btc.yml up +./build.sh +docker-compose -f "Generated/docker-compose.generated.yml" up --remove-orphans -d ``` Then edit your [host file](https://www.howtogeek.com/howto/27350/beginner-geek-how-to-edit-your-hosts-file/) with diff --git a/Production-NoReverseProxy/docker-compose.btc-clightning.yml b/Production-NoReverseProxy/docker-compose.btc-clightning.yml deleted file mode 100644 index 58a6a96..0000000 --- a/Production-NoReverseProxy/docker-compose.btc-clightning.yml +++ /dev/null @@ -1,101 +0,0 @@ -version: "3" -services: - btcpayserver: - restart: unless-stopped - image: nicolasdorier/btcpayserver:1.0.2.105 - expose: - - "49392" - environment: - BTCPAY_POSTGRES: User ID=postgres;Host=postgres;Port=5432;Database=btcpayserver${NBITCOIN_NETWORK:-regtest} - BTCPAY_NETWORK: ${NBITCOIN_NETWORK:-regtest} - BTCPAY_BIND: 0.0.0.0:49392 - BTCPAY_EXTERNALURL: ${BTCPAY_PROTOCOL:-https}://${BTCPAY_HOST}/ - BTCPAY_ROOTPATH: ${BTCPAY_ROOTPATH:-/} - BTCPAY_SSHTRUSTEDFINGERPRINTS: ${BTCPAY_SSHTRUSTEDFINGERPRINTS} - BTCPAY_SSHKEYFILE: ${BTCPAY_SSHKEYFILE} - VIRTUAL_NETWORK: nginx-proxy - VIRTUAL_PORT: 49392 - VIRTUAL_HOST: ${BTCPAY_HOST} - SSL_POLICY: Mozilla-Modern - LETSENCRYPT_HOST: ${BTCPAY_HOST} - LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL:-} - BTCPAY_CHAINS: "btc" - BTCPAY_BTCEXPLORERURL: http://nbxplorer:32838/ - BTCPAY_BTCLIGHTNING: "type=clightning;server=unix://etc/clightning_bitcoin/lightning-rpc" - links: - - nbxplorer - - postgres - - clightning_bitcoin - volumes: - - "btcpay_datadir:/datadir" - - "nbxplorer_datadir:/root/.nbxplorer" - - "clightning_bitcoin_datadir:/etc/clightning_bitcoin" - ports: - - "80:49392" - nbxplorer: - restart: unless-stopped - image: nicolasdorier/nbxplorer:1.0.2.31 - expose: - - "32838" - environment: - NBXPLORER_NETWORK: ${NBITCOIN_NETWORK:-regtest} - NBXPLORER_BIND: 0.0.0.0:32838 - NBXPLORER_CHAINS: "btc" - NBXPLORER_BTCRPCURL: http://bitcoind:43782/ - NBXPLORER_BTCNODEENDPOINT: bitcoind:39388 - volumes: - - "nbxplorer_datadir:/datadir" - - "bitcoin_datadir:/root/.bitcoin" - links: - - bitcoind - postgres: - restart: unless-stopped - image: postgres:9.6.5 - volumes: - - "postgres_datadir:/var/lib/postgresql/data" - bitcoind: - restart: unless-stopped - container_name: btcpayserver_bitcoind - image: nicolasdorier/docker-bitcoin:0.16.3 - environment: - BITCOIN_EXTRA_ARGS: | - rpcport=43782 - ${NBITCOIN_NETWORK:-regtest}=1 - port=39388 - whitelist=0.0.0.0/0 - expose: - - "43782" - - "39388" - volumes: - - "bitcoin_datadir:/data" - clightning_bitcoin: - image: nicolasdorier/clightning:634f19a7b230edc686be56ab950b80784e56252c - container_name: btcpayserver_clightning_bitcoin - restart: unless-stopped - environment: - LIGHTNINGD_NETWORK: ${NBITCOIN_NETWORK:-regtest} - LIGHTNINGD_CHAIN: btc - LIGHTNINGD_EXPLORERURL: "http://nbxplorer:32838/" - LIGHTNINGD_OPT: | - bitcoin-datadir=/etc/bitcoin - bitcoin-rpcconnect=bitcoind - announce-addr=${BTCPAY_HOST}:9735 - bind-addr=0.0.0.0:9735 - network=${NBITCOIN_NETWORK:-regtest} - alias=${LIGHTNING_ALIAS} - chain=btc - volumes: - - "clightning_bitcoin_datadir:/root/.lightning" - - "bitcoin_datadir:/etc/bitcoin" - - "nbxplorer_datadir:/root/.nbxplorer" - ports: - - "9735:9735" - links: - - nbxplorer - - bitcoind -volumes: - postgres_datadir: - btcpay_datadir: - nbxplorer_datadir: - bitcoin_datadir: - clightning_bitcoin_datadir: diff --git a/Production-NoReverseProxy/docker-compose.btc-ltc-clightning.yml b/Production-NoReverseProxy/docker-compose.btc-ltc-clightning.yml deleted file mode 100644 index 1045401..0000000 --- a/Production-NoReverseProxy/docker-compose.btc-ltc-clightning.yml +++ /dev/null @@ -1,151 +0,0 @@ -version: "3" -services: - btcpayserver: - restart: unless-stopped - image: nicolasdorier/btcpayserver:1.0.2.105 - expose: - - "49392" - environment: - BTCPAY_POSTGRES: User ID=postgres;Host=postgres;Port=5432;Database=btcpayserver${NBITCOIN_NETWORK:-regtest} - BTCPAY_NETWORK: ${NBITCOIN_NETWORK:-regtest} - BTCPAY_BIND: 0.0.0.0:49392 - BTCPAY_EXTERNALURL: ${BTCPAY_PROTOCOL:-https}://${BTCPAY_HOST}/ - BTCPAY_ROOTPATH: ${BTCPAY_ROOTPATH:-/} - BTCPAY_SSHTRUSTEDFINGERPRINTS: ${BTCPAY_SSHTRUSTEDFINGERPRINTS} - BTCPAY_SSHKEYFILE: ${BTCPAY_SSHKEYFILE} - VIRTUAL_NETWORK: nginx-proxy - VIRTUAL_PORT: 49392 - VIRTUAL_HOST: ${BTCPAY_HOST} - SSL_POLICY: Mozilla-Modern - LETSENCRYPT_HOST: ${BTCPAY_HOST} - LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL:-} - BTCPAY_LTCEXPLORERURL: http://nbxplorer:32838/ - BTCPAY_CHAINS: "ltc,btc" - BTCPAY_LTCLIGHTNING: "type=clightning;server=unix://etc/clightning_litecoin/lightning-rpc" - BTCPAY_BTCEXPLORERURL: http://nbxplorer:32838/ - BTCPAY_BTCLIGHTNING: "type=clightning;server=unix://etc/clightning_bitcoin/lightning-rpc" - links: - - nbxplorer - - postgres - - clightning_litecoin - - clightning_bitcoin - volumes: - - "btcpay_datadir:/datadir" - - "nbxplorer_datadir:/root/.nbxplorer" - - "clightning_litecoin_datadir:/etc/clightning_litecoin" - - "clightning_bitcoin_datadir:/etc/clightning_bitcoin" - ports: - - "80:49392" - nbxplorer: - restart: unless-stopped - image: nicolasdorier/nbxplorer:1.0.2.31 - expose: - - "32838" - environment: - NBXPLORER_NETWORK: ${NBITCOIN_NETWORK:-regtest} - NBXPLORER_BIND: 0.0.0.0:32838 - NBXPLORER_CHAINS: "ltc,btc" - NBXPLORER_LTCRPCURL: http://litecoind:43782/ - NBXPLORER_LTCNODEENDPOINT: litecoind:39388 - NBXPLORER_BTCRPCURL: http://bitcoind:43782/ - NBXPLORER_BTCNODEENDPOINT: bitcoind:39388 - volumes: - - "nbxplorer_datadir:/datadir" - - "litecoin_datadir:/root/.litecoin" - - "bitcoin_datadir:/root/.bitcoin" - links: - - litecoind - - bitcoind - postgres: - restart: unless-stopped - image: postgres:9.6.5 - volumes: - - "postgres_datadir:/var/lib/postgresql/data" - litecoind: - restart: unless-stopped - container_name: btcpayserver_litecoind - image: nicolasdorier/docker-litecoin:0.16.3 - environment: - BITCOIN_EXTRA_ARGS: | - rpcport=43782 - ${NBITCOIN_NETWORK:-regtest}=1 - port=39388 - whitelist=0.0.0.0/0 - expose: - - "43782" - - "39388" - volumes: - - "litecoin_datadir:/data" - clightning_litecoin: - image: nicolasdorier/clightning:634f19a7b230edc686be56ab950b80784e56252c - container_name: btcpayserver_clightning_litecoin - restart: unless-stopped - environment: - LIGHTNINGD_NETWORK: ${NBITCOIN_NETWORK:-regtest} - LIGHTNINGD_CHAIN: ltc - LIGHTNINGD_EXPLORERURL: "http://nbxplorer:32838/" - LIGHTNINGD_OPT: | - bitcoin-datadir=/etc/litecoin - bitcoin-rpcconnect=litecoind - bind-addr=0.0.0.0:9735 - announce-addr=${BTCPAY_HOST}:9736 - network=${NBITCOIN_NETWORK:-regtest} - alias=${LIGHTNING_ALIAS} - chain=ltc - volumes: - - "clightning_litecoin_datadir:/root/.lightning" - - "litecoin_datadir:/etc/litecoin" - - "nbxplorer_datadir:/root/.nbxplorer" - ports: - - "9736:9735" - links: - - nbxplorer - - litecoind - bitcoind: - restart: unless-stopped - container_name: btcpayserver_bitcoind - image: nicolasdorier/docker-bitcoin:0.16.3 - environment: - BITCOIN_EXTRA_ARGS: | - rpcport=43782 - ${NBITCOIN_NETWORK:-regtest}=1 - port=39388 - whitelist=0.0.0.0/0 - expose: - - "43782" - - "39388" - volumes: - - "bitcoin_datadir:/data" - clightning_bitcoin: - image: nicolasdorier/clightning:634f19a7b230edc686be56ab950b80784e56252c - container_name: btcpayserver_clightning_bitcoin - restart: unless-stopped - environment: - LIGHTNINGD_NETWORK: ${NBITCOIN_NETWORK:-regtest} - LIGHTNINGD_CHAIN: btc - LIGHTNINGD_EXPLORERURL: "http://nbxplorer:32838/" - LIGHTNINGD_OPT: | - bitcoin-datadir=/etc/bitcoin - bitcoin-rpcconnect=bitcoind - announce-addr=${BTCPAY_HOST}:9735 - bind-addr=0.0.0.0:9735 - network=${NBITCOIN_NETWORK:-regtest} - alias=${LIGHTNING_ALIAS} - chain=btc - volumes: - - "clightning_bitcoin_datadir:/root/.lightning" - - "bitcoin_datadir:/etc/bitcoin" - - "nbxplorer_datadir:/root/.nbxplorer" - ports: - - "9735:9735" - links: - - nbxplorer - - bitcoind -volumes: - postgres_datadir: - btcpay_datadir: - nbxplorer_datadir: - litecoin_datadir: - clightning_litecoin_datadir: - bitcoin_datadir: - clightning_bitcoin_datadir: diff --git a/Production-NoReverseProxy/docker-compose.btc-ltc.yml b/Production-NoReverseProxy/docker-compose.btc-ltc.yml deleted file mode 100644 index a0a57a8..0000000 --- a/Production-NoReverseProxy/docker-compose.btc-ltc.yml +++ /dev/null @@ -1,93 +0,0 @@ -version: "3" -services: - btcpayserver: - restart: unless-stopped - image: nicolasdorier/btcpayserver:1.0.2.105 - expose: - - "49392" - environment: - BTCPAY_POSTGRES: User ID=postgres;Host=postgres;Port=5432;Database=btcpayserver${NBITCOIN_NETWORK:-regtest} - BTCPAY_NETWORK: ${NBITCOIN_NETWORK:-regtest} - BTCPAY_BIND: 0.0.0.0:49392 - BTCPAY_EXTERNALURL: ${BTCPAY_PROTOCOL:-https}://${BTCPAY_HOST}/ - BTCPAY_ROOTPATH: ${BTCPAY_ROOTPATH:-/} - BTCPAY_SSHTRUSTEDFINGERPRINTS: ${BTCPAY_SSHTRUSTEDFINGERPRINTS} - BTCPAY_SSHKEYFILE: ${BTCPAY_SSHKEYFILE} - VIRTUAL_NETWORK: nginx-proxy - VIRTUAL_PORT: 49392 - VIRTUAL_HOST: ${BTCPAY_HOST} - SSL_POLICY: Mozilla-Modern - LETSENCRYPT_HOST: ${BTCPAY_HOST} - LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL:-} - BTCPAY_LTCEXPLORERURL: http://nbxplorer:32838/ - BTCPAY_CHAINS: "ltc,btc" - BTCPAY_BTCEXPLORERURL: http://nbxplorer:32838/ - links: - - nbxplorer - - postgres - volumes: - - "btcpay_datadir:/datadir" - - "nbxplorer_datadir:/root/.nbxplorer" - ports: - - "80:49392" - nbxplorer: - restart: unless-stopped - image: nicolasdorier/nbxplorer:1.0.2.31 - expose: - - "32838" - environment: - NBXPLORER_NETWORK: ${NBITCOIN_NETWORK:-regtest} - NBXPLORER_BIND: 0.0.0.0:32838 - NBXPLORER_CHAINS: "ltc,btc" - NBXPLORER_LTCRPCURL: http://litecoind:43782/ - NBXPLORER_LTCNODEENDPOINT: litecoind:39388 - NBXPLORER_BTCRPCURL: http://bitcoind:43782/ - NBXPLORER_BTCNODEENDPOINT: bitcoind:39388 - volumes: - - "nbxplorer_datadir:/datadir" - - "litecoin_datadir:/root/.litecoin" - - "bitcoin_datadir:/root/.bitcoin" - links: - - litecoind - - bitcoind - postgres: - restart: unless-stopped - image: postgres:9.6.5 - volumes: - - "postgres_datadir:/var/lib/postgresql/data" - litecoind: - restart: unless-stopped - container_name: btcpayserver_litecoind - image: nicolasdorier/docker-litecoin:0.16.3 - environment: - BITCOIN_EXTRA_ARGS: | - rpcport=43782 - ${NBITCOIN_NETWORK:-regtest}=1 - port=39388 - whitelist=0.0.0.0/0 - expose: - - "43782" - - "39388" - volumes: - - "litecoin_datadir:/data" - bitcoind: - restart: unless-stopped - container_name: btcpayserver_bitcoind - image: nicolasdorier/docker-bitcoin:0.16.3 - environment: - BITCOIN_EXTRA_ARGS: | - rpcport=43782 - ${NBITCOIN_NETWORK:-regtest}=1 - port=39388 - whitelist=0.0.0.0/0 - expose: - - "43782" - - "39388" - volumes: - - "bitcoin_datadir:/data" -volumes: - postgres_datadir: - btcpay_datadir: - nbxplorer_datadir: - litecoin_datadir: - bitcoin_datadir: diff --git a/Production-NoReverseProxy/docker-compose.btc.yml b/Production-NoReverseProxy/docker-compose.btc.yml deleted file mode 100644 index a91fb9d..0000000 --- a/Production-NoReverseProxy/docker-compose.btc.yml +++ /dev/null @@ -1,72 +0,0 @@ -version: "3" -services: - btcpayserver: - restart: unless-stopped - image: nicolasdorier/btcpayserver:1.0.2.105 - expose: - - "49392" - environment: - BTCPAY_POSTGRES: User ID=postgres;Host=postgres;Port=5432;Database=btcpayserver${NBITCOIN_NETWORK:-regtest} - BTCPAY_NETWORK: ${NBITCOIN_NETWORK:-regtest} - BTCPAY_BIND: 0.0.0.0:49392 - BTCPAY_EXTERNALURL: ${BTCPAY_PROTOCOL:-https}://${BTCPAY_HOST}/ - BTCPAY_ROOTPATH: ${BTCPAY_ROOTPATH:-/} - BTCPAY_SSHTRUSTEDFINGERPRINTS: ${BTCPAY_SSHTRUSTEDFINGERPRINTS} - BTCPAY_SSHKEYFILE: ${BTCPAY_SSHKEYFILE} - VIRTUAL_NETWORK: nginx-proxy - VIRTUAL_PORT: 49392 - VIRTUAL_HOST: ${BTCPAY_HOST} - SSL_POLICY: Mozilla-Modern - LETSENCRYPT_HOST: ${BTCPAY_HOST} - LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL:-} - BTCPAY_CHAINS: "btc" - BTCPAY_BTCEXPLORERURL: http://nbxplorer:32838/ - links: - - nbxplorer - - postgres - volumes: - - "btcpay_datadir:/datadir" - - "nbxplorer_datadir:/root/.nbxplorer" - ports: - - "80:49392" - nbxplorer: - restart: unless-stopped - image: nicolasdorier/nbxplorer:1.0.2.31 - expose: - - "32838" - environment: - NBXPLORER_NETWORK: ${NBITCOIN_NETWORK:-regtest} - NBXPLORER_BIND: 0.0.0.0:32838 - NBXPLORER_CHAINS: "btc" - NBXPLORER_BTCRPCURL: http://bitcoind:43782/ - NBXPLORER_BTCNODEENDPOINT: bitcoind:39388 - volumes: - - "nbxplorer_datadir:/datadir" - - "bitcoin_datadir:/root/.bitcoin" - links: - - bitcoind - postgres: - restart: unless-stopped - image: postgres:9.6.5 - volumes: - - "postgres_datadir:/var/lib/postgresql/data" - bitcoind: - restart: unless-stopped - container_name: btcpayserver_bitcoind - image: nicolasdorier/docker-bitcoin:0.16.3 - environment: - BITCOIN_EXTRA_ARGS: | - rpcport=43782 - ${NBITCOIN_NETWORK:-regtest}=1 - port=39388 - whitelist=0.0.0.0/0 - expose: - - "43782" - - "39388" - volumes: - - "bitcoin_datadir:/data" -volumes: - postgres_datadir: - btcpay_datadir: - nbxplorer_datadir: - bitcoin_datadir: diff --git a/Production-NoReverseProxy/docker-compose.ltc-clightning.yml b/Production-NoReverseProxy/docker-compose.ltc-clightning.yml deleted file mode 100644 index 04ebada..0000000 --- a/Production-NoReverseProxy/docker-compose.ltc-clightning.yml +++ /dev/null @@ -1,101 +0,0 @@ -version: "3" -services: - btcpayserver: - restart: unless-stopped - image: nicolasdorier/btcpayserver:1.0.2.105 - expose: - - "49392" - environment: - BTCPAY_POSTGRES: User ID=postgres;Host=postgres;Port=5432;Database=btcpayserver${NBITCOIN_NETWORK:-regtest} - BTCPAY_NETWORK: ${NBITCOIN_NETWORK:-regtest} - BTCPAY_BIND: 0.0.0.0:49392 - BTCPAY_EXTERNALURL: ${BTCPAY_PROTOCOL:-https}://${BTCPAY_HOST}/ - BTCPAY_ROOTPATH: ${BTCPAY_ROOTPATH:-/} - BTCPAY_SSHTRUSTEDFINGERPRINTS: ${BTCPAY_SSHTRUSTEDFINGERPRINTS} - BTCPAY_SSHKEYFILE: ${BTCPAY_SSHKEYFILE} - VIRTUAL_NETWORK: nginx-proxy - VIRTUAL_PORT: 49392 - VIRTUAL_HOST: ${BTCPAY_HOST} - SSL_POLICY: Mozilla-Modern - LETSENCRYPT_HOST: ${BTCPAY_HOST} - LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL:-} - BTCPAY_LTCEXPLORERURL: http://nbxplorer:32838/ - BTCPAY_CHAINS: "ltc" - BTCPAY_LTCLIGHTNING: "type=clightning;server=unix://etc/clightning_litecoin/lightning-rpc" - links: - - nbxplorer - - postgres - - clightning_litecoin - volumes: - - "btcpay_datadir:/datadir" - - "nbxplorer_datadir:/root/.nbxplorer" - - "clightning_litecoin_datadir:/etc/clightning_litecoin" - ports: - - "80:49392" - nbxplorer: - restart: unless-stopped - image: nicolasdorier/nbxplorer:1.0.2.31 - expose: - - "32838" - environment: - NBXPLORER_NETWORK: ${NBITCOIN_NETWORK:-regtest} - NBXPLORER_BIND: 0.0.0.0:32838 - NBXPLORER_CHAINS: "ltc" - NBXPLORER_LTCRPCURL: http://litecoind:43782/ - NBXPLORER_LTCNODEENDPOINT: litecoind:39388 - volumes: - - "nbxplorer_datadir:/datadir" - - "litecoin_datadir:/root/.litecoin" - links: - - litecoind - postgres: - restart: unless-stopped - image: postgres:9.6.5 - volumes: - - "postgres_datadir:/var/lib/postgresql/data" - litecoind: - restart: unless-stopped - container_name: btcpayserver_litecoind - image: nicolasdorier/docker-litecoin:0.16.3 - environment: - BITCOIN_EXTRA_ARGS: | - rpcport=43782 - ${NBITCOIN_NETWORK:-regtest}=1 - port=39388 - whitelist=0.0.0.0/0 - expose: - - "43782" - - "39388" - volumes: - - "litecoin_datadir:/data" - clightning_litecoin: - image: nicolasdorier/clightning:634f19a7b230edc686be56ab950b80784e56252c - container_name: btcpayserver_clightning_litecoin - restart: unless-stopped - environment: - LIGHTNINGD_NETWORK: ${NBITCOIN_NETWORK:-regtest} - LIGHTNINGD_CHAIN: ltc - LIGHTNINGD_EXPLORERURL: "http://nbxplorer:32838/" - LIGHTNINGD_OPT: | - bitcoin-datadir=/etc/litecoin - bitcoin-rpcconnect=litecoind - bind-addr=0.0.0.0:9735 - announce-addr=${BTCPAY_HOST}:9736 - network=${NBITCOIN_NETWORK:-regtest} - alias=${LIGHTNING_ALIAS} - chain=ltc - volumes: - - "clightning_litecoin_datadir:/root/.lightning" - - "litecoin_datadir:/etc/litecoin" - - "nbxplorer_datadir:/root/.nbxplorer" - ports: - - "9736:9735" - links: - - nbxplorer - - litecoind -volumes: - postgres_datadir: - btcpay_datadir: - nbxplorer_datadir: - litecoin_datadir: - clightning_litecoin_datadir: diff --git a/Production-NoReverseProxy/docker-compose.ltc.yml b/Production-NoReverseProxy/docker-compose.ltc.yml deleted file mode 100644 index 410e25e..0000000 --- a/Production-NoReverseProxy/docker-compose.ltc.yml +++ /dev/null @@ -1,72 +0,0 @@ -version: "3" -services: - btcpayserver: - restart: unless-stopped - image: nicolasdorier/btcpayserver:1.0.2.105 - expose: - - "49392" - environment: - BTCPAY_POSTGRES: User ID=postgres;Host=postgres;Port=5432;Database=btcpayserver${NBITCOIN_NETWORK:-regtest} - BTCPAY_NETWORK: ${NBITCOIN_NETWORK:-regtest} - BTCPAY_BIND: 0.0.0.0:49392 - BTCPAY_EXTERNALURL: ${BTCPAY_PROTOCOL:-https}://${BTCPAY_HOST}/ - BTCPAY_ROOTPATH: ${BTCPAY_ROOTPATH:-/} - BTCPAY_SSHTRUSTEDFINGERPRINTS: ${BTCPAY_SSHTRUSTEDFINGERPRINTS} - BTCPAY_SSHKEYFILE: ${BTCPAY_SSHKEYFILE} - VIRTUAL_NETWORK: nginx-proxy - VIRTUAL_PORT: 49392 - VIRTUAL_HOST: ${BTCPAY_HOST} - SSL_POLICY: Mozilla-Modern - LETSENCRYPT_HOST: ${BTCPAY_HOST} - LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL:-} - BTCPAY_LTCEXPLORERURL: http://nbxplorer:32838/ - BTCPAY_CHAINS: "ltc" - links: - - nbxplorer - - postgres - volumes: - - "btcpay_datadir:/datadir" - - "nbxplorer_datadir:/root/.nbxplorer" - ports: - - "80:49392" - nbxplorer: - restart: unless-stopped - image: nicolasdorier/nbxplorer:1.0.2.31 - expose: - - "32838" - environment: - NBXPLORER_NETWORK: ${NBITCOIN_NETWORK:-regtest} - NBXPLORER_BIND: 0.0.0.0:32838 - NBXPLORER_CHAINS: "ltc" - NBXPLORER_LTCRPCURL: http://litecoind:43782/ - NBXPLORER_LTCNODEENDPOINT: litecoind:39388 - volumes: - - "nbxplorer_datadir:/datadir" - - "litecoin_datadir:/root/.litecoin" - links: - - litecoind - postgres: - restart: unless-stopped - image: postgres:9.6.5 - volumes: - - "postgres_datadir:/var/lib/postgresql/data" - litecoind: - restart: unless-stopped - container_name: btcpayserver_litecoind - image: nicolasdorier/docker-litecoin:0.16.3 - environment: - BITCOIN_EXTRA_ARGS: | - rpcport=43782 - ${NBITCOIN_NETWORK:-regtest}=1 - port=39388 - whitelist=0.0.0.0/0 - expose: - - "43782" - - "39388" - volumes: - - "litecoin_datadir:/data" -volumes: - postgres_datadir: - btcpay_datadir: - nbxplorer_datadir: - litecoin_datadir: diff --git a/Production/README.md b/Production/README.md index 5f4868a..034c339 100644 --- a/Production/README.md +++ b/Production/README.md @@ -1,19 +1,7 @@ -# About those docker-compose +# How to use docker-compose with NGinx -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)) script from the fragments located in [docker-compose-generator/docker-fragments](docker-compose-generator/docker-fragments). - -The pre-generated `docker-compose` files only cover `btc`, `ltc`, `clightning` with `nginx`. - ---- - -We strongly advise you to not use the pre-generated docker-compose of this folder, they are deprecated and kept only for backward compatibility. -Instead use the [build.sh](../build.sh) as documented in (README)(../Readme.md) to generate a docker-compose which fit your needs. - ---- - -The `docker-compose` can be used for production purpose. - -It is composed of: +NGinx acts as a reverse proxy, and takes care of renewing HTTPS certificates for you. +BTCPay Server deployment using NGinx are typically composed of: 1. One full node per supported cryptocurrency (bitcoind/litecoind) 2. A lightweight block explorer ([NBxplorer](https://github.com/dgarage/NBXplorer)) @@ -39,8 +27,6 @@ The relevant environment variables are: If `BTCPAY_HOST` is `btcpay.example.com` and `BTCPAY_ROOTPATH` is `/btcpay`, then you can access the site via `https://btcpay.example.com/btcpay` -Use `docker-compose.btc-ltc.yml` for bitcoin and litecoin support, or `docker-compose.btc.yml` for only bitcoin. - Any unset or empty environment variable will be set for a `regtest` deployment. The ports mapped on the host are: diff --git a/Production/docker-compose.btc-clightning.yml b/Production/docker-compose.btc-clightning.yml deleted file mode 100644 index 7a58a45..0000000 --- a/Production/docker-compose.btc-clightning.yml +++ /dev/null @@ -1,147 +0,0 @@ -version: "3" -services: - nginx: - restart: unless-stopped - image: nginx:stable - container_name: nginx - ports: - - "80:80" - - "443:443" - volumes: - - "nginx_conf:/etc/nginx/conf.d" - - "nginx_vhost:/etc/nginx/vhost.d" - - "nginx_html:/usr/share/nginx/html" - - "nginx_certs:/etc/nginx/certs:ro" - links: - - btcpayserver - nginx-gen: - restart: unless-stopped - image: jwilder/docker-gen - container_name: nginx-gen - volumes: - - "/var/run/docker.sock:/tmp/docker.sock:ro" - - "./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro" - - "nginx_conf:/etc/nginx/conf.d" - - "nginx_vhost:/etc/nginx/vhost.d" - - "nginx_html:/usr/share/nginx/html" - - "nginx_certs:/etc/nginx/certs:ro" - entrypoint: /usr/local/bin/docker-gen -notify-sighup nginx -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf - links: - - nginx - letsencrypt-nginx-proxy-companion: - restart: unless-stopped - image: jrcs/letsencrypt-nginx-proxy-companion - container_name: letsencrypt-nginx-proxy-companion - volumes: - - "/var/run/docker.sock:/var/run/docker.sock:ro" - - "nginx_conf:/etc/nginx/conf.d" - - "nginx_vhost:/etc/nginx/vhost.d" - - "nginx_html:/usr/share/nginx/html" - - "nginx_certs:/etc/nginx/certs:rw" - environment: - NGINX_DOCKER_GEN_CONTAINER: "nginx-gen" - NGINX_PROXY_CONTAINER: "nginx" - ACME_CA_URI: ${ACME_CA_URI:-https://acme-staging.api.letsencrypt.org/directory} - links: - - nginx-gen - btcpayserver: - restart: unless-stopped - image: nicolasdorier/btcpayserver:1.0.2.105 - expose: - - "49392" - environment: - BTCPAY_POSTGRES: User ID=postgres;Host=postgres;Port=5432;Database=btcpayserver${NBITCOIN_NETWORK:-regtest} - BTCPAY_NETWORK: ${NBITCOIN_NETWORK:-regtest} - BTCPAY_BIND: 0.0.0.0:49392 - BTCPAY_EXTERNALURL: ${BTCPAY_PROTOCOL:-https}://${BTCPAY_HOST}/ - BTCPAY_ROOTPATH: ${BTCPAY_ROOTPATH:-/} - BTCPAY_SSHTRUSTEDFINGERPRINTS: ${BTCPAY_SSHTRUSTEDFINGERPRINTS} - BTCPAY_SSHKEYFILE: ${BTCPAY_SSHKEYFILE} - VIRTUAL_NETWORK: nginx-proxy - VIRTUAL_PORT: 49392 - VIRTUAL_HOST: ${BTCPAY_HOST} - SSL_POLICY: Mozilla-Modern - LETSENCRYPT_HOST: ${BTCPAY_HOST} - LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL:-} - BTCPAY_CHAINS: "btc" - BTCPAY_BTCEXPLORERURL: http://nbxplorer:32838/ - BTCPAY_BTCLIGHTNING: "type=clightning;server=unix://etc/clightning_bitcoin/lightning-rpc" - links: - - nbxplorer - - postgres - - clightning_bitcoin - volumes: - - "btcpay_datadir:/datadir" - - "nbxplorer_datadir:/root/.nbxplorer" - - "clightning_bitcoin_datadir:/etc/clightning_bitcoin" - nbxplorer: - restart: unless-stopped - image: nicolasdorier/nbxplorer:1.0.2.31 - expose: - - "32838" - environment: - NBXPLORER_NETWORK: ${NBITCOIN_NETWORK:-regtest} - NBXPLORER_BIND: 0.0.0.0:32838 - NBXPLORER_CHAINS: "btc" - NBXPLORER_BTCRPCURL: http://bitcoind:43782/ - NBXPLORER_BTCNODEENDPOINT: bitcoind:39388 - volumes: - - "nbxplorer_datadir:/datadir" - - "bitcoin_datadir:/root/.bitcoin" - links: - - bitcoind - postgres: - restart: unless-stopped - image: postgres:9.6.5 - volumes: - - "postgres_datadir:/var/lib/postgresql/data" - bitcoind: - restart: unless-stopped - container_name: btcpayserver_bitcoind - image: nicolasdorier/docker-bitcoin:0.16.3 - environment: - BITCOIN_EXTRA_ARGS: | - rpcport=43782 - ${NBITCOIN_NETWORK:-regtest}=1 - port=39388 - whitelist=0.0.0.0/0 - expose: - - "43782" - - "39388" - volumes: - - "bitcoin_datadir:/data" - clightning_bitcoin: - image: nicolasdorier/clightning:634f19a7b230edc686be56ab950b80784e56252c - container_name: btcpayserver_clightning_bitcoin - restart: unless-stopped - environment: - LIGHTNINGD_NETWORK: ${NBITCOIN_NETWORK:-regtest} - LIGHTNINGD_CHAIN: btc - LIGHTNINGD_EXPLORERURL: "http://nbxplorer:32838/" - LIGHTNINGD_OPT: | - bitcoin-datadir=/etc/bitcoin - bitcoin-rpcconnect=bitcoind - announce-addr=${BTCPAY_HOST}:9735 - bind-addr=0.0.0.0:9735 - network=${NBITCOIN_NETWORK:-regtest} - alias=${LIGHTNING_ALIAS} - chain=btc - volumes: - - "clightning_bitcoin_datadir:/root/.lightning" - - "bitcoin_datadir:/etc/bitcoin" - - "nbxplorer_datadir:/root/.nbxplorer" - ports: - - "9735:9735" - links: - - nbxplorer - - bitcoind -volumes: - nginx_conf: - nginx_vhost: - nginx_html: - nginx_certs: - postgres_datadir: - btcpay_datadir: - nbxplorer_datadir: - bitcoin_datadir: - clightning_bitcoin_datadir: diff --git a/Production/docker-compose.btc-ltc-clightning.yml b/Production/docker-compose.btc-ltc-clightning.yml index 984ee55..7ca69b4 100644 --- a/Production/docker-compose.btc-ltc-clightning.yml +++ b/Production/docker-compose.btc-ltc-clightning.yml @@ -1,4 +1,5 @@ version: "3" +# DO NOT USE THOSE ARE DEPRECATED services: nginx: restart: unless-stopped @@ -46,7 +47,7 @@ services: - nginx-gen btcpayserver: restart: unless-stopped - image: nicolasdorier/btcpayserver:1.0.2.105 + image: nicolasdorier/btcpayserver:1.0.2.106 expose: - "49392" environment: @@ -112,14 +113,18 @@ services: rpcport=43782 ${NBITCOIN_NETWORK:-regtest}=1 port=39388 + zmqpubrawblock=tcp://0.0.0.0:28332 + zmqpubrawtx=tcp://0.0.0.0:28333 whitelist=0.0.0.0/0 expose: - "43782" - "39388" + - "28332" + - "28333" volumes: - "litecoin_datadir:/data" clightning_litecoin: - image: nicolasdorier/clightning:634f19a7b230edc686be56ab950b80784e56252c + image: nicolasdorier/clightning:v0.6.1 container_name: btcpayserver_clightning_litecoin restart: unless-stopped environment: @@ -153,13 +158,17 @@ services: ${NBITCOIN_NETWORK:-regtest}=1 port=39388 whitelist=0.0.0.0/0 + zmqpubrawblock=tcp://0.0.0.0:28332 + zmqpubrawtx=tcp://0.0.0.0:28333 expose: - "43782" - "39388" + - "28332" + - "28333" volumes: - "bitcoin_datadir:/data" clightning_bitcoin: - image: nicolasdorier/clightning:634f19a7b230edc686be56ab950b80784e56252c + image: nicolasdorier/clightning:v0.6.1 container_name: btcpayserver_clightning_bitcoin restart: unless-stopped environment: diff --git a/Production/docker-compose.btc-ltc.yml b/Production/docker-compose.btc-ltc.yml index bdf658e..6adaa2d 100644 --- a/Production/docker-compose.btc-ltc.yml +++ b/Production/docker-compose.btc-ltc.yml @@ -1,4 +1,5 @@ version: "3" +# DO NOT USE THOSE ARE DEPRECATED services: nginx: restart: unless-stopped @@ -46,7 +47,7 @@ services: - nginx-gen btcpayserver: restart: unless-stopped - image: nicolasdorier/btcpayserver:1.0.2.105 + image: nicolasdorier/btcpayserver:1.0.2.106 expose: - "49392" environment: @@ -106,10 +107,14 @@ services: rpcport=43782 ${NBITCOIN_NETWORK:-regtest}=1 port=39388 + zmqpubrawblock=tcp://0.0.0.0:28332 + zmqpubrawtx=tcp://0.0.0.0:28333 whitelist=0.0.0.0/0 expose: - "43782" - "39388" + - "28332" + - "28333" volumes: - "litecoin_datadir:/data" bitcoind: @@ -122,9 +127,13 @@ services: ${NBITCOIN_NETWORK:-regtest}=1 port=39388 whitelist=0.0.0.0/0 + zmqpubrawblock=tcp://0.0.0.0:28332 + zmqpubrawtx=tcp://0.0.0.0:28333 expose: - "43782" - "39388" + - "28332" + - "28333" volumes: - "bitcoin_datadir:/data" volumes: diff --git a/Production/docker-compose.btc.yml b/Production/docker-compose.btc.yml index 6ca058e..3d569ac 100644 --- a/Production/docker-compose.btc.yml +++ b/Production/docker-compose.btc.yml @@ -46,7 +46,7 @@ services: - nginx-gen btcpayserver: restart: unless-stopped - image: nicolasdorier/btcpayserver:1.0.2.105 + image: nicolasdorier/btcpayserver:1.0.2.106 expose: - "49392" environment: @@ -102,9 +102,13 @@ services: ${NBITCOIN_NETWORK:-regtest}=1 port=39388 whitelist=0.0.0.0/0 + zmqpubrawblock=tcp://0.0.0.0:28332 + zmqpubrawtx=tcp://0.0.0.0:28333 expose: - "43782" - "39388" + - "28332" + - "28333" volumes: - "bitcoin_datadir:/data" volumes: diff --git a/Production/docker-compose.ltc-clightning.yml b/Production/docker-compose.ltc-clightning.yml deleted file mode 100644 index 5e58b31..0000000 --- a/Production/docker-compose.ltc-clightning.yml +++ /dev/null @@ -1,147 +0,0 @@ -version: "3" -services: - nginx: - restart: unless-stopped - image: nginx:stable - container_name: nginx - ports: - - "80:80" - - "443:443" - volumes: - - "nginx_conf:/etc/nginx/conf.d" - - "nginx_vhost:/etc/nginx/vhost.d" - - "nginx_html:/usr/share/nginx/html" - - "nginx_certs:/etc/nginx/certs:ro" - links: - - btcpayserver - nginx-gen: - restart: unless-stopped - image: jwilder/docker-gen - container_name: nginx-gen - volumes: - - "/var/run/docker.sock:/tmp/docker.sock:ro" - - "./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro" - - "nginx_conf:/etc/nginx/conf.d" - - "nginx_vhost:/etc/nginx/vhost.d" - - "nginx_html:/usr/share/nginx/html" - - "nginx_certs:/etc/nginx/certs:ro" - entrypoint: /usr/local/bin/docker-gen -notify-sighup nginx -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf - links: - - nginx - letsencrypt-nginx-proxy-companion: - restart: unless-stopped - image: jrcs/letsencrypt-nginx-proxy-companion - container_name: letsencrypt-nginx-proxy-companion - volumes: - - "/var/run/docker.sock:/var/run/docker.sock:ro" - - "nginx_conf:/etc/nginx/conf.d" - - "nginx_vhost:/etc/nginx/vhost.d" - - "nginx_html:/usr/share/nginx/html" - - "nginx_certs:/etc/nginx/certs:rw" - environment: - NGINX_DOCKER_GEN_CONTAINER: "nginx-gen" - NGINX_PROXY_CONTAINER: "nginx" - ACME_CA_URI: ${ACME_CA_URI:-https://acme-staging.api.letsencrypt.org/directory} - links: - - nginx-gen - btcpayserver: - restart: unless-stopped - image: nicolasdorier/btcpayserver:1.0.2.105 - expose: - - "49392" - environment: - BTCPAY_POSTGRES: User ID=postgres;Host=postgres;Port=5432;Database=btcpayserver${NBITCOIN_NETWORK:-regtest} - BTCPAY_NETWORK: ${NBITCOIN_NETWORK:-regtest} - BTCPAY_BIND: 0.0.0.0:49392 - BTCPAY_EXTERNALURL: ${BTCPAY_PROTOCOL:-https}://${BTCPAY_HOST}/ - BTCPAY_ROOTPATH: ${BTCPAY_ROOTPATH:-/} - BTCPAY_SSHTRUSTEDFINGERPRINTS: ${BTCPAY_SSHTRUSTEDFINGERPRINTS} - BTCPAY_SSHKEYFILE: ${BTCPAY_SSHKEYFILE} - VIRTUAL_NETWORK: nginx-proxy - VIRTUAL_PORT: 49392 - VIRTUAL_HOST: ${BTCPAY_HOST} - SSL_POLICY: Mozilla-Modern - LETSENCRYPT_HOST: ${BTCPAY_HOST} - LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL:-} - BTCPAY_LTCEXPLORERURL: http://nbxplorer:32838/ - BTCPAY_CHAINS: "ltc" - BTCPAY_LTCLIGHTNING: "type=clightning;server=unix://etc/clightning_litecoin/lightning-rpc" - links: - - nbxplorer - - postgres - - clightning_litecoin - volumes: - - "btcpay_datadir:/datadir" - - "nbxplorer_datadir:/root/.nbxplorer" - - "clightning_litecoin_datadir:/etc/clightning_litecoin" - nbxplorer: - restart: unless-stopped - image: nicolasdorier/nbxplorer:1.0.2.31 - expose: - - "32838" - environment: - NBXPLORER_NETWORK: ${NBITCOIN_NETWORK:-regtest} - NBXPLORER_BIND: 0.0.0.0:32838 - NBXPLORER_CHAINS: "ltc" - NBXPLORER_LTCRPCURL: http://litecoind:43782/ - NBXPLORER_LTCNODEENDPOINT: litecoind:39388 - volumes: - - "nbxplorer_datadir:/datadir" - - "litecoin_datadir:/root/.litecoin" - links: - - litecoind - postgres: - restart: unless-stopped - image: postgres:9.6.5 - volumes: - - "postgres_datadir:/var/lib/postgresql/data" - litecoind: - restart: unless-stopped - container_name: btcpayserver_litecoind - image: nicolasdorier/docker-litecoin:0.16.3 - environment: - BITCOIN_EXTRA_ARGS: | - rpcport=43782 - ${NBITCOIN_NETWORK:-regtest}=1 - port=39388 - whitelist=0.0.0.0/0 - expose: - - "43782" - - "39388" - volumes: - - "litecoin_datadir:/data" - clightning_litecoin: - image: nicolasdorier/clightning:634f19a7b230edc686be56ab950b80784e56252c - container_name: btcpayserver_clightning_litecoin - restart: unless-stopped - environment: - LIGHTNINGD_NETWORK: ${NBITCOIN_NETWORK:-regtest} - LIGHTNINGD_CHAIN: ltc - LIGHTNINGD_EXPLORERURL: "http://nbxplorer:32838/" - LIGHTNINGD_OPT: | - bitcoin-datadir=/etc/litecoin - bitcoin-rpcconnect=litecoind - bind-addr=0.0.0.0:9735 - announce-addr=${BTCPAY_HOST}:9736 - network=${NBITCOIN_NETWORK:-regtest} - alias=${LIGHTNING_ALIAS} - chain=ltc - volumes: - - "clightning_litecoin_datadir:/root/.lightning" - - "litecoin_datadir:/etc/litecoin" - - "nbxplorer_datadir:/root/.nbxplorer" - ports: - - "9736:9735" - links: - - nbxplorer - - litecoind -volumes: - nginx_conf: - nginx_vhost: - nginx_html: - nginx_certs: - postgres_datadir: - btcpay_datadir: - nbxplorer_datadir: - litecoin_datadir: - clightning_litecoin_datadir: diff --git a/Production/docker-compose.ltc.yml b/Production/docker-compose.ltc.yml deleted file mode 100644 index 7551060..0000000 --- a/Production/docker-compose.ltc.yml +++ /dev/null @@ -1,118 +0,0 @@ -version: "3" -services: - nginx: - restart: unless-stopped - image: nginx:stable - container_name: nginx - ports: - - "80:80" - - "443:443" - volumes: - - "nginx_conf:/etc/nginx/conf.d" - - "nginx_vhost:/etc/nginx/vhost.d" - - "nginx_html:/usr/share/nginx/html" - - "nginx_certs:/etc/nginx/certs:ro" - links: - - btcpayserver - nginx-gen: - restart: unless-stopped - image: jwilder/docker-gen - container_name: nginx-gen - volumes: - - "/var/run/docker.sock:/tmp/docker.sock:ro" - - "./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro" - - "nginx_conf:/etc/nginx/conf.d" - - "nginx_vhost:/etc/nginx/vhost.d" - - "nginx_html:/usr/share/nginx/html" - - "nginx_certs:/etc/nginx/certs:ro" - entrypoint: /usr/local/bin/docker-gen -notify-sighup nginx -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf - links: - - nginx - letsencrypt-nginx-proxy-companion: - restart: unless-stopped - image: jrcs/letsencrypt-nginx-proxy-companion - container_name: letsencrypt-nginx-proxy-companion - volumes: - - "/var/run/docker.sock:/var/run/docker.sock:ro" - - "nginx_conf:/etc/nginx/conf.d" - - "nginx_vhost:/etc/nginx/vhost.d" - - "nginx_html:/usr/share/nginx/html" - - "nginx_certs:/etc/nginx/certs:rw" - environment: - NGINX_DOCKER_GEN_CONTAINER: "nginx-gen" - NGINX_PROXY_CONTAINER: "nginx" - ACME_CA_URI: ${ACME_CA_URI:-https://acme-staging.api.letsencrypt.org/directory} - links: - - nginx-gen - btcpayserver: - restart: unless-stopped - image: nicolasdorier/btcpayserver:1.0.2.105 - expose: - - "49392" - environment: - BTCPAY_POSTGRES: User ID=postgres;Host=postgres;Port=5432;Database=btcpayserver${NBITCOIN_NETWORK:-regtest} - BTCPAY_NETWORK: ${NBITCOIN_NETWORK:-regtest} - BTCPAY_BIND: 0.0.0.0:49392 - BTCPAY_EXTERNALURL: ${BTCPAY_PROTOCOL:-https}://${BTCPAY_HOST}/ - BTCPAY_ROOTPATH: ${BTCPAY_ROOTPATH:-/} - BTCPAY_SSHTRUSTEDFINGERPRINTS: ${BTCPAY_SSHTRUSTEDFINGERPRINTS} - BTCPAY_SSHKEYFILE: ${BTCPAY_SSHKEYFILE} - VIRTUAL_NETWORK: nginx-proxy - VIRTUAL_PORT: 49392 - VIRTUAL_HOST: ${BTCPAY_HOST} - SSL_POLICY: Mozilla-Modern - LETSENCRYPT_HOST: ${BTCPAY_HOST} - LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL:-} - BTCPAY_LTCEXPLORERURL: http://nbxplorer:32838/ - BTCPAY_CHAINS: "ltc" - links: - - nbxplorer - - postgres - volumes: - - "btcpay_datadir:/datadir" - - "nbxplorer_datadir:/root/.nbxplorer" - nbxplorer: - restart: unless-stopped - image: nicolasdorier/nbxplorer:1.0.2.31 - expose: - - "32838" - environment: - NBXPLORER_NETWORK: ${NBITCOIN_NETWORK:-regtest} - NBXPLORER_BIND: 0.0.0.0:32838 - NBXPLORER_CHAINS: "ltc" - NBXPLORER_LTCRPCURL: http://litecoind:43782/ - NBXPLORER_LTCNODEENDPOINT: litecoind:39388 - volumes: - - "nbxplorer_datadir:/datadir" - - "litecoin_datadir:/root/.litecoin" - links: - - litecoind - postgres: - restart: unless-stopped - image: postgres:9.6.5 - volumes: - - "postgres_datadir:/var/lib/postgresql/data" - litecoind: - restart: unless-stopped - container_name: btcpayserver_litecoind - image: nicolasdorier/docker-litecoin:0.16.3 - environment: - BITCOIN_EXTRA_ARGS: | - rpcport=43782 - ${NBITCOIN_NETWORK:-regtest}=1 - port=39388 - whitelist=0.0.0.0/0 - expose: - - "43782" - - "39388" - volumes: - - "litecoin_datadir:/data" -volumes: - nginx_conf: - nginx_vhost: - nginx_html: - nginx_certs: - postgres_datadir: - btcpay_datadir: - nbxplorer_datadir: - litecoin_datadir: diff --git a/Production/nginx.tmpl b/Production/nginx.tmpl index f47dc1e..84ffaf5 100644 --- a/Production/nginx.tmpl +++ b/Production/nginx.tmpl @@ -296,13 +296,17 @@ server { {{ else if (exists "/etc/nginx/vhost.d/default_location") }} include /etc/nginx/vhost.d/default_location; {{ end }} - } + } {{ range $container := $ }} {{ $serviceName := (index $container.Labels "com.docker.compose.service") }} {{ if (eq $serviceName "lnd_bitcoin") }} location /lnrpc.Lightning { - grpc_pass grpcs://lnd_bitcoin:10009; + grpc_pass grpcs://lnd_bitcoin:10009; + } + location /lnd-rest/btc/ { + rewrite ^/lnd-rest/btc/(.*) /$1 break; + proxy_pass http://lnd_bitcoin:8080/; } {{ end }} {{ end }} diff --git a/README.md b/README.md index 277e5a1..33dd319 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ You can read [the article](https://medium.com/@BtcpayServer/hosting-btcpay-serve * `BTCPAYGEN_CRYPTO1`: First supported crypto currency (eg. `btc`, `ltc`. Default: `btc`) * `BTCPAYGEN_CRYPTO2`: Second supported crypto currency (eg. `btc`, `ltc`. Default: `(empty)`) * `BTCPAYGEN_CRYPTON`: N'th supported crypto currency where N is 9 at maximum. (eg. `btc`, `ltc`. Default: `(empty)`) -* `BTCPAYGEN_REVERSEPROXY`: Specify reverse proxy to use; NGinx has HTTPS support. (eg. `nginx`, `(empty)`. Default: `nginx`) +* `BTCPAYGEN_REVERSEPROXY`: Specify reverse proxy to use; NGinx has HTTPS support. (eg. `nginx`, `traefik`, `(empty)`. Default: `nginx`) * `BTCPAYGEN_LIGHTNING`: Lightning network implementation to use (eg. `clightning`, `(empty)`) * `BTCPAYGEN_SUBNAME`: The subname of the generated docker-compose file, where the full name is `Generated/docker-compose.SUBNAME.yml` (Default: `generated`) * `BTCPAYGEN_ADDITIONAL_FRAGMENTS`: Semicolon-separated list of additional fragments you want to use (eg. `opt-save-storage`) @@ -123,6 +123,7 @@ You can read [the article](https://medium.com/@BtcpayServer/hosting-btcpay-serve * `ACME_CA_URI`: The API endpoint to ask for HTTPS certificate (Default: `https://acme-v01.api.letsencrypt.org/directory`) * `BTCPAY_HOST_SSHKEYFILE`: Optional, SSH private key that BTCPay can use to connect to this VM's SSH server. This key will be copied to BTCPay's data directory * `BTCPAY_SSHTRUSTEDFINGERPRINTS`: Optional, BTCPay will ensure that it is connecting to the expected SSH server by checking the host's public key against these fingerprints +* `BTCPAYGEN_DOCKER_IMAGE`: Optional, Specify which generator image to use if you have customized the C# generator. Set to `btcpayserver/docker-compose-generator:local` to build the generator locally at runtime. # Tooling @@ -270,19 +271,23 @@ BTCPAY_SSHKEYFILE=/datadir/id_rsa 1. Add support for your crypto to [NBitcoin](https://github.com/MetacoSA/NBitcoin/tree/master/NBitcoin.Altcoins), [NBxplorer](https://github.com/dgarage/NBXplorer), and [BTCPayServer](https://github.com/btcpayserver/btcpayserver). (Use examples from 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 CryptoDefinition ([Example for BTC](docker-compose-generator/src/CryptoDefinition.cs)) +4. Add your `CryptoDefinition` ([Example for BTC](docker-compose-generator/src/CryptoDefinition.cs)) -When testing your coin, **DO NOT USE `build.sh`**, since it uses a pre-built docker image. - -Instead, install [.NET Core 2.1 SDK](https://www.microsoft.com/net/download/windows) and run: +`build.sh` is using a pre-built image of the `docker-compose generator` on [docker hub](https://hub.docker.com/r/btcpayserver/docker-compose-generator/). +If you modify the code source of `docker-compose generator` (for example, the `CryptoDefinition` [Example for BTC](docker-compose-generator/src/CryptoDefinition.cs)), you need to configure `build.sh` to use your own image by setting the environment variable `BTCPAYGEN_DOCKER_IMAGE` to `btcpayserver/docker-compose-generator:local`. ```bash -BTCPAYGEN_CRYPTO1="EXAMPLE-COIN" -BTCPAYGEN_SUBNAME="test" -cd docker-compose-generator/src -dotnet run +cd docker-compose-generator +BTCPAYGEN_DOCKER_IMAGE="btcpayserver/docker-compose-generator:local" ``` +Or on powershell: +```powershell +cd docker-compose-generator +$BTCPAYGEN_DOCKER_IMAGE="btcpayserver/docker-compose-generator:local" +``` + +Then run `./build.sh` or `. .\build.ps1`. This will generate your docker-compose in the `Generated` folder, which you can then run and test. Note that BTCPayServer developers will not spend excessive time testing your image, so make sure it works. @@ -306,9 +311,14 @@ Yes, run the following commands to update: ```bash sudo su - -btcpay-update.sh cd $DOWNLOAD_ROOT/btcpayserver-docker +git checkout master +git pull +git checkout 9acb5d8067cb5c46f59858137feb699b41ac9f19 +btcpay-update.sh . ./btcpay-setup.sh -i +git checkout master +btcpay-update.sh exit ``` diff --git a/Traefik/Production.png b/Traefik/Production.png new file mode 100644 index 0000000..e28875a Binary files /dev/null and b/Traefik/Production.png differ diff --git a/Traefik/README.md b/Traefik/README.md new file mode 100644 index 0000000..1c69e73 --- /dev/null +++ b/Traefik/README.md @@ -0,0 +1,17 @@ +# How to use docker-compose with Traefik + +Traefik is a modern reverse proxy aimed towards applications running through container orchestrators. + +Some of the benefits of using Traefik over NGinx are: +* Real-time configuration changes - no need to reload the proxy +* Auto discovery and configuration of services through a vast amount of container orchestrators. +* Built-in official support for Let's Encrypt SSL with certificate auto-renewal + +## Traefik Specific Environment Variables + +* `BTCPAYGEN_REVERSEPROXY` to `traefik`. +* `LETSENCRYPT_EMAIL`: Optional, The email Let's Encrypt will use to notify you about certificate expiration. +* `BTCPAYGEN_ADDITIONAL_FRAGMENTS`: In the case that you have an already deployed traefik container, you can use the fragment `traefik-labels` which will tag the btcpayserver service with the needed labels to be discovered. + + +![Architecture](Production.png) \ No newline at end of file diff --git a/Traefik/traefik.toml b/Traefik/traefik.toml new file mode 100644 index 0000000..b85e505 --- /dev/null +++ b/Traefik/traefik.toml @@ -0,0 +1,34 @@ +defaultEntryPoints = ["https","http"] + +logLevel = "ERROR" + +[entryPoints] + [entryPoints.http] + address = ":80" + [entryPoints.http.redirect] + entryPoint = "https" + [entryPoints.https] + address = ":443" + [entryPoints.https.tls] + +[retry] + +[docker] +endpoint = "unix:///var/run/docker.sock" +watch = true +exposedByDefault = false + +[acme] +storage = "acme.json" +entryPoint = "https" +onHostRule = true +[acme.httpChallenge] +entryPoint = "http" + +[traefikLog] + filePath = "/traefik_logs/traefik.log" + format = "json" + +[accessLog] + filePath = "/traefik_logs/access.log" + format = "json" diff --git a/bitcoin-lncli.ps1 b/bitcoin-lncli.ps1 index f42a002..f40e82e 100755 --- a/bitcoin-lncli.ps1 +++ b/bitcoin-lncli.ps1 @@ -1 +1 @@ -docker exec -ti btcpayserver_lnd_bitcoin lncli $args +docker exec -ti btcpayserver_lnd_bitcoin lncli --macaroonpath /root/.lnd/admin.macaroon $args diff --git a/bitcoin-lncli.sh b/bitcoin-lncli.sh index e94deb1..34b1b55 100755 --- a/bitcoin-lncli.sh +++ b/bitcoin-lncli.sh @@ -1,3 +1,3 @@ #!/bin/bash -docker exec -ti btcpayserver_lnd_bitcoin lncli "$@" +docker exec -ti btcpayserver_lnd_bitcoin lncli --macaroonpath /root/.lnd/admin.macaroon "$@" diff --git a/btcpay-setup.sh b/btcpay-setup.sh index 79fd939..6973104 100755 --- a/btcpay-setup.sh +++ b/btcpay-setup.sh @@ -55,12 +55,12 @@ Environment variables: BTCPAYGEN_CRYPTO1: First supported crypto currency (eg. btc, ltc, btg, grs, ftc, via, none. Default: btc) BTCPAYGEN_CRYPTO2: Second supported crypto currency (Default: empty) BTCPAYGEN_CRYPTON: N th supported crypto currency where N is maximum at maximum 9. (Default: none) - BTCPAYGEN_REVERSEPROXY: Whether to use or not a reverse proxy. NGinx setup HTTPS for you. (eg. nginx, none. Default: nginx) + BTCPAYGEN_REVERSEPROXY: Whether to use or not a reverse proxy. NGinx setup HTTPS for you. (eg. nginx, traefik, none. Default: nginx) BTCPAYGEN_LIGHTNING: Lightning network implementation to use (eg. clightning, lnd, none) BTCPAYGEN_ADDITIONAL_FRAGMENTS: Semi colon separated list of additional fragments you want to use (eg. opt-save-storage) ACME_CA_URI: The API endpoint to ask for HTTPS certificate (default: https://acme-v01.api.letsencrypt.org/directory) BTCPAY_HOST_SSHKEYFILE: Optional, SSH private key that BTCPay can use to connect to this VM's SSH server. This key will be copied on BTCPay's data directory - + BTCPAYGEN_DOCKER_IMAGE: Allows you to specify a custom docker image for the generator (Default: btcpayserver/docker-compose-generator) END } @@ -71,53 +71,8 @@ fi ######### Migration: old pregen environment to new environment ############ if [ ! -z $BTCPAY_DOCKER_COMPOSE ] && [ ! -z $DOWNLOAD_ROOT ] && [ -z $BTCPAYGEN_OLD_PREGEN ]; then - echo "Old pregen docker deployment detected. Migrating..." - rm "$DOWNLOAD_ROOT/btcpay-restart.sh" - rm "$DOWNLOAD_ROOT/btcpay-update.sh" - rm "$DOWNLOAD_ROOT/changedomain.sh" - rm "$DOWNLOAD_ROOT/entrypoint.sh" - DOWNLOAD_ROOT="" - BTCPAYGEN_OLD_PREGEN="true" - # Migration: old deployment store those in BTCPAY_ENV_FILE - BTCPAY_HOST=$(cat $BTCPAY_ENV_FILE | sed -n 's/^BTCPAY_HOST=\(.*\)$/\1/p') - ACME_CA_URI=$(cat $BTCPAY_ENV_FILE | sed -n 's/^ACME_CA_URI=\(.*\)$/\1/p') - NBITCOIN_NETWORK=$(cat $BTCPAY_ENV_FILE | sed -n 's/^NBITCOIN_NETWORK=\(.*\)$/\1/p') - LETSENCRYPT_EMAIL=$(cat $BTCPAY_ENV_FILE | sed -n 's/^LETSENCRYPT_EMAIL=\(.*\)$/\1/p') - LIGHTNING_ALIAS=$(cat $BTCPAY_ENV_FILE | sed -n 's/^LIGHTNING_ALIAS=\(.*\)$/\1/p') - - if [[ $(dirname $BTCPAY_DOCKER_COMPOSE) == *Production ]]; then - BTCPAYGEN_REVERSEPROXY='nginx' - fi - if [[ $(dirname $BTCPAY_DOCKER_COMPOSE) == *Production-NoReverseProxy ]]; then - BTCPAYGEN_REVERSEPROXY='none' - fi - - if [[ $BTCPAY_DOCKER_COMPOSE == *docker-compose.btc.yml ]]; then - BTCPAYGEN_CRYPTO1='btc' - BTCPAYGEN_LIGHTNING='none' - fi - if [[ $BTCPAY_DOCKER_COMPOSE == *docker-compose.btc-clightning.yml ]]; then - BTCPAYGEN_CRYPTO1='btc' - BTCPAYGEN_LIGHTNING='clightning' - fi - if [[ $BTCPAY_DOCKER_COMPOSE == *docker-compose.ltc.yml ]]; then - BTCPAYGEN_CRYPTO1='ltc' - BTCPAYGEN_LIGHTNING='none' - fi - if [[ $BTCPAY_DOCKER_COMPOSE == *docker-compose.ltc-clightning.yml ]]; then - BTCPAYGEN_CRYPTO1='ltc' - BTCPAYGEN_LIGHTNING='clightning' - fi - if [[ $BTCPAY_DOCKER_COMPOSE == *docker-compose.btc-ltc.yml ]]; then - BTCPAYGEN_CRYPTO1='btc' - BTCPAYGEN_CRYPTO2='ltc' - BTCPAYGEN_LIGHTNING='none' - fi - if [[ $BTCPAY_DOCKER_COMPOSE == *docker-compose.btc-ltc-clightning.yml ]]; then - BTCPAYGEN_CRYPTO1='btc' - BTCPAYGEN_CRYPTO2='ltc' - BTCPAYGEN_LIGHTNING='clightning' - fi + echo "Your deployment is too old, you need to migrate by following instructions on this link https://github.com/btcpayserver/btcpayserver-docker/tree/master#i-deployed-before-btcpay-setupsh-existed-before-may-17-can-i-migrate-to-this-new-system" + return fi ######################################################### @@ -208,6 +163,7 @@ fi # Put the variables in /etc/profile.d when a user log interactively touch "/etc/profile.d/btcpay-env.sh" echo " +export COMPOSE_HTTP_TIMEOUT=\"180\" export BTCPAYGEN_OLD_PREGEN=\"$BTCPAYGEN_OLD_PREGEN\" export BTCPAYGEN_CRYPTO1=\"$BTCPAYGEN_CRYPTO1\" export BTCPAYGEN_CRYPTO2=\"$BTCPAYGEN_CRYPTO2\" diff --git a/btcpay-update.sh b/btcpay-update.sh index 5b6819b..9aeb146 100755 --- a/btcpay-update.sh +++ b/btcpay-update.sh @@ -4,15 +4,28 @@ set -e . /etc/profile.d/btcpay-env.sh +if [ ! -z $BTCPAY_DOCKER_COMPOSE ] && [ ! -z $DOWNLOAD_ROOT ] && [ -z $BTCPAYGEN_OLD_PREGEN ]; then + echo "Your deployment is too old, you need to migrate by following instructions on this link https://github.com/btcpayserver/btcpayserver-docker/tree/master#i-deployed-before-btcpay-setupsh-existed-before-may-17-can-i-migrate-to-this-new-system" + exit +fi + +if [[ $BTCPAY_DOCKER_COMPOSE != *docker-compose.generated.yml ]]; then + echo "Your deployment is too old, you need to migrate by following instructions on this link https://github.com/btcpayserver/btcpayserver-docker/tree/master#i-deployed-before-btcpay-setupsh-existed-before-may-17-can-i-migrate-to-this-new-system" + exit +fi + cd "$BTCPAY_BASE_DIRECTORY/btcpayserver-docker" git pull --force -if [[ $BTCPAY_DOCKER_COMPOSE == *docker-compose.generated.yml ]]; then - # Generate the docker compose in BTCPAY_DOCKER_COMPOSE - . ./build.sh - if [ "$BTCPAYGEN_OLD_PREGEN" == "true" ]; then - cp Generated/docker-compose.generated.yml $BTCPAY_DOCKER_COMPOSE - fi +. ./build.sh +if [ "$BTCPAYGEN_OLD_PREGEN" == "true" ]; then + cp Generated/docker-compose.generated.yml $BTCPAY_DOCKER_COMPOSE +fi + +if ! grep -Fxq "export COMPOSE_HTTP_TIMEOUT=\"180\"" "/etc/profile.d/btcpay-env.sh"; then + echo "export COMPOSE_HTTP_TIMEOUT=\"180\"" >> /etc/profile.d/btcpay-env.sh + export COMPOSE_HTTP_TIMEOUT=180 + echo "Adding COMPOSE_HTTP_TIMEOUT=180 in btcpay-env.sh" fi for scriptname in *.sh; do diff --git a/build-pregen.ps1 b/build-pregen.ps1 deleted file mode 100755 index b8faf78..0000000 --- a/build-pregen.ps1 +++ /dev/null @@ -1,7 +0,0 @@ -# This script will run docker-compose-generator in a container to generate the yml files - -docker pull btcpayserver/docker-compose-generator -docker run -v "$(Get-Location)\Production:/app/Production" ` - -v "$(Get-Location)\Production-NoReverseProxy:/app/Production-NoReverseProxy" ` - -v "$(Get-Location)\docker-compose-generator\docker-fragments:/app/docker-fragments" ` - --rm btcpayserver/docker-compose-generator pregen \ No newline at end of file diff --git a/build-pregen.sh b/build-pregen.sh deleted file mode 100755 index 27fe54c..0000000 --- a/build-pregen.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -# This script will run docker-compose-generator in a container to generate the yml files -docker pull btcpayserver/docker-compose-generator -docker run -v "$(pwd)/Production:/app/Production" \ - -v "$(pwd)/Production-NoReverseProxy:/app/Production-NoReverseProxy" \ - -v "$(pwd)/docker-compose-generator/docker-fragments:/app/docker-fragments" \ - --rm btcpayserver/docker-compose-generator pregen diff --git a/build.ps1 b/build.ps1 index d02efbd..2bafc9e 100755 --- a/build.ps1 +++ b/build.ps1 @@ -1,7 +1,13 @@ # This script will run docker-compose-generator in a container to generate the yml files -if (-not ($BTCPAYGEN_DOCKER_IMAGE)) { $BTCPAYGEN_DOCKER_IMAGE = "btcpayserver/docker-compose-generator" } -docker pull $BTCPAYGEN_DOCKER_IMAGE: +If (-not ($BTCPAYGEN_DOCKER_IMAGE)) { $BTCPAYGEN_DOCKER_IMAGE = "btcpayserver/docker-compose-generator" } + +If ($BTCPAYGEN_DOCKER_IMAGE -eq "btcpayserver/docker-compose-generator:local"){ + docker build docker-compose-generator --tag $BTCPAYGEN_DOCKER_IMAGE +} Else { + docker pull $BTCPAYGEN_DOCKER_IMAGE +} + docker run -v "$(Get-Location)\Generated:/app/Generated" ` -v "$(Get-Location)\docker-compose-generator\docker-fragments:/app/docker-fragments" ` -e "BTCPAYGEN_CRYPTO1=$BTCPAYGEN_CRYPTO1" ` @@ -22,3 +28,9 @@ docker run -v "$(Get-Location)\Generated:/app/Generated" ` If ($BTCPAYGEN_REVERSEPROXY -eq "nginx") { Copy-Item ".\Production\nginx.tmpl" -Destination ".\Generated" } + +If ($BTCPAYGEN_REVERSEPROXY -eq "traefik") { + Copy-Item ".\Traefik\traefik.toml" -Destination ".\Generated" + + New-Item ".\Generated\acme.json" -type file +} diff --git a/build.sh b/build.sh index 7f82e69..09f9a4a 100755 --- a/build.sh +++ b/build.sh @@ -1,7 +1,14 @@ #!/bin/bash +: "${BTCPAYGEN_DOCKER_IMAGE:=btcpayserver/docker-compose-generator}" +if [ "$BTCPAYGEN_DOCKER_IMAGE" == "btcpayserver/docker-compose-generator:local" ] +then + docker build docker-compose-generator --tag $BTCPAYGEN_DOCKER_IMAGE +else + docker pull $BTCPAYGEN_DOCKER_IMAGE +fi + # This script will run docker-compose-generator in a container to generate the yml files -docker pull ${BTCPAYGEN_DOCKER_IMAGE:-"btcpayserver/docker-compose-generator"} docker run -v "$(pwd)/Generated:/app/Generated" \ -v "$(pwd)/docker-compose-generator/docker-fragments:/app/docker-fragments" \ -e "BTCPAYGEN_CRYPTO1=$BTCPAYGEN_CRYPTO1" \ @@ -17,8 +24,14 @@ docker run -v "$(pwd)/Generated:/app/Generated" \ -e "BTCPAYGEN_ADDITIONAL_FRAGMENTS=$BTCPAYGEN_ADDITIONAL_FRAGMENTS" \ -e "BTCPAYGEN_LIGHTNING=$BTCPAYGEN_LIGHTNING" \ -e "BTCPAYGEN_SUBNAME=$BTCPAYGEN_SUBNAME" \ - --rm ${BTCPAYGEN_DOCKER_IMAGE:-"btcpayserver/docker-compose-generator"} + --rm $BTCPAYGEN_DOCKER_IMAGE if [ "$BTCPAYGEN_REVERSEPROXY" == "nginx" ]; then cp Production/nginx.tmpl Generated/nginx.tmpl fi + +if [ "$BTCPAYGEN_REVERSEPROXY" == "traefik" ]; then + cp Traefik/traefik.toml Generated/traefik.toml + :> Generated/acme.json + chmod 600 Generated/acme.json +fi diff --git a/docker-compose-generator/Dockerfile b/docker-compose-generator/Dockerfile index 48fb91c..49e8be0 100644 --- a/docker-compose-generator/Dockerfile +++ b/docker-compose-generator/Dockerfile @@ -1,4 +1,4 @@ -FROM microsoft/dotnet:2.1.300-sdk-alpine3.7 AS builder +FROM microsoft/dotnet:2.1.403-sdk-alpine3.7 AS builder WORKDIR /source COPY src/docker-compose-generator.csproj docker-compose-generator.csproj # Cache some dependencies @@ -6,7 +6,7 @@ RUN dotnet restore COPY src/. . RUN dotnet publish --output /app/ --configuration Release -FROM microsoft/dotnet:2.1.0-runtime-alpine3.7 +FROM microsoft/dotnet:2.1.5-runtime-alpine3.7 WORKDIR /app RUN mkdir /datadir diff --git a/docker-compose-generator/docker-fragments/bitcoin-clightning.yml b/docker-compose-generator/docker-fragments/bitcoin-clightning.yml index 31403e7..05a3db6 100644 --- a/docker-compose-generator/docker-fragments/bitcoin-clightning.yml +++ b/docker-compose-generator/docker-fragments/bitcoin-clightning.yml @@ -2,7 +2,8 @@ version: "3" services: clightning_bitcoin: - image: nicolasdorier/clightning:634f19a7b230edc686be56ab950b80784e56252c + image: nicolasdorier/clightning:v0.6.2-3 + stop_signal: SIGKILL container_name: btcpayserver_clightning_bitcoin restart: unless-stopped environment: diff --git a/docker-compose-generator/docker-fragments/bitcoin-lnd.yml b/docker-compose-generator/docker-fragments/bitcoin-lnd.yml index b4eeedb..dc38442 100644 --- a/docker-compose-generator/docker-fragments/bitcoin-lnd.yml +++ b/docker-compose-generator/docker-fragments/bitcoin-lnd.yml @@ -2,7 +2,7 @@ version: "3" services: lnd_bitcoin: - image: btcpayserver/lnd:0.4.2.0.1 + image: btcpayserver/lnd:0.5-beta-2 container_name: btcpayserver_lnd_bitcoin restart: unless-stopped environment: @@ -15,10 +15,12 @@ services: rpclisten=0.0.0.0:10009 bitcoin.node=bitcoind bitcoind.rpchost=bitcoind:43782 - bitcoind.zmqpath=tcp://bitcoind:28332 + bitcoind.zmqpubrawblock=tcp://bitcoind:28332 + bitcoind.zmqpubrawtx=tcp://bitcoind:28333 externalip=${BTCPAY_HOST}:9735 alias=${LIGHTNING_ALIAS} - noencryptwallet=1 + adminmacaroonpath=/data/admin.macaroon + noseedbackup=1 notls=1 ports: - "9735:9735" @@ -37,6 +39,7 @@ services: environment: BTCPAY_BTCLIGHTNING: "type=lnd-rest;server=http://lnd_bitcoin:8080/;macaroonfilepath=/etc/lnd_bitcoin/admin.macaroon;allowinsecure=true" BTCPAY_BTCEXTERNALLNDGRPC: "type=lnd-grpc;server=${BTCPAY_PROTOCOL:-https}://${BTCPAY_HOST}/;macaroonfilepath=/etc/lnd_bitcoin/admin.macaroon" + BTCPAY_BTCEXTERNALLNDREST: "type=lnd-rest;server=${BTCPAY_PROTOCOL:-https}://${BTCPAY_HOST}/lnd-rest/btc/;macaroonfilepath=/etc/lnd_bitcoin/admin.macaroon" volumes: - "lnd_bitcoin_datadir:/etc/lnd_bitcoin" links: @@ -45,8 +48,8 @@ services: bitcoind: environment: BITCOIN_EXTRA_ARGS: | - zmqpubrawtx=tcp://0.0.0.0:28332 zmqpubrawblock=tcp://0.0.0.0:28332 + zmqpubrawtx=tcp://0.0.0.0:28333 expose: - "28332" - "28333" diff --git a/docker-compose-generator/docker-fragments/bitcoin.yml b/docker-compose-generator/docker-fragments/bitcoin.yml index f23221a..b41f881 100644 --- a/docker-compose-generator/docker-fragments/bitcoin.yml +++ b/docker-compose-generator/docker-fragments/bitcoin.yml @@ -4,11 +4,12 @@ services: bitcoind: restart: unless-stopped container_name: btcpayserver_bitcoind - image: nicolasdorier/docker-bitcoin:0.16.3 + image: nicolasdorier/docker-bitcoin:0.17.0 environment: + BITCOIN_NETWORK: ${NBITCOIN_NETWORK:-regtest} BITCOIN_EXTRA_ARGS: | + deprecatedrpc=signrawtransaction rpcport=43782 - ${NBITCOIN_NETWORK:-regtest}=1 port=39388 whitelist=0.0.0.0/0 expose: diff --git a/docker-compose-generator/docker-fragments/btcpayserver-nginx.yml b/docker-compose-generator/docker-fragments/btcpayserver-nginx.yml new file mode 100644 index 0000000..366353a --- /dev/null +++ b/docker-compose-generator/docker-fragments/btcpayserver-nginx.yml @@ -0,0 +1,15 @@ +version: "3" + +services: + + btcpayserver: + environment: + # NGINX settings + VIRTUAL_NETWORK: nginx-proxy + VIRTUAL_PORT: 49392 + VIRTUAL_HOST: ${BTCPAY_HOST} + SSL_POLICY: Mozilla-Modern + + # Let's encrypt settings + LETSENCRYPT_HOST: ${BTCPAY_HOST} + LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL:-} \ No newline at end of file diff --git a/docker-compose-generator/docker-fragments/btcpayserver.yml b/docker-compose-generator/docker-fragments/btcpayserver.yml index b1ffc14..b1eecb5 100644 --- a/docker-compose-generator/docker-fragments/btcpayserver.yml +++ b/docker-compose-generator/docker-fragments/btcpayserver.yml @@ -4,7 +4,7 @@ services: btcpayserver: restart: unless-stopped - image: nicolasdorier/btcpayserver:1.0.2.105 + image: nicolasdorier/btcpayserver:1.0.3.8 expose: - "49392" environment: @@ -16,17 +16,7 @@ services: BTCPAY_ROOTPATH: ${BTCPAY_ROOTPATH:-/} BTCPAY_SSHTRUSTEDFINGERPRINTS: ${BTCPAY_SSHTRUSTEDFINGERPRINTS} BTCPAY_SSHKEYFILE: ${BTCPAY_SSHKEYFILE} - - # NGINX settings - VIRTUAL_NETWORK: nginx-proxy - VIRTUAL_PORT: 49392 - VIRTUAL_HOST: ${BTCPAY_HOST} - SSL_POLICY: Mozilla-Modern - - # Let's encrypt settings - LETSENCRYPT_HOST: ${BTCPAY_HOST} - LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL:-} - + BTCPAY_DEBUGLOG: btcpay.log links: - nbxplorer - postgres @@ -34,24 +24,5 @@ services: - "btcpay_datadir:/datadir" - "nbxplorer_datadir:/root/.nbxplorer" - nbxplorer: - restart: unless-stopped - image: nicolasdorier/nbxplorer:1.0.2.31 - expose: - - "32838" - environment: - NBXPLORER_NETWORK: ${NBITCOIN_NETWORK:-regtest} - NBXPLORER_BIND: 0.0.0.0:32838 - volumes: - - "nbxplorer_datadir:/datadir" - - postgres: - restart: unless-stopped - image: postgres:9.6.5 - volumes: - - "postgres_datadir:/var/lib/postgresql/data" - volumes: - postgres_datadir: - btcpay_datadir: - nbxplorer_datadir: \ No newline at end of file + btcpay_datadir: \ No newline at end of file diff --git a/docker-compose-generator/docker-fragments/feathercoin.yml b/docker-compose-generator/docker-fragments/feathercoin.yml index 313cdb4..5d97802 100644 --- a/docker-compose-generator/docker-fragments/feathercoin.yml +++ b/docker-compose-generator/docker-fragments/feathercoin.yml @@ -4,7 +4,7 @@ services: feathercoind: restart: unless-stopped container_name: btcpayserver_feathercoind - image: chekaz/docker-feathercoin:0.16.0 + image: chekaz/docker-feathercoin:0.16.3 environment: BITCOIN_EXTRA_ARGS: | rpcport=43782 diff --git a/docker-compose-generator/docker-fragments/litecoin-clightning.yml b/docker-compose-generator/docker-fragments/litecoin-clightning.yml index 602a566..d5e70d8 100644 --- a/docker-compose-generator/docker-fragments/litecoin-clightning.yml +++ b/docker-compose-generator/docker-fragments/litecoin-clightning.yml @@ -2,7 +2,8 @@ version: "3" services: clightning_litecoin: - image: nicolasdorier/clightning:634f19a7b230edc686be56ab950b80784e56252c + image: nicolasdorier/clightning:v0.6.2-3 + stop_signal: SIGKILL container_name: btcpayserver_clightning_litecoin restart: unless-stopped environment: diff --git a/docker-compose-generator/docker-fragments/litecoin-lnd.yml b/docker-compose-generator/docker-fragments/litecoin-lnd.yml index be9ba0e..ced78bd 100644 --- a/docker-compose-generator/docker-fragments/litecoin-lnd.yml +++ b/docker-compose-generator/docker-fragments/litecoin-lnd.yml @@ -2,7 +2,7 @@ version: "3" services: lnd_litecoin: - image: btcpayserver/lnd:0.4.2.0.1 + image: btcpayserver/lnd:0.5-beta-2 container_name: btcpayserver_lnd_litecoin restart: unless-stopped environment: @@ -13,10 +13,12 @@ services: restlisten=0.0.0.0:8080 litecoin.node=litecoind litecoind.rpchost=litecoind:43782 - litecoind.zmqpath=tcp://litecoind:28332 + litecoind.zmqpubrawblock=tcp://litecoind:28332 + litecoind.zmqpubrawtx=tcp://litecoind:28333 externalip=${BTCPAY_HOST}:9736 alias=${LIGHTNING_ALIAS} - noencryptwallet=1 + adminmacaroonpath=/data/admin.macaroon + noseedbackup=1 notls=1 ports: - "9736:9735" @@ -42,10 +44,11 @@ services: litecoind: environment: BITCOIN_EXTRA_ARGS: | - zmqpubrawtx=tcp://0.0.0.0:28332 zmqpubrawblock=tcp://0.0.0.0:28332 + zmqpubrawtx=tcp://0.0.0.0:28333 expose: - "28332" + - "28333" volumes: lnd_litecoin_datadir: \ No newline at end of file diff --git a/docker-compose-generator/docker-fragments/nbxplorer.yml b/docker-compose-generator/docker-fragments/nbxplorer.yml new file mode 100644 index 0000000..3ab7dd8 --- /dev/null +++ b/docker-compose-generator/docker-fragments/nbxplorer.yml @@ -0,0 +1,17 @@ +version: "3" + +services: + + nbxplorer: + restart: unless-stopped + image: nicolasdorier/nbxplorer:1.1.0.12 + expose: + - "32838" + environment: + NBXPLORER_NETWORK: ${NBITCOIN_NETWORK:-regtest} + NBXPLORER_BIND: 0.0.0.0:32838 + volumes: + - "nbxplorer_datadir:/datadir" + +volumes: + nbxplorer_datadir: \ No newline at end of file diff --git a/docker-compose-generator/docker-fragments/opt-lnd-autopilot.yml b/docker-compose-generator/docker-fragments/opt-lnd-autopilot.yml index aff861e..98f9e6b 100644 --- a/docker-compose-generator/docker-fragments/opt-lnd-autopilot.yml +++ b/docker-compose-generator/docker-fragments/opt-lnd-autopilot.yml @@ -7,3 +7,15 @@ services: autopilot.active=1 autopilot.maxchannels=5 autopilot.allocation=0.6 + lnd_litecoin: + environment: + LND_EXTRA_ARGS: | + autopilot.active=1 + autopilot.maxchannels=5 + autopilot.allocation=0.6 + lnd_bitcoingold: + environment: + LND_EXTRA_ARGS: | + autopilot.active=1 + autopilot.maxchannels=5 + autopilot.allocation=0.6 diff --git a/docker-compose-generator/docker-fragments/opt-save-storage-s.yml b/docker-compose-generator/docker-fragments/opt-save-storage-s.yml index 11177d2..e134222 100644 --- a/docker-compose-generator/docker-fragments/opt-save-storage-s.yml +++ b/docker-compose-generator/docker-fragments/opt-save-storage-s.yml @@ -1,8 +1,23 @@ version: "3" +# If you don't use Lightning Network, use opt-save-store-xxs instead +# This save about 6 months of block, your lightning node won't be able to see channel created 6 months since the time you start it. services: bitcoind: environment: - # If you don't use Lightning Network, use opt-save-store-xxs instead - # This save about 6 months of block, your lightning node won't be able to see channel created 6 months since the time you start it. + BITCOIN_EXTRA_ARGS: prune=50000 + bgoldd: + environment: + BITCOIN_EXTRA_ARGS: prune=50000 + feathercoind: + environment: + BITCOIN_EXTRA_ARGS: prune=50000 + groestlcoind: + environment: + BITCOIN_EXTRA_ARGS: prune=50000 + litecoind: + environment: + BITCOIN_EXTRA_ARGS: prune=50000 + viacoind: + environment: BITCOIN_EXTRA_ARGS: prune=50000 \ No newline at end of file diff --git a/docker-compose-generator/docker-fragments/opt-save-storage-xs.yml b/docker-compose-generator/docker-fragments/opt-save-storage-xs.yml index a089417..8e32c8f 100644 --- a/docker-compose-generator/docker-fragments/opt-save-storage-xs.yml +++ b/docker-compose-generator/docker-fragments/opt-save-storage-xs.yml @@ -1,8 +1,23 @@ version: "3" +# If you don't use Lightning Network, use opt-save-store-xxs instead +# This save about 3 months of block, your lightning node won't be able to see channel created 3 months since the time you start it. services: bitcoind: environment: - # If you don't use Lightning Network, use opt-save-store-xxs instead - # This save about 3 months of block, your lightning node won't be able to see channel created 3 months since the time you start it. + BITCOIN_EXTRA_ARGS: prune=25000 + bgoldd: + environment: + BITCOIN_EXTRA_ARGS: prune=25000 + feathercoind: + environment: + BITCOIN_EXTRA_ARGS: prune=25000 + groestlcoind: + environment: + BITCOIN_EXTRA_ARGS: prune=25000 + litecoind: + environment: + BITCOIN_EXTRA_ARGS: prune=25000 + viacoind: + environment: BITCOIN_EXTRA_ARGS: prune=25000 \ No newline at end of file diff --git a/docker-compose-generator/docker-fragments/opt-save-storage-xxs.yml b/docker-compose-generator/docker-fragments/opt-save-storage-xxs.yml index 22fd776..6ad1d81 100644 --- a/docker-compose-generator/docker-fragments/opt-save-storage-xxs.yml +++ b/docker-compose-generator/docker-fragments/opt-save-storage-xxs.yml @@ -1,8 +1,23 @@ version: "3" +# If you don't use Lightning Network, you want this +# This save about 2 weeks worth of block services: bitcoind: environment: - # If you don't use Lightning Network, you want this - # This save about 2 weeks worth of block + BITCOIN_EXTRA_ARGS: prune=5000 + bgoldd: + environment: + BITCOIN_EXTRA_ARGS: prune=5000 + feathercoind: + environment: + BITCOIN_EXTRA_ARGS: prune=5000 + groestlcoind: + environment: + BITCOIN_EXTRA_ARGS: prune=5000 + litecoind: + environment: + BITCOIN_EXTRA_ARGS: prune=5000 + viacoind: + environment: BITCOIN_EXTRA_ARGS: prune=5000 \ No newline at end of file diff --git a/docker-compose-generator/docker-fragments/opt-save-storage.yml b/docker-compose-generator/docker-fragments/opt-save-storage.yml index 103a3e6..9e440cd 100644 --- a/docker-compose-generator/docker-fragments/opt-save-storage.yml +++ b/docker-compose-generator/docker-fragments/opt-save-storage.yml @@ -1,8 +1,23 @@ version: "3" +# If you don't use Lightning Network, use opt-save-store-xxs instead +# This save about 1 years of block, your lightning node won't be able to see channel created 1 year since the time you start it. services: bitcoind: environment: - # If you don't use Lightning Network, use opt-save-store-xxs instead - # This save about 1 years of block, your lightning node won't be able to see channel created 1 year since the time you start it. + BITCOIN_EXTRA_ARGS: prune=100000 + bgoldd: + environment: + BITCOIN_EXTRA_ARGS: prune=100000 + feathercoind: + environment: + BITCOIN_EXTRA_ARGS: prune=100000 + groestlcoind: + environment: + BITCOIN_EXTRA_ARGS: prune=100000 + litecoind: + environment: + BITCOIN_EXTRA_ARGS: prune=100000 + viacoind: + environment: BITCOIN_EXTRA_ARGS: prune=100000 \ No newline at end of file diff --git a/docker-compose-generator/docker-fragments/postgres.yml b/docker-compose-generator/docker-fragments/postgres.yml new file mode 100644 index 0000000..d558564 --- /dev/null +++ b/docker-compose-generator/docker-fragments/postgres.yml @@ -0,0 +1,11 @@ +version: "3" + +services: + postgres: + restart: unless-stopped + image: postgres:9.6.5 + volumes: + - "postgres_datadir:/var/lib/postgresql/data" + +volumes: + postgres_datadir: \ No newline at end of file diff --git a/docker-compose-generator/docker-fragments/traefik-labels.yml b/docker-compose-generator/docker-fragments/traefik-labels.yml new file mode 100644 index 0000000..e361858 --- /dev/null +++ b/docker-compose-generator/docker-fragments/traefik-labels.yml @@ -0,0 +1,12 @@ +version: "3" + +services: + btcpayserver: + labels: + - "traefik.backend=btcpayserver" + - "traefik.backend.loadbalancer.sticky=true" + - "traefik.enable=true" + - "traefik.frontend.rule=Host:${BTCPAY_HOST}" + - "traefik.port.rule=49392" + - "traefik.acme.domains=${BTCPAY_HOST},www.${BTCPAY_HOST}" + - "traefik.acme.email=${LETSENCRYPT_EMAIL}" diff --git a/docker-compose-generator/docker-fragments/traefik.yml b/docker-compose-generator/docker-fragments/traefik.yml new file mode 100644 index 0000000..a42dadf --- /dev/null +++ b/docker-compose-generator/docker-fragments/traefik.yml @@ -0,0 +1,22 @@ +version: "3" + +services: + traefik: + restart: unless-stopped + image: traefik + container_name: traefik + ports: + - "80:80" + - "443:443" + volumes: + - "/var/run/docker.sock:/var/run/docker.sock" + - "./traefik.toml:/traefik.toml" + - "./acme.json:/acme.json:ro" + - "./servers.toml:/servers.toml" + - "./traefik_logs:/traefik_logs" + + links: + - btcpayserver + +volumes: + traefik_logs: \ No newline at end of file diff --git a/docker-compose-generator/docker-fragments/viacoin.yml b/docker-compose-generator/docker-fragments/viacoin.yml index ef3daa9..ac03f79 100644 --- a/docker-compose-generator/docker-fragments/viacoin.yml +++ b/docker-compose-generator/docker-fragments/viacoin.yml @@ -4,7 +4,7 @@ services: viacoind: restart: unless-stopped container_name: btcpayserver_viacoind - image: romanornr/docker-viacoin:0.15.1 + image: romanornr/docker-viacoin:0.15.2 environment: BITCOIN_EXTRA_ARGS: | rpcport=43782 diff --git a/docker-compose-generator/src/DockerComposeDefinition.cs b/docker-compose-generator/src/DockerComposeDefinition.cs index def8cf9..3e8ad95 100644 --- a/docker-compose-generator/src/DockerComposeDefinition.cs +++ b/docker-compose-generator/src/DockerComposeDefinition.cs @@ -8,146 +8,160 @@ using System.IO; namespace DockerGenerator { - public class DockerComposeDefinition - { - public List Fragments - { - get; set; - } - private string _Name; + public class DockerComposeDefinition + { + public List Fragments + { + get; set; + } + private string _Name; - public DockerComposeDefinition(string name, List fragments) - { - Fragments = fragments; - _Name = name; - } + public DockerComposeDefinition(string name, List fragments) + { + Fragments = fragments; + _Name = name; + } - public string FragmentLocation - { - get; set; - } - public string BuildOutputDirectory - { - get; set; - } + public string FragmentLocation + { + get; set; + } + public string BuildOutputDirectory + { + get; set; + } - public string GetFilePath() - { - return Path.Combine(BuildOutputDirectory, $"docker-compose.{_Name}.yml"); - } - public void Build() - { - Console.WriteLine($"Generating {GetFilePath()}"); - var deserializer = new DeserializerBuilder().Build(); - var serializer = new SerializerBuilder().Build(); + public string GetFilePath() + { + return Path.Combine(BuildOutputDirectory, $"docker-compose.{_Name}.yml"); + } + public void Build() + { + Console.WriteLine($"Generating {GetFilePath()}"); + var deserializer = new DeserializerBuilder().Build(); + var serializer = new SerializerBuilder().Build(); - Console.WriteLine($"With fragments:"); - foreach(var fragment in Fragments) - { - Console.WriteLine($"\t{fragment}"); - } - var services = new List>(); - var volumes = new List>(); + Console.WriteLine($"With fragments:"); + foreach (var fragment in Fragments.ToList()) + { + var fragmentPath = GetFragmentLocation(fragment); + if (!File.Exists(fragmentPath)) + { + Console.WriteLine($"\t{fragment} not found in {fragmentPath}, ignoring..."); + Fragments.Remove(fragment); + } + else + { + Console.WriteLine($"\t{fragment}"); + } + } + var services = new List>(); + var volumes = new List>(); - foreach(var doc in Fragments.Select(f => ParseDocument(f))) - { - if(doc.Children.ContainsKey("services") && doc.Children["services"] is YamlMappingNode fragmentServicesRoot) - { - services.AddRange(fragmentServicesRoot.Children); - } + foreach (var doc in Fragments.Select(f => ParseDocument(f))) + { + if (doc.Children.ContainsKey("services") && doc.Children["services"] is YamlMappingNode fragmentServicesRoot) + { + services.AddRange(fragmentServicesRoot.Children); + } - if(doc.Children.ContainsKey("volumes") && doc.Children["volumes"] is YamlMappingNode fragmentVolumesRoot) - { - volumes.AddRange(fragmentVolumesRoot.Children); - } - } + if (doc.Children.ContainsKey("volumes") && doc.Children["volumes"] is YamlMappingNode fragmentVolumesRoot) + { + volumes.AddRange(fragmentVolumesRoot.Children); + } + } - YamlMappingNode output = new YamlMappingNode(); - output.Add("version", new YamlScalarNode("3") { Style = YamlDotNet.Core.ScalarStyle.DoubleQuoted }); - output.Add("services", new YamlMappingNode(Merge(services))); - output.Add("volumes", new YamlMappingNode(volumes)); - var result = serializer.Serialize(output); - var outputFile = GetFilePath(); - File.WriteAllText(outputFile, result.Replace("''", "")); - Console.WriteLine($"Generated {outputFile}"); - Console.WriteLine(); - } + YamlMappingNode output = new YamlMappingNode(); + output.Add("version", new YamlScalarNode("3") { Style = YamlDotNet.Core.ScalarStyle.DoubleQuoted }); + output.Add("services", new YamlMappingNode(Merge(services))); + output.Add("volumes", new YamlMappingNode(volumes)); + var result = serializer.Serialize(output); + var outputFile = GetFilePath(); + File.WriteAllText(outputFile, result.Replace("''", "")); + Console.WriteLine($"Generated {outputFile}"); + Console.WriteLine(); + } - private KeyValuePair[] Merge(List> services) - { - return services - .GroupBy(s => s.Key.ToString(), s => s.Value) - .Select(group => - (GroupName: group.Key, - MainNode: group.OfType().SingleOrDefault(n => n.Children.ContainsKey("image")), - MergedNodes: group.OfType().Where(n => !n.Children.ContainsKey("image")))) - .Where(_ => _.MainNode != null) - .Select(_ => - { - foreach(var node in _.MergedNodes) - { - foreach(var child in node) - { - var childValue = child.Value; - if(!_.MainNode.Children.TryGetValue(child.Key, out var mainChildValue)) - { - mainChildValue = child.Value; - _.MainNode.Add(child.Key, child.Value); - } - else if(childValue is YamlMappingNode childMapping && mainChildValue is YamlMappingNode mainChildMapping) - { - foreach(var leaf in childMapping) - { - if(mainChildMapping.Children.TryGetValue(leaf.Key, out var mainLeaf)) - { - if(leaf.Value is YamlScalarNode leafScalar && mainLeaf is YamlScalarNode leafMainScalar) - { - var eof = EOF(leafMainScalar.Value) ?? EOF(leaf.Value.ToString()); - if(eof != null) - { - leafMainScalar.Value = leafMainScalar.Value + eof + leaf.Value; - } - else - { - leafMainScalar.Value = leafMainScalar.Value + "," + leaf.Value; - } - } - } - else - { - mainChildMapping.Add(leaf.Key, leaf.Value); - } - } - } - else if(childValue is YamlSequenceNode childSequence && mainChildValue is YamlSequenceNode mainSequence) - { - foreach(var c in childSequence.Children) - { - mainSequence.Add(c); - } - } - } - } - return new KeyValuePair(_.GroupName, _.MainNode); - }).ToArray(); - } + private KeyValuePair[] Merge(List> services) + { + return services + .GroupBy(s => s.Key.ToString(), s => s.Value) + .Select(group => + (GroupName: group.Key, + MainNode: group.OfType().SingleOrDefault(n => n.Children.ContainsKey("image")), + MergedNodes: group.OfType().Where(n => !n.Children.ContainsKey("image")))) + .Where(_ => _.MainNode != null) + .Select(_ => + { + foreach (var node in _.MergedNodes) + { + foreach (var child in node) + { + var childValue = child.Value; + if (!_.MainNode.Children.TryGetValue(child.Key, out var mainChildValue)) + { + mainChildValue = child.Value; + _.MainNode.Add(child.Key, child.Value); + } + else if (childValue is YamlMappingNode childMapping && mainChildValue is YamlMappingNode mainChildMapping) + { + foreach (var leaf in childMapping) + { + if (mainChildMapping.Children.TryGetValue(leaf.Key, out var mainLeaf)) + { + if (leaf.Value is YamlScalarNode leafScalar && mainLeaf is YamlScalarNode leafMainScalar) + { + var eof = EOF(leafMainScalar.Value) ?? EOF(leaf.Value.ToString()); + if (eof != null) + { + leafMainScalar.Value = leafMainScalar.Value + eof + leaf.Value; + } + else + { + leafMainScalar.Value = leafMainScalar.Value + "," + leaf.Value; + } + } + } + else + { + mainChildMapping.Add(leaf.Key, leaf.Value); + } + } + } + else if (childValue is YamlSequenceNode childSequence && mainChildValue is YamlSequenceNode mainSequence) + { + foreach (var c in childSequence.Children) + { + mainSequence.Add(c); + } + } + } + } + return new KeyValuePair(_.GroupName, _.MainNode); + }).ToArray(); + } - private string EOF(string value) - { - if(value.Contains("\r\n", StringComparison.OrdinalIgnoreCase)) - return "\r\n"; - if(value.Contains("\n", StringComparison.OrdinalIgnoreCase)) - return "\n"; - return null; - } + private string EOF(string value) + { + if (value.Contains("\r\n", StringComparison.OrdinalIgnoreCase)) + return "\r\n"; + if (value.Contains("\n", StringComparison.OrdinalIgnoreCase)) + return "\n"; + return null; + } - private YamlMappingNode ParseDocument(string fragment) - { - var input = new StringReader(File.ReadAllText(Path.Combine(FragmentLocation, $"{fragment}.yml"))); - YamlStream stream = new YamlStream(); - stream.Load(input); - return (YamlMappingNode)stream.Documents[0].RootNode; - } - } + private YamlMappingNode ParseDocument(string fragment) + { + var input = new StringReader(File.ReadAllText(GetFragmentLocation(fragment))); + YamlStream stream = new YamlStream(); + stream.Load(input); + return (YamlMappingNode)stream.Documents[0].RootNode; + } + + private string GetFragmentLocation(string fragment) + { + return Path.Combine(FragmentLocation, $"{fragment}.yml"); + } + } } diff --git a/docker-compose-generator/src/Program.cs b/docker-compose-generator/src/Program.cs index 9d0d293..e30d5fe 100644 --- a/docker-compose-generator/src/Program.cs +++ b/docker-compose-generator/src/Program.cs @@ -14,50 +14,15 @@ namespace DockerGenerator var root = Environment.GetEnvironmentVariable("INSIDE_CONTAINER") == "1" ? FindRoot("app") : Path.GetFullPath(Path.Combine(FindRoot("docker-compose-generator"), "..")); - if(args.Any(a => a == "pregen")) - { - var productionLocation = Path.GetFullPath(Path.Combine(root, "Production")); - var testLocation = Path.GetFullPath(Path.Combine(root, "Production-NoReverseProxy")); + var composition = DockerComposition.FromEnvironmentVariables(); + Console.WriteLine("Crypto: " + string.Join(", ", composition.SelectedCryptos.ToArray())); + Console.WriteLine("Lightning: " + composition.SelectedLN); + Console.WriteLine("ReverseProxy: " + composition.SelectedProxy); + var generatedLocation = Path.GetFullPath(Path.Combine(root, "Generated")); - foreach(var proxy in new[] { "nginx", "no-reverseproxy" }) - { - foreach(var lightning in new[] { "clightning", "" }) - { - foreach(var btc in new[] { "btc", "" }) - { - foreach(var ltc in new[] { "ltc", "" }) - { - if(btc == "" && ltc == "") - continue; - string name = $"{btc}-{ltc}-{lightning}".Replace("--", "-"); - if(name.EndsWith("-")) - name = name.Substring(0, name.Length - 1); - if(name.StartsWith("-")) - name = name.Substring(1, name.Length - 1); - var composition = new DockerComposition(); - composition.SelectedCryptos = new HashSet(); - composition.SelectedCryptos.Add(btc); - composition.SelectedCryptos.Add(ltc); - composition.SelectedLN = lightning; - composition.SelectedProxy = proxy; - new Program().Run(composition, name, proxy == "nginx" ? productionLocation : testLocation); - } - } - } - } - } - else - { - var composition = DockerComposition.FromEnvironmentVariables(); - Console.WriteLine("Crypto: " + string.Join(", ", composition.SelectedCryptos.ToArray())); - Console.WriteLine("Lightning: " + composition.SelectedLN); - Console.WriteLine("ReverseProxy: " + composition.SelectedProxy); - var generatedLocation = Path.GetFullPath(Path.Combine(root, "Generated")); - - var name = Environment.GetEnvironmentVariable("BTCPAYGEN_SUBNAME"); - name = string.IsNullOrEmpty(name) ? "generated" : name; - new Program().Run(composition, name, generatedLocation); - } + var name = Environment.GetEnvironmentVariable("BTCPAYGEN_SUBNAME"); + name = string.IsNullOrEmpty(name) ? "generated" : name; + new Program().Run(composition, name, generatedLocation); } private void Run(DockerComposition composition, string name, string output) @@ -67,35 +32,44 @@ namespace DockerGenerator fragmentLocation = Path.GetFullPath(Path.Combine(fragmentLocation, "docker-fragments")); var fragments = new List(); - if(composition.SelectedProxy == "nginx") + switch (composition.SelectedProxy) { - fragments.Add("nginx"); - } - else - { - fragments.Add("btcpayserver-noreverseproxy"); + case "nginx": + + fragments.Add("nginx"); + fragments.Add("btcpayserver-nginx"); + break; + case "traefik": + fragments.Add("traefik"); + fragments.Add("traefik-labels"); + break; + case "no-reverseproxy": + fragments.Add("btcpayserver-noreverseproxy"); + break; } fragments.Add("btcpayserver"); - foreach(var crypto in CryptoDefinition.GetDefinitions()) + fragments.Add("nbxplorer"); + fragments.Add("postgres"); + foreach (var crypto in CryptoDefinition.GetDefinitions()) { - if(!composition.SelectedCryptos.Contains(crypto.Crypto)) + if (!composition.SelectedCryptos.Contains(crypto.Crypto)) continue; fragments.Add(crypto.CryptoFragment); - if(composition.SelectedLN == "clightning" && crypto.CLightningFragment != null) + if (composition.SelectedLN == "clightning" && crypto.CLightningFragment != null) { fragments.Add(crypto.CLightningFragment); } - if(composition.SelectedLN == "lnd" && crypto.LNDFragment != null) - { - fragments.Add(crypto.LNDFragment); - } - } + if (composition.SelectedLN == "lnd" && crypto.LNDFragment != null) + { + fragments.Add(crypto.LNDFragment); + } + } - foreach(var fragment in composition.AdditionalFragments) - { - fragments.Add(fragment.Trim()); - } + foreach (var fragment in composition.AdditionalFragments) + { + fragments.Add(fragment.Trim()); + } var def = new DockerComposeDefinition(name, fragments); def.FragmentLocation = fragmentLocation; @@ -107,11 +81,11 @@ namespace DockerGenerator { string directory = Directory.GetCurrentDirectory(); int i = 0; - while(true) + while (true) { - if(i > 10) + if (i > 10) throw new DirectoryNotFoundException(rootDirectory); - if(directory.EndsWith(rootDirectory)) + if (directory.EndsWith(rootDirectory)) return directory; directory = Path.GetFullPath(Path.Combine(directory, "..")); i++; diff --git a/docker-compose-generator/src/docker-compose-generator.csproj b/docker-compose-generator/src/docker-compose-generator.csproj index ba248d8..2ecf0a4 100644 --- a/docker-compose-generator/src/docker-compose-generator.csproj +++ b/docker-compose-generator/src/docker-compose-generator.csproj @@ -7,7 +7,6 @@ - + - diff --git a/litecoin-lncli.ps1 b/litecoin-lncli.ps1 index 5eea0cc..e286ac9 100755 --- a/litecoin-lncli.ps1 +++ b/litecoin-lncli.ps1 @@ -1 +1 @@ -docker exec -ti btcpayserver_lnd_litecoin lncli $args +docker exec -ti btcpayserver_lnd_litecoin lncli --macaroonpath /root/.lnd/admin.macaroon $args diff --git a/litecoin-lncli.sh b/litecoin-lncli.sh index c2bb713..5178674 100755 --- a/litecoin-lncli.sh +++ b/litecoin-lncli.sh @@ -1,3 +1,3 @@ #!/bin/bash -docker exec -ti btcpayserver_lnd_litecoin lncli "$@" +docker exec -ti btcpayserver_lnd_litecoin lncli --macaroonpath /root/.lnd/admin.macaroon "$@"