Skip to content

Commit 16e76b1

Browse files
committed
Update logic based on script_dir to determine if a base_docker_image
1 parent b4d2fba commit 16e76b1

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

src/xpk/core/docker_image.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,17 @@ def setup_docker_image(args) -> tuple[int, str]:
170170

171171
docker_image = args.docker_image
172172

173+
if (
174+
docker_image
175+
and args.base_docker_image
176+
and args.base_docker_image is not DEFAULT_DOCKER_IMAGE
177+
):
178+
xpk_print(
179+
'`--base-docker-image` and --docker-image can not be used together.'
180+
' Please see `--help` command for more details.'
181+
)
182+
xpk_exit(1)
183+
173184
if not docker_image and args.base_docker_image:
174185
docker_image = args.base_docker_image # fallback for legacy users
175186

@@ -183,27 +194,18 @@ def setup_docker_image(args) -> tuple[int, str]:
183194
re.match(prefix, docker_image) for prefix in CLOUD_PREFIXES
184195
)
185196

186-
if is_cloud_image:
187-
if args.script_dir is not DEFAULT_SCRIPT_DIR:
188-
xpk_print(
189-
'Error: `--script-dir` cannot be used with a cloud docker'
190-
' image.\nHint: If you need to customize the image with local'
191-
' scripts, use a local base image (e.g., `ubuntu:20.04`) instead of a'
192-
' prebuilt cloud image.'
193-
)
194-
xpk_exit(1)
195-
197+
if (
198+
args.script_dir and args.script_dir != DEFAULT_SCRIPT_DIR
199+
) or not is_cloud_image:
196200
validate_code = validate_docker_image(docker_image, args)
197201
if validate_code != 0:
198202
xpk_exit(validate_code)
199-
203+
build_code, docker_image = build_docker_image_from_base_image(args)
204+
if build_code != 0:
205+
xpk_exit(build_code)
200206
else:
201207
validate_code = validate_docker_image(docker_image, args)
202208
if validate_code != 0:
203209
xpk_exit(validate_code)
204210

205-
build_code, docker_image = build_docker_image_from_base_image(args)
206-
if build_code != 0:
207-
xpk_exit(build_code)
208-
209211
return 0, docker_image

0 commit comments

Comments
 (0)