@@ -358,10 +358,8 @@ def copy_into_build_dir(from_path: Path, path_in_build_dir: str):
358
358
)
359
359
360
360
# Copy base TrussServer requirements if supplied custom base image
361
+ base_truss_server_reqs_filepath = SERVER_CODE_DIR / REQUIREMENTS_TXT_FILENAME
361
362
if config .base_image :
362
- base_truss_server_reqs_filepath = (
363
- SERVER_CODE_DIR / REQUIREMENTS_TXT_FILENAME
364
- )
365
363
copy_into_build_dir (
366
364
base_truss_server_reqs_filepath , BASE_SERVER_REQUIREMENTS_TXT_FILENAME
367
365
)
@@ -374,7 +372,22 @@ def copy_into_build_dir(from_path: Path, path_in_build_dir: str):
374
372
if should_install_server_requirements :
375
373
copy_into_build_dir (server_reqs_filepath , SERVER_REQUIREMENTS_TXT_FILENAME )
376
374
377
- (build_dir / REQUIREMENTS_TXT_FILENAME ).write_text (spec .requirements_txt )
375
+ with open (base_truss_server_reqs_filepath , "r" ) as f :
376
+ base_server_requirements = f .read ()
377
+
378
+ # If the user has provided python requirements,
379
+ # append the truss server requirements, so that any conflicts
380
+ # are detected and cause a build failure. If there are no
381
+ # requirements provided, we just pass an empty string,
382
+ # as there's no need to install anything.
383
+ user_provided_python_requirements = (
384
+ base_server_requirements + spec .requirements_txt
385
+ if spec .requirements
386
+ else ""
387
+ )
388
+ (build_dir / REQUIREMENTS_TXT_FILENAME ).write_text (
389
+ user_provided_python_requirements
390
+ )
378
391
(build_dir / SYSTEM_PACKAGES_TXT_FILENAME ).write_text (spec .system_packages_txt )
379
392
380
393
self ._render_dockerfile (
0 commit comments