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

Improve execution of pip during container building #713

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion src/ansible_builder/containerfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ def prepare(self) -> None:
self.steps.append('RUN /output/scripts/pip_install $PYCMD')

if self.definition.ansible_ref_install_list:
self.steps.append('RUN $PYCMD -m pip install --no-cache-dir $ANSIBLE_INSTALL_REFS')
self.steps.append(
'RUN --mount=type=cache,dst=/root/.cache/pip $PYCMD -m pip install -q $ANSIBLE_INSTALL_REFS')
Copy link
Contributor

Choose a reason for hiding this comment

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

Using -q hides some install info that could be useful in debugging user issues. I'd prefer to not use this.

I did notice that it did subtract about 1.5 seconds on a very simple build, and the resulting image sizes did not seem to change by any significant amount.


self._insert_custom_steps('append_base')

Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_containerfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def test_v3_various(build_dir_and_ee_yml):
assert "RUN $PYCMD -m pip install --no-cache-dir 'dumb-init==x.y.z'" in c.steps
assert "USER myuser" in c.steps
assert "RUN $PKGMGR install $PYPKG -y ; if [ -z $PKGMGR_PRESERVE_CACHE ]; then $PKGMGR clean all; fi" in c.steps
assert "RUN $PYCMD -m pip install --no-cache-dir $ANSIBLE_INSTALL_REFS" in c.steps
assert "RUN --mount=type=cache,dst=/root/.cache/pip $PYCMD -m pip install -q $ANSIBLE_INSTALL_REFS" in c.steps
assert 'ENTRYPOINT ["dumb-init"]' in c.steps
assert 'CMD ["csh"]' in c.steps

Expand Down
Loading