2023-06-01 07:35:18 +00:00
|
|
|
|
using DistTestCore.Marketplace;
|
2023-04-14 08:51:35 +00:00
|
|
|
|
using KubernetesWorkflow;
|
2023-04-12 11:53:55 +00:00
|
|
|
|
|
|
|
|
|
namespace DistTestCore.Codex
|
|
|
|
|
{
|
|
|
|
|
public class CodexContainerRecipe : ContainerRecipeFactory
|
|
|
|
|
{
|
2023-05-02 05:16:10 +00:00
|
|
|
|
#if Arm64
|
2023-05-30 19:45:41 +00:00
|
|
|
|
public const string DockerImage = "codexstorage/nim-codex:sha-7b88ea0";
|
2023-05-02 05:16:10 +00:00
|
|
|
|
#else
|
2023-05-30 19:45:41 +00:00
|
|
|
|
//public const string DockerImage = "codexstorage/nim-codex:sha-7b88ea0";
|
|
|
|
|
public const string DockerImage = "codexstorage/nim-codex:sha-7b88ea0";
|
2023-05-02 05:16:10 +00:00
|
|
|
|
#endif
|
2023-04-13 12:36:17 +00:00
|
|
|
|
public const string MetricsPortTag = "metrics_port";
|
2023-05-29 06:35:46 +00:00
|
|
|
|
public const string DiscoveryPortTag = "discovery-port";
|
2023-04-13 12:36:17 +00:00
|
|
|
|
|
2023-04-14 10:37:05 +00:00
|
|
|
|
protected override string Image => DockerImage;
|
2023-04-12 11:53:55 +00:00
|
|
|
|
|
|
|
|
|
protected override void Initialize(StartupConfig startupConfig)
|
|
|
|
|
{
|
|
|
|
|
var config = startupConfig.Get<CodexStartupConfig>();
|
|
|
|
|
|
|
|
|
|
AddExposedPortAndVar("API_PORT");
|
|
|
|
|
AddEnvVar("DATA_DIR", $"datadir{ContainerNumber}");
|
2023-05-29 06:35:46 +00:00
|
|
|
|
AddInternalPortAndVar("DISC_PORT", DiscoveryPortTag);
|
2023-05-31 11:50:52 +00:00
|
|
|
|
AddEnvVar("LOG_LEVEL", config.LogLevel.ToString()!.ToUpperInvariant());
|
2023-04-12 11:53:55 +00:00
|
|
|
|
|
|
|
|
|
var listenPort = AddInternalPort();
|
|
|
|
|
AddEnvVar("LISTEN_ADDRS", $"/ip4/0.0.0.0/tcp/{listenPort.Number}");
|
|
|
|
|
|
2023-04-24 12:09:23 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(config.BootstrapSpr))
|
|
|
|
|
{
|
|
|
|
|
AddEnvVar("BOOTSTRAP_SPR", config.BootstrapSpr);
|
|
|
|
|
}
|
2023-04-12 11:53:55 +00:00
|
|
|
|
if (config.StorageQuota != null)
|
|
|
|
|
{
|
|
|
|
|
AddEnvVar("STORAGE_QUOTA", config.StorageQuota.SizeInBytes.ToString()!);
|
|
|
|
|
}
|
|
|
|
|
if (config.MetricsEnabled)
|
|
|
|
|
{
|
|
|
|
|
AddEnvVar("METRICS_ADDR", "0.0.0.0");
|
2023-04-13 12:36:17 +00:00
|
|
|
|
AddInternalPortAndVar("METRICS_PORT", tag: MetricsPortTag);
|
2023-04-12 11:53:55 +00:00
|
|
|
|
}
|
2023-04-14 08:51:35 +00:00
|
|
|
|
|
|
|
|
|
if (config.MarketplaceConfig != null)
|
|
|
|
|
{
|
|
|
|
|
var gethConfig = startupConfig.Get<GethStartResult>();
|
2023-04-26 09:12:33 +00:00
|
|
|
|
var companionNode = gethConfig.CompanionNode;
|
|
|
|
|
var companionNodeAccount = companionNode.Accounts[Index];
|
|
|
|
|
Additional(companionNodeAccount);
|
2023-04-14 08:51:35 +00:00
|
|
|
|
|
2023-06-02 08:04:07 +00:00
|
|
|
|
var ip = companionNode.RunningContainer.Pod.PodInfo.Ip;
|
2023-04-21 07:57:52 +00:00
|
|
|
|
var port = companionNode.RunningContainer.Recipe.GetPortByTag(GethContainerRecipe.HttpPortTag).Number;
|
2023-04-14 08:51:35 +00:00
|
|
|
|
|
2023-04-18 11:45:48 +00:00
|
|
|
|
AddEnvVar("ETH_PROVIDER", $"ws://{ip}:{port}");
|
2023-04-26 09:12:33 +00:00
|
|
|
|
AddEnvVar("ETH_ACCOUNT", companionNodeAccount.Account);
|
2023-04-18 11:45:48 +00:00
|
|
|
|
AddEnvVar("ETH_MARKETPLACE_ADDRESS", gethConfig.MarketplaceNetwork.Marketplace.Address);
|
2023-06-01 07:35:18 +00:00
|
|
|
|
AddEnvVar("PERSISTENCE", "1");
|
2023-04-14 08:51:35 +00:00
|
|
|
|
}
|
2023-04-12 11:53:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|