mirror of
https://github.com/aljazceru/btcpayserver-docker.git
synced 2025-12-18 20:14:21 +01:00
Generate docker-compose for integrated clightning
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
clightning_bitcoin:
|
||||
image: nicolasdorier/clightning
|
||||
environment:
|
||||
LIGHTNINGD_OPT: |
|
||||
bitcoin-datadir=/etc/bitcoin
|
||||
bitcoin-rpcconnect=bitcoind
|
||||
ipaddr=${BTCPAY_HOST}
|
||||
network=${NBITCOIN_NETWORK:-regtest}
|
||||
chain=btc
|
||||
volumes:
|
||||
- "clightning_bitcoin_datadir:/root/.lightning"
|
||||
- "bitcoin_datadir:/etc/bitcoin"
|
||||
links:
|
||||
- bitcoind
|
||||
btcpayserver:
|
||||
environment:
|
||||
BTCPAY_BTCLIGHTNING: "/etc/clightning_bitcoin/lightning-rpc"
|
||||
volumes:
|
||||
- "clightning_bitcoin_datadir:/etc/clightning_bitcoin"
|
||||
links:
|
||||
- clightning_bitcoin
|
||||
volumes:
|
||||
clightning_bitcoin_datadir:
|
||||
@@ -0,0 +1,26 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
clightning_litecoin:
|
||||
image: nicolasdorier/clightning
|
||||
environment:
|
||||
LIGHTNINGD_OPT: |
|
||||
bitcoin-datadir=/etc/litecoin
|
||||
bitcoin-rpcconnect=litecoind
|
||||
ipaddr=${BTCPAY_HOST}
|
||||
network=${NBITCOIN_NETWORK:-regtest}
|
||||
chain=ltc
|
||||
volumes:
|
||||
- "clightning_litecoin_datadir:/root/.lightning"
|
||||
- "litecoin_datadir:/etc/litecoin"
|
||||
links:
|
||||
- litecoind
|
||||
btcpayserver:
|
||||
environment:
|
||||
BTCPAY_LTCLIGHTNING: "/etc/clightning_litecoin/lightning-rpc"
|
||||
volumes:
|
||||
- "clightning_litecoin_datadir:/etc/clightning_litecoin"
|
||||
links:
|
||||
- clightning_litecoin
|
||||
volumes:
|
||||
clightning_litecoin_datadir:
|
||||
@@ -1,37 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace DockerGenerator
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
new Program().Run();
|
||||
}
|
||||
|
||||
private void Run()
|
||||
{
|
||||
List<DockerComposeDefinition> defs = new List<DockerComposeDefinition>();
|
||||
defs.Add(new DockerComposeDefinition("btc",
|
||||
new List<string> { "nginx", "btcpayserver", "bitcoin" }));
|
||||
defs.Add(new DockerComposeDefinition("btc-ltc",
|
||||
new List<string> { "nginx", "btcpayserver", "bitcoin", "litecoin" }));
|
||||
|
||||
var fragmentLocation = FindLocation("docker-fragments");
|
||||
var productionLocation = FindLocation("Production");
|
||||
foreach(var def in defs)
|
||||
var testLocation = FindLocation("Production-NoReverseProxy");
|
||||
|
||||
HashSet<string> processed = new HashSet<string>();
|
||||
foreach(var permutation in ItemCombinations(new[] { "btc", "ltc", "clightning" }.ToList()))
|
||||
{
|
||||
if(permutation.Count == 1 && permutation.First() == "clightning")
|
||||
continue;
|
||||
permutation.Sort();
|
||||
if(permutation.Remove("clightning"))
|
||||
permutation.Add("clightning"); // ensure clightning at the end
|
||||
string id = string.Join('-', permutation);
|
||||
if(!processed.Add(id))
|
||||
continue;
|
||||
|
||||
var fragments = new List<string>();
|
||||
fragments.Add("nginx");
|
||||
fragments.Add("btcpayserver");
|
||||
|
||||
if(permutation.Contains("ltc"))
|
||||
{
|
||||
fragments.Add("litecoin");
|
||||
if(permutation.Contains("clightning"))
|
||||
fragments.Add("litecoin-clightning");
|
||||
}
|
||||
if(permutation.Contains("btc"))
|
||||
{
|
||||
fragments.Add("bitcoin");
|
||||
if(permutation.Contains("clightning"))
|
||||
fragments.Add("bitcoin-clightning");
|
||||
}
|
||||
|
||||
var def = new DockerComposeDefinition(id, fragments);
|
||||
def.FragmentLocation = fragmentLocation;
|
||||
def.BuildOutputDirectory = productionLocation;
|
||||
def.Build();
|
||||
}
|
||||
|
||||
var testLocation = FindLocation("Production-NoReverseProxy");
|
||||
foreach(var def in defs)
|
||||
{
|
||||
|
||||
def.Fragments.Remove("nginx");
|
||||
def.Fragments.Add("btcpayserver-noreverseproxy");
|
||||
def.BuildOutputDirectory = testLocation;
|
||||
@@ -39,6 +61,44 @@ namespace DockerGenerator
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to create lists containing possible combinations of an input list of items. This is
|
||||
/// basically copied from code by user "jaolho" on this thread:
|
||||
/// http://stackoverflow.com/questions/7802822/all-possible-combinations-of-a-list-of-values
|
||||
/// </summary>
|
||||
/// <typeparam name="T">type of the items on the input list</typeparam>
|
||||
/// <param name="inputList">list of items</param>
|
||||
/// <param name="minimumItems">minimum number of items wanted in the generated combinations,
|
||||
/// if zero the empty combination is included,
|
||||
/// default is one</param>
|
||||
/// <param name="maximumItems">maximum number of items wanted in the generated combinations,
|
||||
/// default is no maximum limit</param>
|
||||
/// <returns>list of lists for possible combinations of the input items</returns>
|
||||
public static List<List<T>> ItemCombinations<T>(List<T> inputList, int minimumItems = 1,
|
||||
int maximumItems = int.MaxValue)
|
||||
{
|
||||
int nonEmptyCombinations = (int)Math.Pow(2, inputList.Count) - 1;
|
||||
List<List<T>> listOfLists = new List<List<T>>(nonEmptyCombinations + 1);
|
||||
|
||||
if(minimumItems == 0) // Optimize default case
|
||||
listOfLists.Add(new List<T>());
|
||||
|
||||
for(int i = 1; i <= nonEmptyCombinations; i++)
|
||||
{
|
||||
List<T> thisCombination = new List<T>(inputList.Count);
|
||||
for(int j = 0; j < inputList.Count; j++)
|
||||
{
|
||||
if((i >> j & 1) == 1)
|
||||
thisCombination.Add(inputList[j]);
|
||||
}
|
||||
|
||||
if(thisCombination.Count >= minimumItems && thisCombination.Count <= maximumItems)
|
||||
listOfLists.Add(thisCombination);
|
||||
}
|
||||
|
||||
return listOfLists;
|
||||
}
|
||||
|
||||
private string FindLocation(string path)
|
||||
{
|
||||
while(true)
|
||||
|
||||
Reference in New Issue
Block a user