Skip to content

Commit

Permalink
docs: add copy command examples and description (#5782)
Browse files Browse the repository at this point in the history
Signed-off-by: mao3267 <[email protected]>
  • Loading branch information
mao3267 authored Nov 5, 2024
1 parent d8afbcc commit 96c467e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/user_guide/customizing_dependencies/imagespec.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,26 @@ image_spec = ImageSpec(
)
```

## Copy additional files or directories
You can specify files or directories to be copied into the container `/root`, allowing users to access the required files. The directory structure will match the relative path. Since Docker only supports relative paths, absolute paths and paths outside the current working directory (e.g., paths with "../") are not allowed.

```py
from flytekit.image_spec import ImageSpec
from flytekit import task, workflow

image_spec = ImageSpec(
name="image_with_copy",
registry="localhost:30000",
builder="default",
copy=["files/input.txt"],
)

@task(container_image=image_spec)
def my_task() -> str:
with open("/root/files/input.txt", "r") as f:
return f.read()
```

## Define ImageSpec in a YAML File

You can override the container image by providing an ImageSpec YAML file to the `pyflyte run` or `pyflyte register` command.
Expand Down

0 comments on commit 96c467e

Please sign in to comment.