From 76dbf33dc6e3efba9fd348b51d8f38173c7d6ea4 Mon Sep 17 00:00:00 2001 From: mliner Date: Mon, 19 Jul 2021 11:42:53 +0200 Subject: [PATCH 1/5] Update package.py Fixed adding root/.ssh folder into docker command only when ssh_agent is enabled --- package.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.py b/package.py index 98613118..d3e5b897 100644 --- a/package.py +++ b/package.py @@ -960,12 +960,12 @@ def docker_run_command(build_root, command, runtime, docker_cmd.extend(['-v', "{}:/var/task:z".format(bind_path)]) home = os.environ['HOME'] - docker_cmd.extend([ - # '-v', '{}/.ssh/id_rsa:/root/.ssh/id_rsa:z'.format(home), - '-v', '{}/.ssh/known_hosts:/root/.ssh/known_hosts:z'.format(home), - ]) if ssh_agent: + docker_cmd.extend([ + # '-v', '{}/.ssh/id_rsa:/root/.ssh/id_rsa:z'.format(home), + '-v', '{}/.ssh/known_hosts:/root/.ssh/known_hosts:z'.format(home), + ]) if platform.system() == 'Darwin': # https://docs.docker.com/docker-for-mac/osxfs/#ssh-agent-forwarding docker_cmd.extend([ From ba59edaa1d224cfacad1d412f761f0f67f49599e Mon Sep 17 00:00:00 2001 From: Matej Liner Date: Thu, 22 Jul 2021 11:16:56 +0200 Subject: [PATCH 2/5] fix: added build-root for docker pacakging --- package.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.py b/package.py index d3e5b897..ffa8ef23 100644 --- a/package.py +++ b/package.py @@ -118,10 +118,10 @@ def cd(path, silent=False): @contextmanager -def tempdir(): +def tempdir(dir=None): """Creates a temporary directory and then deletes it afterwards.""" prefix = 'terraform-aws-lambda-' - path = tempfile.mkdtemp(prefix=prefix) + path = tempfile.mkdtemp(prefix=prefix,dir=dir) cmd_log.info('mktemp -d %sXXXXXXXX # %s', prefix, shlex.quote(path)) try: yield path @@ -849,7 +849,7 @@ def install_pip_requirements(query, requirements_file): working_dir = os.getcwd() log.info('Installing python requirements: %s', requirements_file) - with tempdir() as temp_dir: + with tempdir(dir=docker_build_root) as temp_dir: requirements_filename = os.path.basename(requirements_file) target_file = os.path.join(temp_dir, requirements_filename) shutil.copyfile(requirements_file, target_file) From bd202a91f94bd632261d19e13aa124bcec2a96a4 Mon Sep 17 00:00:00 2001 From: Matej Liner Date: Thu, 22 Jul 2021 11:41:03 +0200 Subject: [PATCH 3/5] fix: another round --- package.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.py b/package.py index ffa8ef23..738532c7 100644 --- a/package.py +++ b/package.py @@ -893,7 +893,7 @@ def install_pip_requirements(query, requirements_file): chown_mask, '.'])] shell_command = [' '.join(shell_command)] check_call(docker_run_command( - '.', shell_command, runtime, + temp_dir, shell_command, runtime, image=docker_image_tag_id, shell=True, ssh_agent=with_ssh_agent, pip_cache_dir=pip_cache_dir, From 41ffd37e825701f133656112d10817e1b224ddc1 Mon Sep 17 00:00:00 2001 From: Matej Liner Date: Thu, 22 Jul 2021 12:14:27 +0200 Subject: [PATCH 4/5] fix: another fix --- package.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.py b/package.py index 738532c7..ffa8ef23 100644 --- a/package.py +++ b/package.py @@ -893,7 +893,7 @@ def install_pip_requirements(query, requirements_file): chown_mask, '.'])] shell_command = [' '.join(shell_command)] check_call(docker_run_command( - temp_dir, shell_command, runtime, + '.', shell_command, runtime, image=docker_image_tag_id, shell=True, ssh_agent=with_ssh_agent, pip_cache_dir=pip_cache_dir, From f1dc8322d08b3b7320c35aad98a580f0026a332b Mon Sep 17 00:00:00 2001 From: Matej Liner Date: Mon, 26 Jul 2021 21:37:36 +0200 Subject: [PATCH 5/5] Testing --- package.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.py b/package.py index ffa8ef23..e59bd2d5 100644 --- a/package.py +++ b/package.py @@ -852,6 +852,7 @@ def install_pip_requirements(query, requirements_file): with tempdir(dir=docker_build_root) as temp_dir: requirements_filename = os.path.basename(requirements_file) target_file = os.path.join(temp_dir, requirements_filename) + log.info('Copying %s to %s' % (requirements_filename, target_file)) shutil.copyfile(requirements_file, target_file) python_exec = runtime @@ -910,7 +911,7 @@ def install_pip_requirements(query, requirements_file): "available in system PATH".format(runtime) ) from e - os.remove(target_file) + # os.remove(target_file) yield temp_dir