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

Docker image tweaks #230

Closed
wants to merge 2 commits into from
Closed
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
6 changes: 3 additions & 3 deletions Dockerfile.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:${python_version}-slim as base
FROM python:${python_version}-alpine as base

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suprisingly enough, alpine switch "just works"; seems all binary dependencies do have musl wheel

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suprisingly enough, alpine switch "just works"; seems all binary dependencies do have musl wheel

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using builder stage did not help save any disk space and was troublesome to get working - you have to be really careful what you want to copy, which makes Dockerfile significantly more complex.

We probably could do our custom python-base imagine, but I don't see that paying off as we don't even know how many MBs we can save that way.
If we ever start using standalone binary in these images instead, we are likely to see better results than optimizing python install.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok but the builder stage wasn't there when you started working on the thing, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was no builder stage

LABEL vendor=${vendor}
LABEL name="${name}"
Expand All @@ -11,8 +11,8 @@ LABEL build-date-iso8601="${build_date}"

WORKDIR /root

COPY ${tar_path}/${tar_name} .
RUN ["pip", "install", "${tar_name}[full]"]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~170kB; but perhaps more imortant it looked weird to just have that tar left in there

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~170kB; but perhaps more imortant it looked weird to just have that tar left in there

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~170kB; but perhaps more imortant it looked weird to just have that tar left in there

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~170kB; but perhaps more imortant it looked weird to just have that tar left in there

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~170kB; but perhaps more imortant it looked weird to just have that tar left in there

RUN --mount=type=bind,source=${tar_path}/${tar_name},target=/tmp/${tar_name} \
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--no-cache-dir saves ~6MB

pip install --no-cache-dir /tmp/${tar_name}[full]

ENTRYPOINT ["b2"]
CMD ["--help"]
1 change: 1 addition & 0 deletions changelog.d/+docker_optimization.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce docker image size, from 170MB to 87MB by using alpine and other build optimizations
Loading