arkitekt-next 0.7.33__py3-none-any.whl → 0.7.34__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of arkitekt-next might be problematic. Click here for more details.
- arkitekt_next/__blok__.py +14 -2
- arkitekt_next/bloks/__init__.py +1 -0
- arkitekt_next/bloks/admin.py +7 -15
- arkitekt_next/bloks/arkitekt.py +10 -23
- arkitekt_next/bloks/config.py +42 -0
- arkitekt_next/bloks/fluss.py +20 -70
- arkitekt_next/bloks/funcs.py +86 -0
- arkitekt_next/bloks/gateway.py +48 -28
- arkitekt_next/bloks/internal_docker.py +80 -0
- arkitekt_next/bloks/kabinet.py +20 -70
- arkitekt_next/bloks/livekit.py +33 -12
- arkitekt_next/bloks/lok.py +69 -33
- arkitekt_next/bloks/mikro.py +19 -73
- arkitekt_next/bloks/minio.py +28 -28
- arkitekt_next/bloks/mount.py +35 -0
- arkitekt_next/bloks/postgres.py +13 -19
- arkitekt_next/bloks/redis.py +8 -17
- arkitekt_next/bloks/rekuest.py +93 -0
- arkitekt_next/bloks/services/__init__.py +0 -0
- arkitekt_next/bloks/services/admin.py +22 -0
- arkitekt_next/bloks/services/config.py +18 -0
- arkitekt_next/bloks/services/db.py +27 -0
- arkitekt_next/bloks/services/gateway.py +20 -0
- arkitekt_next/bloks/services/livekit.py +19 -0
- arkitekt_next/bloks/services/lok.py +27 -0
- arkitekt_next/bloks/services/mount.py +15 -0
- arkitekt_next/bloks/services/redis.py +28 -0
- arkitekt_next/bloks/services/s3.py +26 -0
- arkitekt_next/bloks/services/socket.py +16 -0
- arkitekt_next/bloks/socket.py +38 -0
- arkitekt_next/cli/commands/server/init.py +4 -63
- {arkitekt_next-0.7.33.dist-info → arkitekt_next-0.7.34.dist-info}/METADATA +1 -1
- {arkitekt_next-0.7.33.dist-info → arkitekt_next-0.7.34.dist-info}/RECORD +36 -20
- arkitekt_next/bloks/services.py +0 -2
- {arkitekt_next-0.7.33.dist-info → arkitekt_next-0.7.34.dist-info}/LICENSE +0 -0
- {arkitekt_next-0.7.33.dist-info → arkitekt_next-0.7.34.dist-info}/WHEEL +0 -0
- {arkitekt_next-0.7.33.dist-info → arkitekt_next-0.7.34.dist-info}/entry_points.txt +0 -0
arkitekt_next/__blok__.py
CHANGED
|
@@ -4,10 +4,16 @@ from arkitekt_next.bloks.mikro import MikroBlok
|
|
|
4
4
|
from arkitekt_next.bloks.fluss import FlussBlok
|
|
5
5
|
from arkitekt_next.bloks.redis import RedisBlok
|
|
6
6
|
from arkitekt_next.bloks.gateway import GatewayBlok
|
|
7
|
-
from arkitekt_next.bloks.livekit import
|
|
7
|
+
from arkitekt_next.bloks.livekit import LocalLiveKitBlok
|
|
8
8
|
from arkitekt_next.bloks.postgres import PostgresBlok
|
|
9
9
|
from arkitekt_next.bloks.minio import MinioBlok
|
|
10
|
+
from arkitekt_next.bloks.kabinet import KabinetBlok
|
|
10
11
|
from arkitekt_next.bloks.lok import LokBlok
|
|
12
|
+
from arkitekt_next.bloks.config import ConfigBlok
|
|
13
|
+
from arkitekt_next.bloks.mount import MountBlok
|
|
14
|
+
from arkitekt_next.bloks.internal_docker import InternalDockerBlok
|
|
15
|
+
from arkitekt_next.bloks.socket import DockerSocketBlok
|
|
16
|
+
from arkitekt_next.bloks.rekuest import RekuestBlok
|
|
11
17
|
|
|
12
18
|
|
|
13
19
|
def get_bloks():
|
|
@@ -18,8 +24,14 @@ def get_bloks():
|
|
|
18
24
|
FlussBlok(),
|
|
19
25
|
RedisBlok(),
|
|
20
26
|
GatewayBlok(),
|
|
21
|
-
|
|
27
|
+
LocalLiveKitBlok(),
|
|
22
28
|
PostgresBlok(),
|
|
23
29
|
MinioBlok(),
|
|
24
30
|
LokBlok(),
|
|
31
|
+
KabinetBlok(),
|
|
32
|
+
MountBlok(),
|
|
33
|
+
ConfigBlok(),
|
|
34
|
+
InternalDockerBlok(),
|
|
35
|
+
DockerSocketBlok(),
|
|
36
|
+
RekuestBlok(),
|
|
25
37
|
]
|
arkitekt_next/bloks/__init__.py
CHANGED
arkitekt_next/bloks/admin.py
CHANGED
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
from pydantic import BaseModel
|
|
2
2
|
from typing import Dict, Any
|
|
3
|
-
from blok import blok, InitContext,
|
|
3
|
+
from blok import blok, InitContext, Option
|
|
4
|
+
from arkitekt_next.bloks.services.admin import AdminService, AdminCredentials
|
|
4
5
|
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
password: str
|
|
8
|
-
username: str
|
|
9
|
-
email: str
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@blok("live.arkitekt.admin")
|
|
7
|
+
@blok(AdminService)
|
|
13
8
|
class AdminBlok:
|
|
14
9
|
def __init__(self) -> None:
|
|
15
10
|
self.password = "admin"
|
|
16
11
|
self.username = "admin"
|
|
17
12
|
self.email = "admin@admin.com"
|
|
18
13
|
|
|
19
|
-
def
|
|
14
|
+
def preflight(self, init: InitContext):
|
|
20
15
|
for key, value in init.kwargs.items():
|
|
21
16
|
setattr(self, key, value)
|
|
22
17
|
|
|
23
|
-
def build(self, cwd):
|
|
24
|
-
pass
|
|
25
|
-
|
|
26
18
|
def retrieve(self):
|
|
27
19
|
return AdminCredentials(
|
|
28
20
|
password=self.password,
|
|
@@ -31,19 +23,19 @@ class AdminBlok:
|
|
|
31
23
|
)
|
|
32
24
|
|
|
33
25
|
def get_options(self):
|
|
34
|
-
with_username =
|
|
26
|
+
with_username = Option(
|
|
35
27
|
subcommand="username",
|
|
36
28
|
help="Which admin username to use",
|
|
37
29
|
default=self.username,
|
|
38
30
|
show_default=True,
|
|
39
31
|
)
|
|
40
|
-
with_username =
|
|
32
|
+
with_username = Option(
|
|
41
33
|
subcommand="password",
|
|
42
34
|
help="Which password to use",
|
|
43
35
|
default=self.password,
|
|
44
36
|
show_default=True,
|
|
45
37
|
)
|
|
46
|
-
with_email =
|
|
38
|
+
with_email = Option(
|
|
47
39
|
subcommand="password",
|
|
48
40
|
help="Which password to use",
|
|
49
41
|
default=self.password,
|
arkitekt_next/bloks/arkitekt.py
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
from pydantic import BaseModel
|
|
2
2
|
from typing import Dict, Any
|
|
3
3
|
from blok import blok, InitContext, Renderer, Panel
|
|
4
|
+
from .livekit import LocalLiveKitBlok
|
|
5
|
+
from .mikro import MikroBlok
|
|
6
|
+
from .kabinet import KabinetBlok
|
|
7
|
+
from .rekuest import RekuestBlok
|
|
8
|
+
from .fluss import FlussBlok
|
|
9
|
+
from .gateway import GatewayBlok
|
|
10
|
+
from .internal_docker import InternalDockerBlok
|
|
4
11
|
|
|
5
12
|
|
|
6
13
|
class AdminCredentials(BaseModel):
|
|
@@ -11,17 +18,6 @@ class AdminCredentials(BaseModel):
|
|
|
11
18
|
|
|
12
19
|
@blok("live.arkitekt")
|
|
13
20
|
class ArkitektBlok:
|
|
14
|
-
def __init__(self) -> None:
|
|
15
|
-
pass
|
|
16
|
-
|
|
17
|
-
def get_dependencies(self):
|
|
18
|
-
return [
|
|
19
|
-
"live.arkitekt.lok",
|
|
20
|
-
"live.arkitekt.mikro",
|
|
21
|
-
"live.arkitekt.kabinet",
|
|
22
|
-
"live.arkitekt.gateway",
|
|
23
|
-
"io.livekit.livekit",
|
|
24
|
-
]
|
|
25
21
|
|
|
26
22
|
def entry(self, renderer: Renderer):
|
|
27
23
|
renderer.render(
|
|
@@ -33,19 +29,10 @@ class ArkitektBlok:
|
|
|
33
29
|
)
|
|
34
30
|
)
|
|
35
31
|
|
|
36
|
-
def
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
def preflight(self, lok: LocalLiveKitBlok, mikro: MikroBlok, kabinet: KabinetBlok, rekuest: RekuestBlok, fluss: FlussBlok, gateway: GatewayBlok, internal_engine: InternalDockerBlok):
|
|
33
|
+
print (lok, mikro, kabinet, rekuest, fluss, gateway, internal_engine)
|
|
34
|
+
|
|
39
35
|
|
|
40
36
|
def build(self, cwd):
|
|
41
37
|
pass
|
|
42
38
|
|
|
43
|
-
def retrieve(self):
|
|
44
|
-
return AdminCredentials(
|
|
45
|
-
password=self.password,
|
|
46
|
-
username=self.username,
|
|
47
|
-
email=self.email,
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
def get_options(self):
|
|
51
|
-
return []
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
from typing import Dict, Any
|
|
3
|
+
from blok import blok, InitContext, Option, ExecutionContext
|
|
4
|
+
from blok.tree import YamlFile
|
|
5
|
+
from arkitekt_next.bloks.services.config import ConfigService
|
|
6
|
+
|
|
7
|
+
class AdminCredentials(BaseModel):
|
|
8
|
+
password: str
|
|
9
|
+
username: str
|
|
10
|
+
email: str
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@blok(ConfigService)
|
|
14
|
+
class ConfigBlok:
|
|
15
|
+
def __init__(self) -> None:
|
|
16
|
+
self.config_path = "configs"
|
|
17
|
+
self.registered_configs = {}
|
|
18
|
+
|
|
19
|
+
def preflight(self, init: InitContext):
|
|
20
|
+
for key, value in init.kwargs.items():
|
|
21
|
+
setattr(self, key, value)
|
|
22
|
+
|
|
23
|
+
def build(self, ex: ExecutionContext):
|
|
24
|
+
for name, file in self.registered_configs.items():
|
|
25
|
+
ex.file_tree.set_nested(*f"{self.config_path}/{name}".split("/"), file)
|
|
26
|
+
|
|
27
|
+
def register_config(self, name: str, file: YamlFile) -> str:
|
|
28
|
+
self.registered_configs[name] = file
|
|
29
|
+
return f"./{self.config_path}/" + name
|
|
30
|
+
|
|
31
|
+
def get_path(self, name: str) -> str:
|
|
32
|
+
return f"./{self.config_path}/" + name
|
|
33
|
+
|
|
34
|
+
def get_options(self):
|
|
35
|
+
config_path = Option(
|
|
36
|
+
subcommand="config_path",
|
|
37
|
+
help="Which path to use for configs",
|
|
38
|
+
default=self.config_path,
|
|
39
|
+
show_default=True,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
return [config_path]
|
arkitekt_next/bloks/fluss.py
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import secrets
|
|
2
|
-
from
|
|
2
|
+
from arkitekt_next.bloks.funcs import create_default_service_yaml
|
|
3
|
+
from blok import blok, InitContext, ExecutionContext, Option
|
|
3
4
|
from blok.tree import YamlFile, Repo
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
DEFAULT_ARKITEKT_URL = "http://localhost:8000"
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
@blok("live.arkitekt.
|
|
10
|
+
@blok("live.arkitekt.fluss")
|
|
10
11
|
class FlussBlok:
|
|
11
12
|
def __init__(self) -> None:
|
|
12
13
|
self.host = "fluss"
|
|
13
14
|
self.command = "bash run-debug.sh"
|
|
15
|
+
self.image = "jhnnsrs/fluss:next"
|
|
14
16
|
self.repo = "https://github.com/jhnnsrs/fluss-server-next"
|
|
15
17
|
self.scopes = {"read_image": "Read image from the database"}
|
|
16
|
-
self.mount_repo =
|
|
17
|
-
self.build_repo =
|
|
18
|
+
self.mount_repo = False
|
|
19
|
+
self.build_repo = False
|
|
20
|
+
self.buckets = ["media"]
|
|
18
21
|
self.secret_key = secrets.token_hex(16)
|
|
19
22
|
self.ensured_repos = []
|
|
20
23
|
|
|
21
24
|
def get_dependencies(self):
|
|
22
25
|
return [
|
|
26
|
+
"live.arkitekt.mount",
|
|
27
|
+
"live.arkitekt.config",
|
|
23
28
|
"live.arkitekt.gateway",
|
|
24
29
|
"live.arkitekt.postgres",
|
|
25
30
|
"live.arkitekt.lok",
|
|
@@ -28,101 +33,46 @@ class FlussBlok:
|
|
|
28
33
|
"live.arkitekt.s3",
|
|
29
34
|
]
|
|
30
35
|
|
|
31
|
-
def
|
|
36
|
+
def preflight(self, init: InitContext):
|
|
32
37
|
for key, value in init.kwargs.items():
|
|
33
38
|
setattr(self, key, value)
|
|
34
39
|
|
|
35
|
-
|
|
40
|
+
self.service = create_default_service_yaml(init, self)
|
|
36
41
|
|
|
37
|
-
deps["live.arkitekt.lok"].register_scopes(self.scopes)
|
|
38
|
-
|
|
39
|
-
self.gateway_access = deps["live.arkitekt.gateway"].expose(
|
|
40
|
-
self.host, 80, self.host
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
self.postgress_access = deps["live.arkitekt.postgres"].register_db(self.host)
|
|
44
|
-
self.redis_access = deps["live.arkitekt.redis"].register()
|
|
45
|
-
self.lok_access = deps["live.arkitekt.lok"].retrieve_credentials()
|
|
46
|
-
self.admin_access = deps["live.arkitekt.admin"].retrieve()
|
|
47
|
-
self.minio_access = deps["live.arkitekt.s3"].retrieve_credentials(["media"])
|
|
48
42
|
self.initialized = True
|
|
49
43
|
|
|
50
44
|
def build(self, context: ExecutionContext):
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if self.redis_access.dependency:
|
|
54
|
-
depends_on.append(self.redis_access.dependency)
|
|
55
|
-
|
|
56
|
-
if self.postgress_access.dependency:
|
|
57
|
-
depends_on.append(self.postgress_access.dependency)
|
|
58
|
-
|
|
59
|
-
db_service = {
|
|
60
|
-
"labels": [
|
|
61
|
-
"fakts.service=live.arkitekt.fluss",
|
|
62
|
-
"fakts.builder=arkitekt.fluss",
|
|
63
|
-
],
|
|
64
|
-
"depends_on": depends_on,
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if self.mount_repo:
|
|
68
|
-
context.file_tree.set_nested("mounts", self.host, Repo(self.repo))
|
|
69
|
-
db_service["volumes"] = [f"./mounts/{self.host}:/workspace"]
|
|
70
|
-
|
|
71
|
-
if self.build_repo:
|
|
72
|
-
context.file_tree.set_nested("mounts", self.host, Repo(self.repo))
|
|
73
|
-
db_service["build"] = f"./mounts/{self.host}"
|
|
74
|
-
|
|
75
|
-
db_service["command"] = self.command
|
|
76
|
-
|
|
77
|
-
configuration = YamlFile(
|
|
78
|
-
**{
|
|
79
|
-
"db": self.postgress_access.dict(),
|
|
80
|
-
"django": {
|
|
81
|
-
"admin": self.admin_access.dict(),
|
|
82
|
-
"debug": True,
|
|
83
|
-
"hosts": ["*"],
|
|
84
|
-
"secret_key": self.secret_key,
|
|
85
|
-
},
|
|
86
|
-
"redis": self.redis_access.dict(),
|
|
87
|
-
"lok": self.lok_access.dict(),
|
|
88
|
-
"s3": self.minio_access.dict(),
|
|
89
|
-
"scopes": self.scopes,
|
|
90
|
-
}
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
context.file_tree.set_nested("configs", "fluss.yaml", configuration)
|
|
94
|
-
|
|
95
|
-
context.docker_compose.set_nested("services", self.host, db_service)
|
|
45
|
+
context.docker_compose.set_nested("services", self.host, self.service)
|
|
96
46
|
|
|
97
47
|
def get_options(self):
|
|
98
|
-
with_repo =
|
|
48
|
+
with_repo = Option(
|
|
99
49
|
subcommand="with_repo",
|
|
100
50
|
help="Which repo should we use when building the service? Only active if build_repo or mount_repo is active",
|
|
101
51
|
default=self.repo,
|
|
102
52
|
)
|
|
103
|
-
with_command =
|
|
53
|
+
with_command = Option(
|
|
104
54
|
subcommand="command",
|
|
105
55
|
help="Which command should be run when starting the service",
|
|
106
56
|
default=self.command,
|
|
107
57
|
)
|
|
108
|
-
mount_repo =
|
|
58
|
+
mount_repo = Option(
|
|
109
59
|
subcommand="mount_repo",
|
|
110
60
|
help="Should we mount the repo into the container?",
|
|
111
61
|
is_flag=True,
|
|
112
|
-
default=
|
|
62
|
+
default=self.mount_repo,
|
|
113
63
|
)
|
|
114
|
-
build_repo =
|
|
64
|
+
build_repo = Option(
|
|
115
65
|
subcommand="build_repo",
|
|
116
66
|
help="Should we build the container from the repo?",
|
|
117
67
|
is_flag=True,
|
|
118
|
-
default=
|
|
68
|
+
default=self.build_repo,
|
|
119
69
|
)
|
|
120
|
-
with_host =
|
|
70
|
+
with_host = Option(
|
|
121
71
|
subcommand="host",
|
|
122
72
|
help="How should the service be named inside the docker-compose file?",
|
|
123
73
|
default=self.host,
|
|
124
74
|
)
|
|
125
|
-
with_secret_key =
|
|
75
|
+
with_secret_key = Option(
|
|
126
76
|
subcommand="secret_key",
|
|
127
77
|
help="The secret key to use for the django service",
|
|
128
78
|
default=self.secret_key,
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
from blok import blok, InitContext, Option
|
|
2
|
+
from blok.tree import YamlFile, Repo
|
|
3
|
+
from typing import Protocol
|
|
4
|
+
from blok.utils import check_protocol_compliance
|
|
5
|
+
from dataclasses import asdict
|
|
6
|
+
|
|
7
|
+
class DefaultService(Protocol):
|
|
8
|
+
service_name: str
|
|
9
|
+
host: str
|
|
10
|
+
buckets: list[str]
|
|
11
|
+
scopes: dict[str, str]
|
|
12
|
+
secret_key: str
|
|
13
|
+
mount_repo: bool
|
|
14
|
+
build_repo: bool
|
|
15
|
+
|
|
16
|
+
def get_identifier(self) -> str: ...
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def create_default_service_yaml(
|
|
20
|
+
init: InitContext,
|
|
21
|
+
self: DefaultService,
|
|
22
|
+
) -> YamlFile:
|
|
23
|
+
check_protocol_compliance(self, DefaultService)
|
|
24
|
+
deps = init.dependencies
|
|
25
|
+
deps["live.arkitekt.lok"].register_scopes(self.scopes)
|
|
26
|
+
|
|
27
|
+
gateway_access = deps["live.arkitekt.gateway"].expose(self.host, 80, self.host)
|
|
28
|
+
|
|
29
|
+
postgress_access = deps["live.arkitekt.postgres"].register_db(self.host)
|
|
30
|
+
redis_access = deps["live.arkitekt.redis"].register()
|
|
31
|
+
lok_access = deps["live.arkitekt.lok"].retrieve_credentials()
|
|
32
|
+
admin_access = deps["live.arkitekt.admin"].retrieve()
|
|
33
|
+
minio_access = deps["live.arkitekt.s3"].create_buckets(self.buckets)
|
|
34
|
+
lok_access = deps["live.arkitekt.lok"].retrieve_credentials()
|
|
35
|
+
lok_labels = deps["live.arkitekt.lok"].retrieve_labels(self.get_identifier())
|
|
36
|
+
|
|
37
|
+
configuration = YamlFile(
|
|
38
|
+
**{
|
|
39
|
+
"db": asdict(postgress_access),
|
|
40
|
+
"django": {
|
|
41
|
+
"admin": asdict(admin_access),
|
|
42
|
+
"debug": True,
|
|
43
|
+
"hosts": ["*"],
|
|
44
|
+
"secret_key": self.secret_key,
|
|
45
|
+
},
|
|
46
|
+
"redis": asdict(redis_access),
|
|
47
|
+
"lok": asdict(lok_access),
|
|
48
|
+
"s3": asdict(minio_access),
|
|
49
|
+
"scopes": self.scopes,
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
config_mount = deps["live.arkitekt.config"].register_config(
|
|
54
|
+
f"{self.host}.yaml", configuration
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
depends_on = []
|
|
58
|
+
|
|
59
|
+
if redis_access.dependency:
|
|
60
|
+
depends_on.append(redis_access.dependency)
|
|
61
|
+
|
|
62
|
+
if postgress_access.dependency:
|
|
63
|
+
depends_on.append(postgress_access.dependency)
|
|
64
|
+
|
|
65
|
+
if minio_access.dependency:
|
|
66
|
+
depends_on.append(minio_access.dependency)
|
|
67
|
+
|
|
68
|
+
service = {
|
|
69
|
+
"labels": lok_labels,
|
|
70
|
+
"volumes": [f"{config_mount}:/workspace/config.yaml"],
|
|
71
|
+
"depends_on": depends_on,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if self.mount_repo:
|
|
75
|
+
mount = deps["live.arkitekt.mount"].register_mount(self.host, Repo(self.repo))
|
|
76
|
+
service["volumes"].extend([f"{mount}:/workspace"])
|
|
77
|
+
|
|
78
|
+
if self.build_repo:
|
|
79
|
+
mount = deps["live.arkitekt.mount"].register_mount(self.host, Repo(self.repo))
|
|
80
|
+
service["build"] = mount
|
|
81
|
+
else:
|
|
82
|
+
service["image"] = self.image
|
|
83
|
+
|
|
84
|
+
service["command"] = self.command
|
|
85
|
+
|
|
86
|
+
return service
|
arkitekt_next/bloks/gateway.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from blok import blok, InitContext, ExecutionContext,
|
|
1
|
+
from blok import blok, InitContext, ExecutionContext, Option
|
|
2
2
|
from blok.tree import YamlFile, Repo
|
|
3
3
|
from pydantic import BaseModel
|
|
4
4
|
from typing import Dict, Any
|
|
@@ -30,16 +30,16 @@ class GatewayBlok:
|
|
|
30
30
|
self.exposed_ports = {}
|
|
31
31
|
self.with_certer = True
|
|
32
32
|
self.with_tailscale = True
|
|
33
|
+
self.certer_image = "jhnnsrs/certer:next"
|
|
33
34
|
self.http_port = 80
|
|
34
35
|
self.https_port = 443
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return "live.arkitekt.gateway"
|
|
36
|
+
self.public_ips = DEFAULT_PUBLIC_URLS
|
|
37
|
+
self.public_hosts = DEFAULT_PUBLIC_HOSTS
|
|
38
38
|
|
|
39
39
|
def get_dependencies(self):
|
|
40
40
|
return []
|
|
41
41
|
|
|
42
|
-
def
|
|
42
|
+
def preflight(self, init: InitContext):
|
|
43
43
|
for key, value in init.kwargs.items():
|
|
44
44
|
setattr(self, key, value)
|
|
45
45
|
|
|
@@ -65,10 +65,18 @@ class GatewayBlok:
|
|
|
65
65
|
}}
|
|
66
66
|
"""
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
for protocol in ["http", "https"]:
|
|
69
|
+
caddyfile += f"""
|
|
70
|
+
{protocol}:// {{
|
|
71
|
+
"""
|
|
72
|
+
caddyfile += (
|
|
73
|
+
"""
|
|
70
74
|
tls /certs/caddy.crt /certs/caddy.key
|
|
71
|
-
|
|
75
|
+
"""
|
|
76
|
+
if protocol == "https"
|
|
77
|
+
else ""
|
|
78
|
+
)
|
|
79
|
+
caddyfile += """
|
|
72
80
|
header {
|
|
73
81
|
-Server
|
|
74
82
|
X-Forwarded-Proto {scheme}
|
|
@@ -78,26 +86,35 @@ https:// {
|
|
|
78
86
|
}
|
|
79
87
|
"""
|
|
80
88
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
@{path_name} path /{path_name}
|
|
89
|
+
for path_name, exposed_host in self.exposed_hosts.items():
|
|
90
|
+
if exposed_host.stip_prefix:
|
|
91
|
+
caddyfile += f"""
|
|
92
|
+
@{path_name} path /{path_name}*
|
|
93
|
+
handle @{path_name} {{
|
|
85
94
|
uri strip_prefix /{path_name}
|
|
86
95
|
reverse_proxy {exposed_host.host}:{exposed_host.port}
|
|
87
96
|
}}
|
|
88
97
|
"""
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
@{path_name} path /{path_name}
|
|
98
|
+
else:
|
|
99
|
+
caddyfile += f"""
|
|
100
|
+
@{path_name} path /{path_name}*
|
|
101
|
+
handle @{path_name} {{
|
|
92
102
|
reverse_proxy {exposed_host.host}:{exposed_host.port}
|
|
93
103
|
}}
|
|
94
104
|
"""
|
|
95
105
|
|
|
96
|
-
|
|
106
|
+
if self.http_expose_default:
|
|
107
|
+
caddyfile += f"""
|
|
108
|
+
handle {{
|
|
109
|
+
reverse_proxy {self.http_expose_default.host}:{self.http_expose_default.port}
|
|
110
|
+
}}
|
|
111
|
+
"""
|
|
112
|
+
|
|
113
|
+
caddyfile += """
|
|
97
114
|
}
|
|
98
115
|
"""
|
|
99
116
|
|
|
100
|
-
context.file_tree.set_nested("
|
|
117
|
+
context.file_tree.set_nested("configs", "Caddyfile", caddyfile)
|
|
101
118
|
|
|
102
119
|
caddy_depends_on = []
|
|
103
120
|
if self.with_certer:
|
|
@@ -105,21 +122,24 @@ https:// {
|
|
|
105
122
|
|
|
106
123
|
caddy_container = {
|
|
107
124
|
"image": "caddy:latest",
|
|
108
|
-
"volumes": ["./
|
|
125
|
+
"volumes": ["./configs/Caddyfile:/etc/caddy/Caddyfile", "./certs:/certs"],
|
|
109
126
|
"ports": [f"{self.http_port}:80", f"{self.https_port}:443"],
|
|
110
127
|
"depends_on": caddy_depends_on,
|
|
111
128
|
}
|
|
112
129
|
|
|
113
130
|
context.docker_compose.set_nested("services", "caddy", caddy_container)
|
|
114
131
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
}
|
|
132
|
+
context.file_tree.set_nested("certs", {})
|
|
133
|
+
certer_container = {
|
|
134
|
+
"image": self.certer_image,
|
|
135
|
+
"volumes": ["./certs:/certs"],
|
|
136
|
+
"environment": {
|
|
137
|
+
"DOMAIN_NAMES": ",".join(self.public_hosts),
|
|
138
|
+
"IP_ADDRESSED": ",".join(self.public_ips),
|
|
139
|
+
},
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
context.docker_compose.set_nested("services", "certer", certer_container)
|
|
123
143
|
|
|
124
144
|
def expose(self, path_name: str, port: int, host: str, strip_prefix: bool = True):
|
|
125
145
|
self.exposed_hosts[path_name] = ExposedHost(
|
|
@@ -133,7 +153,7 @@ https:// {
|
|
|
133
153
|
self.exposed_ports[port] = ExposedPort(port=port, host=host, tls=tls)
|
|
134
154
|
|
|
135
155
|
def get_options(self):
|
|
136
|
-
with_public_urls =
|
|
156
|
+
with_public_urls = Option(
|
|
137
157
|
subcommand="public_url",
|
|
138
158
|
help="Which public urls to use",
|
|
139
159
|
type=str,
|
|
@@ -141,7 +161,7 @@ https:// {
|
|
|
141
161
|
default=DEFAULT_PUBLIC_URLS,
|
|
142
162
|
show_default=True,
|
|
143
163
|
)
|
|
144
|
-
with_public_services =
|
|
164
|
+
with_public_services = Option(
|
|
145
165
|
subcommand="public_hosts",
|
|
146
166
|
help="Which public hosts to use",
|
|
147
167
|
type=str,
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
from typing import Dict, Any
|
|
2
|
+
import secrets
|
|
3
|
+
|
|
4
|
+
from blok import blok, InitContext, ExecutionContext, Option
|
|
5
|
+
from blok.tree import YamlFile, Repo
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@blok("live.arkitekt.internal_engine")
|
|
9
|
+
class InternalDockerBlok:
|
|
10
|
+
def __init__(self) -> None:
|
|
11
|
+
self.host = "internal_docker"
|
|
12
|
+
self.command = (
|
|
13
|
+
"arkitekt-next run prod --redeem-token=mylittletoken --url http://caddy:80"
|
|
14
|
+
)
|
|
15
|
+
self.image = "jhnnsrs/deployer:0.0.1-vanilla"
|
|
16
|
+
self.instance_id = "INTERNAL_DOCKER"
|
|
17
|
+
|
|
18
|
+
def get_dependencies(self):
|
|
19
|
+
return ["live.arkitekt.docker_socket"]
|
|
20
|
+
|
|
21
|
+
def preflight(self, init: InitContext):
|
|
22
|
+
for key, value in init.kwargs.items():
|
|
23
|
+
setattr(self, key, value)
|
|
24
|
+
|
|
25
|
+
deps = init.dependencies
|
|
26
|
+
|
|
27
|
+
if self.skip:
|
|
28
|
+
return
|
|
29
|
+
|
|
30
|
+
self._socket = deps["live.arkitekt.docker_socket"].register_socket(self.host)
|
|
31
|
+
|
|
32
|
+
self.initialized = True
|
|
33
|
+
|
|
34
|
+
def build(self, context: ExecutionContext):
|
|
35
|
+
if self.skip:
|
|
36
|
+
return
|
|
37
|
+
db_service = {
|
|
38
|
+
"labels": [
|
|
39
|
+
"fakts.service=io.livekit.livekit",
|
|
40
|
+
"fakts.builder=livekitio.livekit",
|
|
41
|
+
],
|
|
42
|
+
"image": self.image,
|
|
43
|
+
"command": self.command,
|
|
44
|
+
"volumes": [f"{self._socket}:/var/run/docker.sock"],
|
|
45
|
+
"environment": {
|
|
46
|
+
"INSTANCE_ID": self.instance_id,
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
context.docker_compose.set_nested("services", self.host, db_service)
|
|
51
|
+
|
|
52
|
+
def get_options(self):
|
|
53
|
+
with_command = Option(
|
|
54
|
+
subcommand="command",
|
|
55
|
+
help="The fakts url for connection",
|
|
56
|
+
default=self.command,
|
|
57
|
+
)
|
|
58
|
+
with_host = Option(
|
|
59
|
+
subcommand="host",
|
|
60
|
+
help="The fakts url for connection",
|
|
61
|
+
default=self.host,
|
|
62
|
+
)
|
|
63
|
+
with_skip = Option(
|
|
64
|
+
subcommand="skip",
|
|
65
|
+
help="The fakts url for connection",
|
|
66
|
+
default=False,
|
|
67
|
+
type=bool,
|
|
68
|
+
is_flag=True,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
return [
|
|
72
|
+
with_host,
|
|
73
|
+
with_command,
|
|
74
|
+
with_skip,
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
def __str__(self) -> str:
|
|
78
|
+
return (
|
|
79
|
+
f"InterDocker(host={self.host}, command={self.command}, image={self.image})"
|
|
80
|
+
)
|