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

Speed up local layer builds by skipping unnecessary compression of docker context #862

Merged
merged 4 commits into from
Jan 18, 2019
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion samcli/lib/utils/tar.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def create_tarball(tar_paths):
"""
tarballfile = TemporaryFile()

with tarfile.open(fileobj=tarballfile, mode='w:gz') as archive:
with tarfile.open(fileobj=tarballfile, mode='w') as archive:
for path_on_system, path_in_tarball in tar_paths.items():
archive.add(path_on_system, arcname=path_in_tarball)

Expand Down
1 change: 0 additions & 1 deletion samcli/local/docker/lambda_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ def _build_image(self, base_image, docker_tag, layers):
self.docker_client.images.build(fileobj=tarballfile,
custom_context=True,
rm=True,
encoding='gzip',
tag=docker_tag,
pull=not self.skip_pull_image)
except (docker.errors.BuildError, docker.errors.APIError):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib/utils/test_tar.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ def test_generating_tarball(self, temporary_file_patch, tarfile_open_patch):
temp_file_mock.flush.assert_called_once()
temp_file_mock.seek.assert_called_once_with(0)
temp_file_mock.close.assert_called_once()
tarfile_open_patch.assert_called_once_with(fileobj=temp_file_mock, mode='w:gz')
tarfile_open_patch.assert_called_once_with(fileobj=temp_file_mock, mode='w')
9 changes: 3 additions & 6 deletions tests/unit/local/docker/test_lambda_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ def test_build_image(self, generate_dockerfile_patch, path_patch, uuid_patch, cr
rm=True,
tag="docker_tag",
pull=False,
custom_context=True,
encoding='gzip')
custom_context=True)

docker_full_path_mock.unlink.assert_called_once()

Expand Down Expand Up @@ -218,8 +217,7 @@ def test_build_image_fails_with_BuildError(self,
rm=True,
tag="docker_tag",
pull=False,
custom_context=True,
encoding='gzip')
custom_context=True)

docker_full_path_mock.unlink.assert_not_called()

Expand Down Expand Up @@ -264,6 +262,5 @@ def test_build_image_fails_with_ApiError(self,
rm=True,
tag="docker_tag",
pull=False,
custom_context=True,
encoding='gzip')
custom_context=True)
docker_full_path_mock.unlink.assert_called_once()