From 3ba1f826a1eafda4e106be7124a3178c5ce18280 Mon Sep 17 00:00:00 2001 From: Shailesh Pant Date: Mon, 11 Nov 2024 22:11:24 +0530 Subject: [PATCH] - Add docstring to facilitate doc generation for `fx workspace dockerize` command - Rebased - 18/Nov/2024 - Updated as per latest code and comments Signed-off-by: Shailesh Pant --- openfl/interface/workspace.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/openfl/interface/workspace.py b/openfl/interface/workspace.py index b138ad67db..6849ba0634 100644 --- a/openfl/interface/workspace.py +++ b/openfl/interface/workspace.py @@ -413,8 +413,38 @@ def export_() -> str: ) @pass_context def dockerize_(context, save: bool, rebuild: bool, enclave_key: str, revision: str): - """Package current workspace as a TEE-ready Docker image.""" + """ + Package the current workspace as a Trusted Execution Environment (TEE)-ready Docker image. + + This command exports the current workspace, builds an OpenFL base Docker image, + constructs the workspace Docker image, and optionally saves the workspace image as a tarball file. + + Args: + context: The Click context object, representing the current command-line invocation context. + save (bool): If True, exports the Docker image as a `.tar` file. + rebuild (bool): If True, rebuilds Docker images with the `--no-cache` option for a clean build. + enclave_key (str): Path to an enclave signing key. If not provided, a new key is auto-generated + within the workspace. Note that the key is not packaged with the image, allowing flexibility + to run without TEE later. + revision (str): Specifies the version of OpenFL source code to use when building the base Docker + image. Format: `@`. If not specified, the default value + in the `Dockerfile.base` is used, typically the latest stable release. + + Steps Performed: + 1. Exports the current workspace as an archive. + 2. Builds the OpenFL base Docker image using the specified or default revision. + 3. Builds the workspace Docker image, incorporating the exported workspace and signing key. + 4. Optionally saves the workspace Docker image as a `.tar` file. + Raises: + FileNotFoundError: If the provided enclave key path does not exist. + RuntimeError: If any Docker commands fail during the build or export process. + + Notes: + - If no enclave key is provided, a new one is generated using OpenSSL and saved in the workspace. + - The generated image is compatible with TEE environments but can be used outside of TEE if needed. + - Docker BuildKit is utilized for efficient and secure image builds. + """ # Docker build options options = [] options.append("--no-cache" if rebuild else "")