mirror of
https://github.com/aljazceru/btcpayserver-docker.git
synced 2025-12-19 01:54:22 +01:00
Remove legacy docker-compose.yml, auto generate the Test docker-compose
This commit is contained in:
@@ -10,12 +10,15 @@ namespace DockerGenerator
|
||||
{
|
||||
public class DockerComposeDefinition
|
||||
{
|
||||
string[] _Fragments;
|
||||
public List<string> Fragments
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
private string _Name;
|
||||
|
||||
public DockerComposeDefinition(string name, string[] fragments)
|
||||
public DockerComposeDefinition(string name, List<string> fragments)
|
||||
{
|
||||
_Fragments = fragments;
|
||||
Fragments = fragments;
|
||||
_Name = name;
|
||||
}
|
||||
|
||||
@@ -39,21 +42,21 @@ namespace DockerGenerator
|
||||
var serializer = new SerializerBuilder().Build();
|
||||
|
||||
Console.WriteLine($"With fragments:");
|
||||
foreach(var fragment in _Fragments)
|
||||
foreach(var fragment in Fragments)
|
||||
{
|
||||
Console.WriteLine($"\t{fragment}");
|
||||
}
|
||||
var services = new List<KeyValuePair<YamlNode, YamlNode>>();
|
||||
var volumes = new List<KeyValuePair<YamlNode, YamlNode>>();
|
||||
|
||||
foreach(var doc in _Fragments.Select(f => ParseDocument(f)))
|
||||
foreach(var doc in Fragments.Select(f => ParseDocument(f)))
|
||||
{
|
||||
if(doc.Children["services"] is YamlMappingNode fragmentServicesRoot)
|
||||
if(doc.Children.ContainsKey("services") && doc.Children["services"] is YamlMappingNode fragmentServicesRoot)
|
||||
{
|
||||
services.AddRange(fragmentServicesRoot.Children);
|
||||
}
|
||||
|
||||
if(doc.Children["volumes"] is YamlMappingNode fragmentVolumesRoot)
|
||||
if(doc.Children.ContainsKey("volumes") && doc.Children["volumes"] is YamlMappingNode fragmentVolumesRoot)
|
||||
{
|
||||
volumes.AddRange(fragmentVolumesRoot.Children);
|
||||
}
|
||||
|
||||
@@ -15,11 +15,10 @@ namespace DockerGenerator
|
||||
private void Run()
|
||||
{
|
||||
List<DockerComposeDefinition> defs = new List<DockerComposeDefinition>();
|
||||
var btc = new DockerComposeDefinition("btc",
|
||||
new string[] { "nginx", "btcpayserver", "bitcoin" });
|
||||
defs.Add(btc);
|
||||
defs.Add(new DockerComposeDefinition("btc",
|
||||
new List<string> { "nginx", "btcpayserver", "bitcoin" }));
|
||||
defs.Add(new DockerComposeDefinition("btc-ltc",
|
||||
new string[] { "nginx", "btcpayserver", "bitcoin", "litecoin" }));
|
||||
new List<string> { "nginx", "btcpayserver", "bitcoin", "litecoin" }));
|
||||
|
||||
var fragmentLocation = FindLocation("docker-fragments");
|
||||
var productionLocation = FindLocation("Production");
|
||||
@@ -29,7 +28,15 @@ namespace DockerGenerator
|
||||
def.BuildOutputDirectory = productionLocation;
|
||||
def.Build();
|
||||
}
|
||||
File.Copy(btc.GetFilePath(), Path.Combine(new FileInfo(btc.GetFilePath()).Directory.FullName, "docker-compose.yml"), true);
|
||||
|
||||
var testLocation = FindLocation("Test");
|
||||
foreach(var def in defs)
|
||||
{
|
||||
def.Fragments.Remove("nginx");
|
||||
def.Fragments.Add("btcpayserver-test");
|
||||
def.BuildOutputDirectory = testLocation;
|
||||
def.Build();
|
||||
}
|
||||
}
|
||||
|
||||
private string FindLocation(string path)
|
||||
|
||||
Reference in New Issue
Block a user