from dagger import dag, function, object_type
@object_type
class RayInference:
@function
def build_env(self, source: dagger.Directory) -> dagger.Container:
return (
dag.container()
.from_("python:3.11.9-bullseye")
.with_exec(["pip", "uninstall", "-y", "virtualenv"])
.with_exec(
[
"curl",
"-sSL",
"https://install.python-poetry.org",
"-o",
"install-poetry.py",
]
)
.with_exec(["python3", "install-poetry.py"])
.with_env_variable("PATH", "/root/.local/bin:$PATH")
.with_exec(["poetry", "config", "virtualenvs.create", "false"])
.with_directory("/src", source, exclude=[".venv", ".ruff_cache"])
.with_workdir("/src")
.with_mounted_cache("/root/.cache/pypoetry", dag.cache_volume("pypoetry"))
.with_exec(["poetry", "install", "--no-root", "--without", "dev", "-vvv"])
.with_entrypoint(["python", "/src/main.py"])
)
@function
def build_all_services(self) -> list[dagger.Container]:
service_paths = ["services/cdc-sink", "services/ingest"]
service_dirs = [DIRECTORY(path) for path in service_paths]
return [self.build_env(service_dir) for service_dir in service_dirs]