wip: updating codex container recipe for public deployment

This commit is contained in:
benbierens 2023-10-23 11:30:54 +02:00
parent 854325f10c
commit 840e794761
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
3 changed files with 43 additions and 6 deletions

View File

@ -29,20 +29,30 @@ namespace CodexPlugin
var config = startupConfig.Get<CodexStartupConfig>();
AddExposedPortAndVar("CODEX_API_PORT", ApiPortTag);
var apiPort = CreateApiPort(config, ApiPortTag);
AddEnvVar("CODEX_API_PORT", apiPort);
AddEnvVar("CODEX_API_BINDADDR", "0.0.0.0");
var dataDir = $"datadir{ContainerNumber}";
AddEnvVar("CODEX_DATA_DIR", dataDir);
AddVolume($"codex/{dataDir}", GetVolumeCapacity(config));
AddExposedPortAndVar("CODEX_DISC_PORT", DiscoveryPortTag);
var discPort = CreateP2pPort(config, DiscoveryPortTag);
AddEnvVar("CODEX_DISC_PORT", discPort);
AddEnvVar("CODEX_LOG_LEVEL", config.LogLevelWithTopics());
// This makes the node announce itself to its local (pod) IP address.
AddEnvVar("NAT_IP_AUTO", "true");
if (config.IsPublicTestNet)
{
todo
AddEnvVar("CODEX_NAT", "required");
}
else
{
// This makes the node announce itself to its local (pod) IP address.
AddEnvVar("NAT_IP_AUTO", "true");
}
var listenPort = AddExposedPort(ListenPortTag);
var listenPort = CreateP2pPort(config, ListenPortTag);
AddEnvVar("CODEX_LISTEN_ADDRS", $"/ip4/0.0.0.0/tcp/{listenPort.Number}");
if (!string.IsNullOrEmpty(config.BootstrapSpr))
@ -67,7 +77,7 @@ namespace CodexPlugin
}
if (config.MetricsEnabled)
{
var metricsPort = AddInternalPort(MetricsPortTag);
var metricsPort = CreateApiPort(config, MetricsPortTag);
AddEnvVar("CODEX_METRICS", "true");
AddEnvVar("CODEX_METRICS_ADDRESS", "0.0.0.0");
AddEnvVar("CODEX_METRICS_PORT", metricsPort);
@ -124,5 +134,23 @@ namespace CodexPlugin
if (!string.IsNullOrEmpty(DockerImageOverride)) return DockerImageOverride;
return DefaultDockerImage;
}
private Port CreateP2pPort(CodexStartupConfig config, string tag)
{
if (config.IsPublicTestNet)
{
return AddExposedPort(tag);
}
return AddInternalPort(tag);
}
private Port CreateApiPort(CodexStartupConfig config, string tag)
{
if (config.IsPublicTestNet)
{
return AddInternalPort(tag);
}
return AddExposedPort(tag);
}
}
}

View File

@ -22,6 +22,7 @@ namespace CodexPlugin
/// Provides an invalid proof every N proofs
/// </summary>
ICodexSetup WithSimulateProofFailures(uint failEveryNProofs);
ICodexSetup AsPublicTestNet();
}
public class CodexLogCustomTopics
@ -118,6 +119,12 @@ namespace CodexPlugin
return this;
}
public ICodexSetup AsPublicTestNet()
{
IsPublicTestNet = true;
return this;
}
public string Describe()
{
var args = string.Join(',', DescribeArgs());
@ -126,6 +133,7 @@ namespace CodexPlugin
private IEnumerable<string> DescribeArgs()
{
if (IsPublicTestNet) yield return "<!>Public TestNet<!>";
yield return $"LogLevel={LogLevelWithTopics()}";
if (BootstrapSpr != null) yield return $"BootstrapNode={BootstrapSpr}";
if (StorageQuota != null) yield return $"StorageQuota={StorageQuota}";

View File

@ -18,6 +18,7 @@ namespace CodexPlugin
public bool? EnableValidator { get; set; }
public TimeSpan? BlockMaintenanceInterval { get; set; }
public int? BlockMaintenanceNumber { get; set; }
public bool IsPublicTestNet { get; set; } = false;
public string LogLevelWithTopics()
{