arkitekt-next 0.16.0__py3-none-any.whl → 0.17.0__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/app/fakts.py +27 -1
- arkitekt_next/cli/commands/call/local.py +1 -1
- arkitekt_next/cli/commands/call/main.py +14 -7
- arkitekt_next/cli/templates/filter.py +7 -7
- arkitekt_next/cli/templates/simple.py +4 -1
- arkitekt_next/py.typed +0 -0
- {arkitekt_next-0.16.0.dist-info → arkitekt_next-0.17.0.dist-info}/METADATA +1 -1
- {arkitekt_next-0.16.0.dist-info → arkitekt_next-0.17.0.dist-info}/RECORD +11 -56
- arkitekt_next/__blok__.py +0 -58
- arkitekt_next/bloks/__init__.py +0 -1
- arkitekt_next/bloks/admin.py +0 -43
- arkitekt_next/bloks/alpaka.py +0 -139
- arkitekt_next/bloks/arkitekt.py +0 -55
- arkitekt_next/bloks/base.py +0 -217
- arkitekt_next/bloks/channel.py +0 -27
- arkitekt_next/bloks/config.py +0 -43
- arkitekt_next/bloks/elektro.py +0 -42
- arkitekt_next/bloks/fluss.py +0 -33
- arkitekt_next/bloks/gateway.py +0 -224
- arkitekt_next/bloks/internal_docker.py +0 -90
- arkitekt_next/bloks/kabinet.py +0 -46
- arkitekt_next/bloks/kraph.py +0 -45
- arkitekt_next/bloks/livekit.py +0 -85
- arkitekt_next/bloks/lok.py +0 -415
- arkitekt_next/bloks/lovekit.py +0 -202
- arkitekt_next/bloks/mikro.py +0 -42
- arkitekt_next/bloks/minio.py +0 -178
- arkitekt_next/bloks/mount.py +0 -34
- arkitekt_next/bloks/namegen.py +0 -34
- arkitekt_next/bloks/ollama.py +0 -90
- arkitekt_next/bloks/orkestrator.py +0 -122
- arkitekt_next/bloks/postgres.py +0 -134
- arkitekt_next/bloks/redis.py +0 -79
- arkitekt_next/bloks/rekuest.py +0 -30
- arkitekt_next/bloks/secret.py +0 -32
- arkitekt_next/bloks/self_signed.py +0 -91
- arkitekt_next/bloks/services/__init__.py +0 -27
- arkitekt_next/bloks/services/admin.py +0 -21
- arkitekt_next/bloks/services/certer.py +0 -14
- arkitekt_next/bloks/services/channel.py +0 -12
- arkitekt_next/bloks/services/config.py +0 -13
- arkitekt_next/bloks/services/db.py +0 -23
- arkitekt_next/bloks/services/gateway.py +0 -39
- arkitekt_next/bloks/services/livekit.py +0 -20
- arkitekt_next/bloks/services/lok.py +0 -24
- arkitekt_next/bloks/services/mount.py +0 -9
- arkitekt_next/bloks/services/name.py +0 -11
- arkitekt_next/bloks/services/ollama.py +0 -21
- arkitekt_next/bloks/services/redis.py +0 -19
- arkitekt_next/bloks/services/s3.py +0 -21
- arkitekt_next/bloks/services/secret.py +0 -16
- arkitekt_next/bloks/services/socket.py +0 -13
- arkitekt_next/bloks/socket.py +0 -40
- arkitekt_next/bloks/tailscale.py +0 -90
- {arkitekt_next-0.16.0.dist-info → arkitekt_next-0.17.0.dist-info}/WHEEL +0 -0
- {arkitekt_next-0.16.0.dist-info → arkitekt_next-0.17.0.dist-info}/entry_points.txt +0 -0
- {arkitekt_next-0.16.0.dist-info → arkitekt_next-0.17.0.dist-info}/licenses/LICENSE +0 -0
arkitekt_next/bloks/base.py
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
from arkitekt_next.bloks.services.channel import ChannelService
|
|
2
|
-
from blok import blok, InitContext, Option
|
|
3
|
-
from blok.tree import YamlFile, Repo
|
|
4
|
-
from typing import Any, Optional, Protocol
|
|
5
|
-
from blok.utils import check_protocol_compliance
|
|
6
|
-
from dataclasses import asdict
|
|
7
|
-
from arkitekt_next.bloks.services import (
|
|
8
|
-
GatewayService,
|
|
9
|
-
DBService,
|
|
10
|
-
RedisService,
|
|
11
|
-
S3Service,
|
|
12
|
-
ConfigService,
|
|
13
|
-
MountService,
|
|
14
|
-
AdminService,
|
|
15
|
-
SecretService,
|
|
16
|
-
LokService,
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
from blok.bloks.services.dns import DnsService
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class DefaultService(Protocol):
|
|
23
|
-
dev: bool
|
|
24
|
-
repo: str
|
|
25
|
-
command: str
|
|
26
|
-
service_name: str
|
|
27
|
-
host: str
|
|
28
|
-
buckets: list[str]
|
|
29
|
-
scopes: dict[str, str]
|
|
30
|
-
secret_key: str
|
|
31
|
-
mount_repo: bool
|
|
32
|
-
build_repo: bool
|
|
33
|
-
|
|
34
|
-
def get_blok_meta(self) -> str: ...
|
|
35
|
-
|
|
36
|
-
def get_builder(self) -> str: ...
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
def create_default_service_dependencies():
|
|
40
|
-
return [
|
|
41
|
-
DnsService,
|
|
42
|
-
GatewayService,
|
|
43
|
-
DBService,
|
|
44
|
-
RedisService,
|
|
45
|
-
S3Service,
|
|
46
|
-
ConfigService,
|
|
47
|
-
MountService,
|
|
48
|
-
AdminService,
|
|
49
|
-
SecretService,
|
|
50
|
-
LokService,
|
|
51
|
-
]
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
class BaseArkitektService:
|
|
55
|
-
def get_additional_config(self):
|
|
56
|
-
return {}
|
|
57
|
-
|
|
58
|
-
def preflight(
|
|
59
|
-
self,
|
|
60
|
-
init: InitContext,
|
|
61
|
-
lok: LokService,
|
|
62
|
-
db: DBService,
|
|
63
|
-
redis: RedisService,
|
|
64
|
-
s3: S3Service,
|
|
65
|
-
config: ConfigService,
|
|
66
|
-
mount: MountService,
|
|
67
|
-
admin: AdminService,
|
|
68
|
-
secret: SecretService,
|
|
69
|
-
gateway: GatewayService,
|
|
70
|
-
mount_repo: bool = False,
|
|
71
|
-
host: str = "",
|
|
72
|
-
image: str = "",
|
|
73
|
-
secret_key: str = "",
|
|
74
|
-
build_repo: bool = False,
|
|
75
|
-
command: str = "",
|
|
76
|
-
repo: str = "",
|
|
77
|
-
disable: bool = False,
|
|
78
|
-
dev: bool = False,
|
|
79
|
-
):
|
|
80
|
-
deps = init.dependencies
|
|
81
|
-
|
|
82
|
-
lok.register_scopes(self.scopes)
|
|
83
|
-
|
|
84
|
-
path_name = self.host
|
|
85
|
-
|
|
86
|
-
postgress_access = db.register_db(self.host)
|
|
87
|
-
redis_access = redis.register()
|
|
88
|
-
lok_access = lok.retrieve_credentials()
|
|
89
|
-
admin_access = admin.retrieve()
|
|
90
|
-
minio_access = s3.create_buckets(self.buckets)
|
|
91
|
-
|
|
92
|
-
self.service_identifier = self.get_blok_meta().service_identifier
|
|
93
|
-
|
|
94
|
-
gateway_path = gateway.expose_service(
|
|
95
|
-
path_name, 80, self.host, strip_prefix=False
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
lok_labels = lok.register_service_on_subpath(
|
|
99
|
-
self.service_identifier, gateway_path, "ht"
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
django_secret = secret.retrieve_secret()
|
|
103
|
-
|
|
104
|
-
csrf_trusted_origins = []
|
|
105
|
-
|
|
106
|
-
configuration = YamlFile(
|
|
107
|
-
**{
|
|
108
|
-
"db": asdict(postgress_access),
|
|
109
|
-
"django": {
|
|
110
|
-
"admin": asdict(admin_access),
|
|
111
|
-
"debug": True,
|
|
112
|
-
"hosts": ["*"],
|
|
113
|
-
"secret_key": django_secret,
|
|
114
|
-
},
|
|
115
|
-
"redis": asdict(redis_access),
|
|
116
|
-
"lok": asdict(lok_access),
|
|
117
|
-
"s3": asdict(minio_access),
|
|
118
|
-
"scopes": self.scopes,
|
|
119
|
-
"force_script_name": path_name,
|
|
120
|
-
"csrf_trusted_origins": csrf_trusted_origins,
|
|
121
|
-
**self.get_additional_config(),
|
|
122
|
-
}
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
config_mount = init.get_service(ConfigService).register_config(
|
|
126
|
-
f"{self.host}.yaml", configuration
|
|
127
|
-
)
|
|
128
|
-
|
|
129
|
-
depends_on = []
|
|
130
|
-
|
|
131
|
-
if redis_access.dependency:
|
|
132
|
-
depends_on.append(redis_access.dependency)
|
|
133
|
-
|
|
134
|
-
if postgress_access.dependency:
|
|
135
|
-
depends_on.append(postgress_access.dependency)
|
|
136
|
-
|
|
137
|
-
if minio_access.dependency:
|
|
138
|
-
depends_on.append(minio_access.dependency)
|
|
139
|
-
|
|
140
|
-
service = {
|
|
141
|
-
"volumes": [f"{config_mount}:/workspace/config.yaml"],
|
|
142
|
-
"depends_on": depends_on,
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if mount_repo or dev:
|
|
146
|
-
mount = init.get_service(MountService).register_mount(self.host, Repo(repo))
|
|
147
|
-
service["volumes"].extend([f"{mount}:/workspace"])
|
|
148
|
-
|
|
149
|
-
if build_repo or dev:
|
|
150
|
-
mount = init.get_service(MountService).register_mount(self.host, Repo(repo))
|
|
151
|
-
service["build"] = mount
|
|
152
|
-
else:
|
|
153
|
-
service["image"] = image
|
|
154
|
-
|
|
155
|
-
service["command"] = command
|
|
156
|
-
|
|
157
|
-
self.service = service
|
|
158
|
-
|
|
159
|
-
def get_additional_options(self):
|
|
160
|
-
return []
|
|
161
|
-
|
|
162
|
-
def get_options(self):
|
|
163
|
-
return [
|
|
164
|
-
Option(
|
|
165
|
-
subcommand="dev",
|
|
166
|
-
help="Shoud we run the service in development mode (includes withrepo, mountrepo)?",
|
|
167
|
-
default=self.dev,
|
|
168
|
-
),
|
|
169
|
-
Option(
|
|
170
|
-
subcommand="host",
|
|
171
|
-
help="The name we should use for the host?",
|
|
172
|
-
default=self.host,
|
|
173
|
-
),
|
|
174
|
-
Option(
|
|
175
|
-
subcommand="disable",
|
|
176
|
-
help="Shoud we disable the service?",
|
|
177
|
-
default=False,
|
|
178
|
-
),
|
|
179
|
-
Option(
|
|
180
|
-
subcommand="repo",
|
|
181
|
-
help="Which repo should we use when building the service? Only active if build_repo or mount_repo is active",
|
|
182
|
-
default=self.repo,
|
|
183
|
-
),
|
|
184
|
-
Option(
|
|
185
|
-
subcommand="command",
|
|
186
|
-
help="Which command should we use when building the service?",
|
|
187
|
-
default=self.command,
|
|
188
|
-
),
|
|
189
|
-
Option(
|
|
190
|
-
subcommand="mount_repo",
|
|
191
|
-
help="Should we mount the repo into the container?",
|
|
192
|
-
type=bool,
|
|
193
|
-
default=self.mount_repo,
|
|
194
|
-
),
|
|
195
|
-
Option(
|
|
196
|
-
subcommand="build_repo",
|
|
197
|
-
help="Should we build the container from the repo?",
|
|
198
|
-
type=bool,
|
|
199
|
-
default=self.build_repo,
|
|
200
|
-
),
|
|
201
|
-
Option(
|
|
202
|
-
subcommand="host",
|
|
203
|
-
help="How should the service be named inside the docker-compose file?",
|
|
204
|
-
default=self.host,
|
|
205
|
-
),
|
|
206
|
-
Option(
|
|
207
|
-
subcommand="secret_key",
|
|
208
|
-
help="The secret key to use for the django service",
|
|
209
|
-
default=self.secret_key,
|
|
210
|
-
),
|
|
211
|
-
Option(
|
|
212
|
-
subcommand="image",
|
|
213
|
-
help="The image to use for the service",
|
|
214
|
-
default=self.image,
|
|
215
|
-
),
|
|
216
|
-
*self.get_additional_options(),
|
|
217
|
-
]
|
arkitekt_next/bloks/channel.py
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
from pydantic import BaseModel
|
|
2
|
-
from typing import Dict, Any
|
|
3
|
-
from blok import blok, InitContext, Option
|
|
4
|
-
from arkitekt_next.bloks.services.channel import ChannelService
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@blok(ChannelService, description="The current channel of the application")
|
|
8
|
-
class ChannelBlok:
|
|
9
|
-
def __init__(self) -> None:
|
|
10
|
-
self.name = "default"
|
|
11
|
-
|
|
12
|
-
def preflight(self, init: InitContext):
|
|
13
|
-
for key, value in init.kwargs.items():
|
|
14
|
-
setattr(self, key, value)
|
|
15
|
-
|
|
16
|
-
def retrieve(self):
|
|
17
|
-
return self.name
|
|
18
|
-
|
|
19
|
-
def get_options(self):
|
|
20
|
-
with_name = Option(
|
|
21
|
-
subcommand="name",
|
|
22
|
-
help="Which channel name to use",
|
|
23
|
-
default=self.name,
|
|
24
|
-
show_default=True,
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
return [with_name]
|
arkitekt_next/bloks/config.py
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
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
|
-
|
|
8
|
-
class AdminCredentials(BaseModel):
|
|
9
|
-
password: str
|
|
10
|
-
username: str
|
|
11
|
-
email: str
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@blok(ConfigService)
|
|
15
|
-
class ConfigBlok:
|
|
16
|
-
def __init__(self) -> None:
|
|
17
|
-
self.config_path = "configs"
|
|
18
|
-
self.registered_configs = {}
|
|
19
|
-
|
|
20
|
-
def preflight(self, init: InitContext):
|
|
21
|
-
for key, value in init.kwargs.items():
|
|
22
|
-
setattr(self, key, value)
|
|
23
|
-
|
|
24
|
-
def build(self, ex: ExecutionContext):
|
|
25
|
-
for name, file in self.registered_configs.items():
|
|
26
|
-
ex.file_tree.set_nested(*f"{self.config_path}/{name}".split("/"), file)
|
|
27
|
-
|
|
28
|
-
def register_config(self, name: str, file: YamlFile) -> str:
|
|
29
|
-
self.registered_configs[name] = file
|
|
30
|
-
return f"./{self.config_path}/" + name
|
|
31
|
-
|
|
32
|
-
def get_path(self, name: str) -> str:
|
|
33
|
-
return f"./{self.config_path}/" + name
|
|
34
|
-
|
|
35
|
-
def get_options(self):
|
|
36
|
-
config_path = Option(
|
|
37
|
-
subcommand="config_path",
|
|
38
|
-
help="Which path to use for configs",
|
|
39
|
-
default=self.config_path,
|
|
40
|
-
show_default=True,
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
return [config_path]
|
arkitekt_next/bloks/elektro.py
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import click
|
|
2
|
-
from pydantic import BaseModel
|
|
3
|
-
from typing import Dict, Any
|
|
4
|
-
import yaml
|
|
5
|
-
import secrets
|
|
6
|
-
from blok import blok, InitContext
|
|
7
|
-
|
|
8
|
-
from blok import blok, InitContext, ExecutionContext, Option
|
|
9
|
-
from blok.tree import YamlFile, Repo
|
|
10
|
-
from arkitekt_next.bloks.base import BaseArkitektService
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class AccessCredentials(BaseModel):
|
|
14
|
-
password: str
|
|
15
|
-
username: str
|
|
16
|
-
host: str
|
|
17
|
-
port: str
|
|
18
|
-
db_name: str
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
@blok("live.arkitekt.elektro", description="Mikro is the bio-image database for arkitekt")
|
|
22
|
-
class ElektroBlok(BaseArkitektService):
|
|
23
|
-
def __init__(self) -> None:
|
|
24
|
-
self.dev = False
|
|
25
|
-
self.host = "elektro"
|
|
26
|
-
self.command = "bash run-debug.sh"
|
|
27
|
-
self.repo = "https://github.com/jhnnsrs/elektro-server"
|
|
28
|
-
self.scopes = {
|
|
29
|
-
"mikro_read": "Read image from the database",
|
|
30
|
-
"mikro_write": "Write image to the database",
|
|
31
|
-
}
|
|
32
|
-
self.image = "jhnnsrs/elektro:nightly"
|
|
33
|
-
self.mount_repo = False
|
|
34
|
-
self.build_repo = False
|
|
35
|
-
self.buckets = ["media", "zarr", "parquet"]
|
|
36
|
-
self.secret_key = secrets.token_hex(16)
|
|
37
|
-
|
|
38
|
-
def get_builder(self):
|
|
39
|
-
return "arkitekt.generic"
|
|
40
|
-
|
|
41
|
-
def build(self, context: ExecutionContext):
|
|
42
|
-
context.docker_compose.set_nested("services", self.host, self.service)
|
arkitekt_next/bloks/fluss.py
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import secrets
|
|
2
|
-
|
|
3
|
-
from blok import blok, InitContext, ExecutionContext, Option
|
|
4
|
-
from blok.tree import YamlFile, Repo
|
|
5
|
-
from arkitekt_next.bloks.base import BaseArkitektService
|
|
6
|
-
from typing import List
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
DEFAULT_ARKITEKT_URL = "http://localhost:8000"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@blok(
|
|
13
|
-
"live.arkitekt.fluss", description="A service for managing workflows and their data"
|
|
14
|
-
)
|
|
15
|
-
class FlussBlok(BaseArkitektService):
|
|
16
|
-
def __init__(self) -> None:
|
|
17
|
-
self.dev = False
|
|
18
|
-
self.host = "fluss"
|
|
19
|
-
self.command = "bash run-debug.sh"
|
|
20
|
-
self.image = "jhnnsrs/fluss_next:nightly"
|
|
21
|
-
self.repo = "https://github.com/jhnnsrs/fluss-server-next"
|
|
22
|
-
self.scopes = {"read_image": "Read image from the database"}
|
|
23
|
-
self.mount_repo = False
|
|
24
|
-
self.build_repo = False
|
|
25
|
-
self.buckets = ["media"]
|
|
26
|
-
self.secret_key = secrets.token_hex(16)
|
|
27
|
-
self.ensured_repos: List[str] = []
|
|
28
|
-
|
|
29
|
-
def get_builder(self):
|
|
30
|
-
return "arkitekt.generic"
|
|
31
|
-
|
|
32
|
-
def build(self, context: ExecutionContext):
|
|
33
|
-
context.docker_compose.set_nested("services", self.host, self.service)
|
arkitekt_next/bloks/gateway.py
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
from arkitekt_next.bloks.services.certer import CerterService
|
|
2
|
-
from arkitekt_next.bloks.services.name import NameService
|
|
3
|
-
from blok import blok, InitContext, ExecutionContext, Option
|
|
4
|
-
from blok.tree import YamlFile, Repo
|
|
5
|
-
from pydantic import BaseModel
|
|
6
|
-
from typing import Dict, Any, Optional
|
|
7
|
-
|
|
8
|
-
from blok import blok, InitContext
|
|
9
|
-
from blok.bloks.services.dns import DnsService
|
|
10
|
-
|
|
11
|
-
DEFAULT_PUBLIC_URLS = ["127.0.0.1"]
|
|
12
|
-
DEFAULT_PUBLIC_HOSTS = ["localhost"]
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class ExposedHost(BaseModel):
|
|
16
|
-
host: str
|
|
17
|
-
port: int
|
|
18
|
-
stip_prefix: bool = True
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class ExpostedToHost(BaseModel):
|
|
22
|
-
port: int
|
|
23
|
-
host: str
|
|
24
|
-
to: str
|
|
25
|
-
tls: bool = False
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
class ExposedPort(BaseModel):
|
|
29
|
-
port: int
|
|
30
|
-
host: str
|
|
31
|
-
tls: bool = False
|
|
32
|
-
to: int
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
@blok(
|
|
36
|
-
"live.arkitekt.gateway",
|
|
37
|
-
description="A gateway for exposing services on the host",
|
|
38
|
-
)
|
|
39
|
-
class CaddyBlok:
|
|
40
|
-
def __init__(self) -> None:
|
|
41
|
-
self.exposed_hosts = {}
|
|
42
|
-
self.exposed_to_hosts = {}
|
|
43
|
-
self.http_expose_default = None
|
|
44
|
-
self.exposed_ports = {}
|
|
45
|
-
self.with_certer = False
|
|
46
|
-
self.http_port = 80
|
|
47
|
-
self.https_port = 443
|
|
48
|
-
self.public_ips = DEFAULT_PUBLIC_URLS
|
|
49
|
-
self.public_hosts = DEFAULT_PUBLIC_HOSTS
|
|
50
|
-
self.cert_mount = None
|
|
51
|
-
self.depends_on = []
|
|
52
|
-
|
|
53
|
-
def get_internal_host(self):
|
|
54
|
-
return "caddy"
|
|
55
|
-
|
|
56
|
-
def get_https_port(self):
|
|
57
|
-
return 443
|
|
58
|
-
|
|
59
|
-
def get_http_port(self):
|
|
60
|
-
return 80
|
|
61
|
-
|
|
62
|
-
def retrieve_gateway_network(self):
|
|
63
|
-
return self.gateway_network
|
|
64
|
-
|
|
65
|
-
def preflight(
|
|
66
|
-
self,
|
|
67
|
-
init: InitContext,
|
|
68
|
-
name: NameService,
|
|
69
|
-
):
|
|
70
|
-
for key, value in init.kwargs.items():
|
|
71
|
-
setattr(self, key, value)
|
|
72
|
-
|
|
73
|
-
self.gateway_network = name.retrieve_name().replace("-", "_")
|
|
74
|
-
|
|
75
|
-
def build(
|
|
76
|
-
self,
|
|
77
|
-
context: ExecutionContext,
|
|
78
|
-
):
|
|
79
|
-
caddyfile = """
|
|
80
|
-
{
|
|
81
|
-
auto_https off
|
|
82
|
-
}
|
|
83
|
-
"""
|
|
84
|
-
|
|
85
|
-
for key, port in self.exposed_ports.items():
|
|
86
|
-
if port.tls:
|
|
87
|
-
caddyfile += f"""
|
|
88
|
-
:{port.port} {{
|
|
89
|
-
reverse_proxy {port.host}:{port.to}
|
|
90
|
-
}}
|
|
91
|
-
"""
|
|
92
|
-
else:
|
|
93
|
-
caddyfile += f"""
|
|
94
|
-
:{port.port} {{
|
|
95
|
-
reverse_proxy {port.host}:{port.to}
|
|
96
|
-
}}
|
|
97
|
-
"""
|
|
98
|
-
|
|
99
|
-
for protocol in ["http"]:
|
|
100
|
-
caddyfile += f"""
|
|
101
|
-
{protocol}:// {{
|
|
102
|
-
"""
|
|
103
|
-
caddyfile += (
|
|
104
|
-
"""
|
|
105
|
-
"""
|
|
106
|
-
if protocol == "https" and self.cert_mount
|
|
107
|
-
else ""
|
|
108
|
-
)
|
|
109
|
-
caddyfile += """
|
|
110
|
-
header {
|
|
111
|
-
-Server
|
|
112
|
-
X-Forwarded-Proto {scheme}
|
|
113
|
-
X-Forwarded-For {remote}
|
|
114
|
-
X-Forwarded-Port {server_port}
|
|
115
|
-
X-Forwarded-Host {host}
|
|
116
|
-
}
|
|
117
|
-
"""
|
|
118
|
-
|
|
119
|
-
for path_name, exposed_host in self.exposed_hosts.items():
|
|
120
|
-
if exposed_host.stip_prefix:
|
|
121
|
-
caddyfile += f"""
|
|
122
|
-
@{path_name} path /{path_name}*
|
|
123
|
-
handle @{path_name} {{
|
|
124
|
-
uri strip_prefix /{path_name}
|
|
125
|
-
reverse_proxy {exposed_host.host}:{exposed_host.port}
|
|
126
|
-
}}
|
|
127
|
-
"""
|
|
128
|
-
else:
|
|
129
|
-
caddyfile += f"""
|
|
130
|
-
@{path_name} path /{path_name}*
|
|
131
|
-
handle @{path_name} {{
|
|
132
|
-
reverse_proxy {exposed_host.host}:{exposed_host.port}
|
|
133
|
-
}}
|
|
134
|
-
"""
|
|
135
|
-
|
|
136
|
-
for path_name, exposed_to_host in self.exposed_to_hosts.items():
|
|
137
|
-
caddyfile += f"""
|
|
138
|
-
@{path_name} path /{path_name}*
|
|
139
|
-
handle @{path_name} {{
|
|
140
|
-
rewrite * /{exposed_to_host.to}{{uri}}
|
|
141
|
-
reverse_proxy {exposed_to_host.host}:{exposed_to_host.port}
|
|
142
|
-
}}
|
|
143
|
-
"""
|
|
144
|
-
|
|
145
|
-
if self.http_expose_default:
|
|
146
|
-
caddyfile += f"""
|
|
147
|
-
handle {{
|
|
148
|
-
reverse_proxy {self.http_expose_default.host}:{self.http_expose_default.port}
|
|
149
|
-
}}
|
|
150
|
-
"""
|
|
151
|
-
|
|
152
|
-
caddyfile += """
|
|
153
|
-
}
|
|
154
|
-
"""
|
|
155
|
-
|
|
156
|
-
context.file_tree.set_nested("configs", "Caddyfile", caddyfile)
|
|
157
|
-
|
|
158
|
-
caddy_depends_on = self.depends_on
|
|
159
|
-
|
|
160
|
-
exposed_ports_strings = [
|
|
161
|
-
f"{port.port}:{port.port}" for port in self.exposed_ports.values()
|
|
162
|
-
]
|
|
163
|
-
|
|
164
|
-
volumes = ["./configs/Caddyfile:/etc/caddy/Caddyfile"]
|
|
165
|
-
|
|
166
|
-
caddy_container = {
|
|
167
|
-
"image": "caddy:latest",
|
|
168
|
-
"ports": [
|
|
169
|
-
f"{self.http_port}:80",
|
|
170
|
-
]
|
|
171
|
-
+ exposed_ports_strings,
|
|
172
|
-
"volumes": volumes,
|
|
173
|
-
"networks": [self.gateway_network, "default"],
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
context.docker_compose.set_nested("services", "caddy", caddy_container)
|
|
177
|
-
|
|
178
|
-
context.docker_compose.set_nested(
|
|
179
|
-
"networks",
|
|
180
|
-
self.gateway_network,
|
|
181
|
-
{"driver": "bridge", "name": self.gateway_network},
|
|
182
|
-
)
|
|
183
|
-
|
|
184
|
-
def expose_service(
|
|
185
|
-
self, path_name: str, port: int, host: str, strip_prefix: bool = False
|
|
186
|
-
):
|
|
187
|
-
self.exposed_hosts[path_name] = ExposedHost(
|
|
188
|
-
host=host, port=port, stip_prefix=strip_prefix
|
|
189
|
-
)
|
|
190
|
-
return path_name
|
|
191
|
-
|
|
192
|
-
def expose_mapped(self, path_name: str, port: int, host: str, to: str):
|
|
193
|
-
self.exposed_to_hosts[path_name] = ExpostedToHost(host=host, port=port, to=to)
|
|
194
|
-
|
|
195
|
-
def expose_default(self, port: int, host: str):
|
|
196
|
-
self.http_expose_default = ExposedHost(host=host, port=port, stip_prefix=False)
|
|
197
|
-
|
|
198
|
-
def expose_port(self, port: int, host: str, tls: bool = False):
|
|
199
|
-
self.exposed_ports[port] = ExposedPort(port=port, host=host, tls=tls, to=port)
|
|
200
|
-
|
|
201
|
-
def expose_port_to(self, port: int, host: str, to_port: int, tls: bool = False):
|
|
202
|
-
self.exposed_ports[port] = ExposedPort(
|
|
203
|
-
port=port, host=host, tls=tls, to=to_port
|
|
204
|
-
)
|
|
205
|
-
|
|
206
|
-
def get_options(self):
|
|
207
|
-
with_public_urls = Option(
|
|
208
|
-
subcommand="public_url",
|
|
209
|
-
help="Which public urls to use",
|
|
210
|
-
type=str,
|
|
211
|
-
multiple=True,
|
|
212
|
-
default=DEFAULT_PUBLIC_URLS,
|
|
213
|
-
show_default=True,
|
|
214
|
-
)
|
|
215
|
-
with_public_services = Option(
|
|
216
|
-
subcommand="public_hosts",
|
|
217
|
-
help="Which public hosts to use",
|
|
218
|
-
type=str,
|
|
219
|
-
multiple=True,
|
|
220
|
-
default=DEFAULT_PUBLIC_HOSTS,
|
|
221
|
-
show_default=True,
|
|
222
|
-
)
|
|
223
|
-
|
|
224
|
-
return [with_public_urls, with_public_services]
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
from typing import Dict, Any
|
|
2
|
-
import secrets
|
|
3
|
-
|
|
4
|
-
from arkitekt_next.bloks.lok import LokBlok
|
|
5
|
-
from arkitekt_next.bloks.services.gateway import GatewayService
|
|
6
|
-
from arkitekt_next.bloks.socket import DockerSocketBlok
|
|
7
|
-
from blok import blok, InitContext, ExecutionContext, Option
|
|
8
|
-
from blok.bloks.services.dns import DnsService
|
|
9
|
-
from blok.tree import YamlFile, Repo
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@blok(
|
|
13
|
-
"live.arkitekt.internal_engine",
|
|
14
|
-
description="An Arkitekt plugin engine running inside a docker container",
|
|
15
|
-
)
|
|
16
|
-
class InternalDockerBlok:
|
|
17
|
-
def __init__(self) -> None:
|
|
18
|
-
self.host = "deployer"
|
|
19
|
-
|
|
20
|
-
self.image = "jhnnsrs/deployer:nightly"
|
|
21
|
-
self.instance_id = "INTERNAL_DOCKER"
|
|
22
|
-
|
|
23
|
-
def preflight(
|
|
24
|
-
self,
|
|
25
|
-
init: InitContext,
|
|
26
|
-
gateway: GatewayService,
|
|
27
|
-
lok: LokBlok,
|
|
28
|
-
socket: DockerSocketBlok,
|
|
29
|
-
):
|
|
30
|
-
for key, value in init.kwargs.items():
|
|
31
|
-
setattr(self, key, value)
|
|
32
|
-
|
|
33
|
-
deps = init.dependencies
|
|
34
|
-
|
|
35
|
-
self._socket = socket.register_socket(self.host)
|
|
36
|
-
self.gateway_host = gateway.get_internal_host()
|
|
37
|
-
self.gateway_port = gateway.get_http_port()
|
|
38
|
-
|
|
39
|
-
self.token = lok.retrieve_token()
|
|
40
|
-
|
|
41
|
-
self.gateway_network = gateway.retrieve_gateway_network()
|
|
42
|
-
|
|
43
|
-
self.command = f"arkitekt-next run prod --redeem-token={self.token} --url http://{self.gateway_host}:{self.gateway_port}"
|
|
44
|
-
|
|
45
|
-
self.initialized = True
|
|
46
|
-
|
|
47
|
-
def build(self, context: ExecutionContext):
|
|
48
|
-
db_service = {
|
|
49
|
-
"image": self.image,
|
|
50
|
-
"command": self.command,
|
|
51
|
-
"volumes": [f"{self._socket}:/var/run/docker.sock"],
|
|
52
|
-
"environment": {
|
|
53
|
-
"INSTANCE_ID": self.instance_id,
|
|
54
|
-
"ARKITEKT_GATEWAY": f"http://{self.gateway_host}:{self.gateway_port}",
|
|
55
|
-
"ARKITEKT_NETWORK": self.gateway_network,
|
|
56
|
-
},
|
|
57
|
-
"deploy": {
|
|
58
|
-
"restart_policy": {
|
|
59
|
-
"condition": "on-failure",
|
|
60
|
-
"delay": "10s",
|
|
61
|
-
"max_attempts": 10,
|
|
62
|
-
"window": "300s",
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
context.docker_compose.set_nested("services", self.host, db_service)
|
|
68
|
-
|
|
69
|
-
def get_options(self):
|
|
70
|
-
with_host = Option(
|
|
71
|
-
subcommand="host",
|
|
72
|
-
help="The host of this service",
|
|
73
|
-
default=self.host,
|
|
74
|
-
)
|
|
75
|
-
with_skip = Option(
|
|
76
|
-
subcommand="skip",
|
|
77
|
-
help="Should we skip creating this service?",
|
|
78
|
-
default=False,
|
|
79
|
-
type=bool,
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
return [
|
|
83
|
-
with_host,
|
|
84
|
-
with_skip,
|
|
85
|
-
]
|
|
86
|
-
|
|
87
|
-
def __str__(self) -> str:
|
|
88
|
-
return (
|
|
89
|
-
f"InterDocker(host={self.host}, command={self.command}, image={self.image})"
|
|
90
|
-
)
|