Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update package.py - fixed docker volume #183

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -868,9 +868,10 @@ 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)
log.info('Copying %s to %s' % (requirements_filename, target_file))
shutil.copyfile(requirements_file, target_file)

python_exec = runtime
Expand Down Expand Up @@ -929,7 +930,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


Expand Down Expand Up @@ -979,12 +980,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([
Expand Down