summaryrefslogtreecommitdiffstats
path: root/packaging/dag/build_command.py
diff options
context:
space:
mode:
Diffstat (limited to 'packaging/dag/build_command.py')
-rw-r--r--packaging/dag/build_command.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/packaging/dag/build_command.py b/packaging/dag/build_command.py
new file mode 100644
index 000000000..dcb1b6c8a
--- /dev/null
+++ b/packaging/dag/build_command.py
@@ -0,0 +1,65 @@
+import click
+import asyncio
+import sys
+import dagger
+import pathlib
+import uuid
+
+from nd import (
+ Distribution,
+ NetdataInstaller,
+ FeatureFlags,
+ Endpoint,
+ AgentContext,
+ SUPPORTED_PLATFORMS,
+ SUPPORTED_DISTRIBUTIONS,
+)
+
+
+def run_async(func):
+ def wrapper(*args, **kwargs):
+ return asyncio.run(func(*args, **kwargs))
+
+ return wrapper
+
+
+@run_async
+async def simple_build(platform, distro):
+ config = dagger.Config(log_output=sys.stdout)
+
+ async with dagger.Connection(config) as client:
+ repo_root = pathlib.Path("/netdata")
+ prefix_path = pathlib.Path("/opt/netdata")
+
+ installer = NetdataInstaller(
+ platform, distro, repo_root, prefix_path, FeatureFlags.DBEngine
+ )
+
+ endpoint = Endpoint("node", 19999)
+ api_key = uuid.uuid4()
+ allow_children = False
+
+ agent_ctx = AgentContext(
+ client, platform, distro, installer, endpoint, api_key, allow_children
+ )
+
+ await agent_ctx.build_container()
+
+
+@click.command()
+@click.option(
+ "--platform",
+ "-p",
+ type=click.Choice(sorted([str(p) for p in SUPPORTED_PLATFORMS])),
+ help="Specify the platform.",
+)
+@click.option(
+ "--distribution",
+ "-d",
+ type=click.Choice(sorted([str(p) for p in SUPPORTED_DISTRIBUTIONS])),
+ help="Specify the distribution.",
+)
+def build(platform, distribution):
+ platform = dagger.Platform(platform)
+ distro = Distribution(distribution)
+ simple_build(platform, distro)