<#3284 Support recursive `ImageSpec` build by `Def...
# flyte-github
c
#3284 Support recursive
ImageSpec
build by
DefaultBuilder
Pull request opened by amitani ## Tracking issue None ## Why are the changes needed?
ImageBuildEngine
supports recursively build
ImageSpec
if
base_image
is also an
ImageSpec
. flytekit/flytekit/image_spec/image_spec.py Line 523 in</flyteorg/flytekit/commit/147c405d11abb222f88933d5ef3ed258df92ba99|147c405> | if isinstance(spec.base_image, ImageSpec): | | ------------------------------------------ | However, it doesn't work with current
DefaultBuilder
. This PR includes a few minor changes so that such recursive build works. ## What changes were proposed in this pull request? 1.
micromamba create
falls back to
micromamba install
in case the micromamba environment already exists. 2. Set workdir to
/
to have consistent behavior in the second build. Otherwise, workdir is set to
/root
in the first build, and
uv run
itself uses
/root/.venv
instead of
UV_PYTHON
(if uv lock or poetry lock was used). 3. When there are
/root/.venv
from the first build (if uv lock or poetry lock was used),
chown -R flytekit /root
creates a duplicated layer, nearly doubling the size of the final image. ## How was this patch tested? A small example was added, which can be run
Copy code
_FLYTEKIT_TEST_IMAGE_BUILD_ENGINE=1 python -m pytest tests/flytekit/unit/core/image_spec/test_image_spec.py -k test_nested_build -s
### Setup process ### Screenshots ## Check all the applicable boxes • I updated the documentation accordingly. • All new and existing tests passed. • All commits are signed-off. ## Related PRs ## Docs link https://bito.ai#summarystart| ### Summary by Bito This pull request enhances the
DefaultBuilder
to support recursive builds of
ImageSpec
, optimizes the ownership change process, and sets the working directory to root for consistency. A test case for nested builds has also been introduced to ensure functionality. flyteorg/flytekit