Skip to content

Commit 0e2147f

Browse files
Getting Dockerfile.dependencies from parent of payload folder
1 parent 23604b2 commit 0e2147f

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/datacustomcode/deploy.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ def create_deployment(
240240
def prepare_dependency_archive(
241241
directory: str, docker_network: str, package_type: str
242242
) -> None:
243+
# The parent directory of 'directory' contains Dockerfile.dependencies,
244+
# requirements.txt, and build_native_dependencies.sh
245+
# (same location checked by has_nonempty_requirements_file)
246+
parent_dir = os.path.dirname(directory)
247+
243248
cmd = f"docker images -q {DOCKER_IMAGE_NAME}"
244249
image_exists = cmd_output(cmd)
245250

@@ -248,7 +253,8 @@ def prepare_dependency_archive(
248253
if not image_exists:
249254
logger.info(f"Building docker image with docker network: {docker_network}...")
250255
cmd = docker_build_cmd(docker_network)
251-
cmd_output(cmd, env=docker_env)
256+
# Run docker build from parent_dir where Dockerfile.dependencies exists
257+
cmd_output(cmd, env=docker_env, cwd=parent_dir)
252258

253259
# ignore_cleanup_errors=True: on Windows, Docker creates files inside the
254260
# mounted volume whose permissions prevent the host from deleting them.
@@ -258,10 +264,12 @@ def prepare_dependency_archive(
258264
logger.info(
259265
f"Building dependencies archive with docker network: {docker_network}"
260266
)
261-
shutil.copy("requirements.txt", temp_dir)
262-
shutil.copy("build_native_dependencies.sh", temp_dir)
267+
# Copy from parent_dir where files actually exist
268+
shutil.copy(os.path.join(parent_dir, "requirements.txt"), temp_dir)
269+
shutil.copy(os.path.join(parent_dir, "build_native_dependencies.sh"), temp_dir)
263270
cmd = docker_run_cmd(docker_network, temp_dir)
264-
cmd_output(cmd, env=docker_env)
271+
# Run docker run from parent_dir for consistency
272+
cmd_output(cmd, env=docker_env, cwd=parent_dir)
265273
if package_type == "function":
266274
source_py_files = os.path.join(temp_dir, "py-files")
267275
if os.path.exists(source_py_files):

0 commit comments

Comments
 (0)