@@ -170,6 +170,13 @@ def setup_docker_image(args) -> tuple[int, str]:
170170
171171 docker_image = args .docker_image
172172
173+ if docker_image and args .base_docker_image and args .base_docker_image is not DEFAULT_DOCKER_IMAGE :
174+ xpk_print (
175+ '`--base-docker-image` and --docker-image can not be used together.'
176+ ' Please see `--help` command for more details.'
177+ )
178+ xpk_exit (1 )
179+
173180 if not docker_image and args .base_docker_image :
174181 docker_image = args .base_docker_image # fallback for legacy users
175182
@@ -183,27 +190,16 @@ def setup_docker_image(args) -> tuple[int, str]:
183190 re .match (prefix , docker_image ) for prefix in CLOUD_PREFIXES
184191 )
185192
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.\n Hint: 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-
193+ if (args .script_dir and args .script_dir != DEFAULT_SCRIPT_DIR ) or not is_cloud_image :
196194 validate_code = validate_docker_image (docker_image , args )
197195 if validate_code != 0 :
198196 xpk_exit (validate_code )
199-
197+ build_code , docker_image = build_docker_image_from_base_image (args )
198+ if build_code != 0 :
199+ xpk_exit (build_code )
200200 else :
201201 validate_code = validate_docker_image (docker_image , args )
202202 if validate_code != 0 :
203203 xpk_exit (validate_code )
204204
205- build_code , docker_image = build_docker_image_from_base_image (args )
206- if build_code != 0 :
207- xpk_exit (build_code )
208-
209205 return 0 , docker_image
0 commit comments