2023-10-24 08:06:07 +00:00
|
|
|
|
using KubernetesWorkflow;
|
2023-11-12 09:07:23 +00:00
|
|
|
|
using KubernetesWorkflow.Recipe;
|
2023-10-25 09:53:33 +00:00
|
|
|
|
using Utils;
|
2023-10-24 08:06:07 +00:00
|
|
|
|
|
|
|
|
|
namespace CodexDiscordBotPlugin
|
|
|
|
|
{
|
|
|
|
|
public class DiscordBotContainerRecipe : ContainerRecipeFactory
|
|
|
|
|
{
|
|
|
|
|
public override string AppName => "discordbot-bibliotech";
|
2024-05-20 14:18:01 +00:00
|
|
|
|
public override string Image => "codexstorage/codex-discordbot:sha-22cf82b";
|
2023-10-24 08:06:07 +00:00
|
|
|
|
|
2024-02-19 08:11:36 +00:00
|
|
|
|
public static string RewardsPort = "bot_rewards_port";
|
|
|
|
|
|
2023-10-24 08:06:07 +00:00
|
|
|
|
protected override void Initialize(StartupConfig startupConfig)
|
|
|
|
|
{
|
|
|
|
|
var config = startupConfig.Get<DiscordBotStartupConfig>();
|
|
|
|
|
|
2023-11-27 17:06:04 +00:00
|
|
|
|
SetSchedulingAffinity(notIn: "false");
|
2023-11-14 09:16:00 +00:00
|
|
|
|
|
2023-10-24 08:06:07 +00:00
|
|
|
|
AddEnvVar("TOKEN", config.Token);
|
|
|
|
|
AddEnvVar("SERVERNAME", config.ServerName);
|
|
|
|
|
AddEnvVar("ADMINROLE", config.AdminRoleName);
|
2023-10-25 08:38:21 +00:00
|
|
|
|
AddEnvVar("ADMINCHANNELNAME", config.AdminChannelName);
|
2024-02-19 08:11:36 +00:00
|
|
|
|
AddEnvVar("REWARDSCHANNELNAME", config.RewardChannelName);
|
2023-11-08 10:49:21 +00:00
|
|
|
|
AddEnvVar("KUBECONFIG", "/opt/kubeconfig.yaml");
|
|
|
|
|
AddEnvVar("KUBENAMESPACE", config.KubeNamespace);
|
2023-10-25 09:53:33 +00:00
|
|
|
|
|
2023-12-11 10:09:29 +00:00
|
|
|
|
var gethInfo = config.GethInfo;
|
|
|
|
|
AddEnvVar("GETH_HOST", gethInfo.Host);
|
|
|
|
|
AddEnvVar("GETH_HTTP_PORT", gethInfo.Port.ToString());
|
|
|
|
|
AddEnvVar("GETH_PRIVATE_KEY", gethInfo.PrivKey);
|
|
|
|
|
AddEnvVar("CODEXCONTRACTS_MARKETPLACEADDRESS", gethInfo.MarketplaceAddress);
|
|
|
|
|
AddEnvVar("CODEXCONTRACTS_TOKENADDRESS", gethInfo.TokenAddress);
|
|
|
|
|
AddEnvVar("CODEXCONTRACTS_ABI", gethInfo.Abi);
|
|
|
|
|
|
2024-05-20 14:18:01 +00:00
|
|
|
|
AddEnvVar("NODISCORD", "1");
|
|
|
|
|
|
2024-02-19 08:11:36 +00:00
|
|
|
|
AddInternalPortAndVar("REWARDAPIPORT", RewardsPort);
|
|
|
|
|
|
2023-10-25 12:33:47 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(config.DataPath))
|
2023-10-25 09:53:33 +00:00
|
|
|
|
{
|
|
|
|
|
AddEnvVar("DATAPATH", config.DataPath);
|
|
|
|
|
AddVolume(config.DataPath, 1.GB());
|
|
|
|
|
}
|
2023-10-24 08:06:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|