Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion truss/base/truss_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,11 +541,19 @@ def _validate_path(cls, v: str) -> str:


class DockerServer(custom_types.ConfigModel):
start_command: str
start_command: Optional[str] = None
server_port: int
predict_endpoint: str
readiness_endpoint: str
liveness_endpoint: str
run_as_user_id: Optional[int] = None
as_is: Optional[bool] = None

@pydantic.model_validator(mode="after")
def _validate_start_command(self) -> "DockerServer":
if not self.as_is and self.start_command is None:
raise ValueError("start_command is required when as_is is not true")
return self


class TrainingArtifactReference(custom_types.ConfigModel):
Expand Down
17 changes: 16 additions & 1 deletion truss/contexts/image_builder/serving_image_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ def prepare_image_build_dir(
else:
self.prepare_trtllm_decoder_build_dir(build_dir=build_dir)

if config.docker_server is not None:
if config.docker_server is not None and config.docker_server.as_is is not True:
self._copy_into_build_dir(
TEMPLATES_DIR / "docker_server_requirements.txt",
build_dir,
Expand Down Expand Up @@ -750,6 +750,21 @@ def _render_dockerfile(
build_commands: List[str],
):
config = self._spec.config
ff_as_is = os.getenv("BT_AS_IS_DEPLOYMENT", False)
# Escape hatch for as-is deployments
if ff_as_is and config.docker_server and config.docker_server.as_is:
dockerfile_contents = f"FROM {config.base_image.image}"
# Add COPY for bptr-manifest if model_cache v2 is enabled
if config.model_cache and config.model_cache.is_v2:
if config.docker_server and config.docker_server.run_as_user_id:
user_id = config.docker_server.run_as_user_id
else:
user_id = 60000
dockerfile_contents += f"\nCOPY --chown={user_id}:{user_id} ./bptr-manifest /static-bptr/static-bptr-manifest.json"
docker_file_path = build_dir / MODEL_DOCKERFILE_NAME
docker_file_path.write_text(dockerfile_contents)
return

data_dir = build_dir / config.data_dir
model_dir = build_dir / config.model_module_dir
bundled_packages_dir = build_dir / config.bundled_packages_dir
Expand Down
Loading