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

proposal: Dnf cache between containers #526

Open
wants to merge 2 commits into
base: main
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
2 changes: 2 additions & 0 deletions images/fedora/f28/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ RUN rm /extra-packages

RUN dnf clean all

RUN echo 'keepcache=True' >> /etc/dnf/dnf.conf

CMD /bin/sh
2 changes: 2 additions & 0 deletions images/fedora/f29/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ RUN rm /extra-packages

RUN dnf clean all

RUN echo 'keepcache=True' >> /etc/dnf/dnf.conf

CMD /bin/sh
2 changes: 2 additions & 0 deletions images/fedora/f30/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ RUN rm /extra-packages

RUN dnf clean all

RUN echo 'keepcache=True' >> /etc/dnf/dnf.conf

CMD /bin/sh
2 changes: 2 additions & 0 deletions images/fedora/f31/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ RUN rm /extra-packages

RUN dnf clean all

RUN echo 'keepcache=True' >> /etc/dnf/dnf.conf

CMD /bin/sh
2 changes: 2 additions & 0 deletions images/fedora/f32/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ RUN rm /extra-packages

RUN dnf clean all

RUN echo 'keepcache=True' >> /etc/dnf/dnf.conf

CMD /bin/sh
2 changes: 2 additions & 0 deletions images/fedora/f33/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ RUN rm /extra-packages

RUN dnf clean all

RUN echo 'keepcache=True' >> /etc/dnf/dnf.conf

CMD /bin/sh
21 changes: 21 additions & 0 deletions src/cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,26 @@ func createContainer(container, image, release string, showCommandToEnter bool)
runMediaMount = []string{"--volume", "/run/media:/run/media:rslave"}
}

logrus.Debug("Creating the dnf cache")
var dnfCacheMount []string

cacheDir, err := os.UserCacheDir()
if err != nil {
return fmt.Errorf("failed to get the user cache directory")
}

dnfCacheDir := cacheDir + "/toolbox/" + release
logrus.Debugf("Toolbox cache directory is %s", dnfCacheDir)

if !utils.PathExists(dnfCacheDir) {
err = os.MkdirAll(dnfCacheDir, 0775)
if err != nil {
return fmt.Errorf("failed to create cache directory")
}
}

dnfCacheMount = []string{"--volume", dnfCacheDir + ":/var/cache/dnf/:rslave"}

logrus.Debug("Looking for toolbox.sh")

var toolboxShMount []string
Expand Down Expand Up @@ -375,6 +395,7 @@ func createContainer(container, image, release string, showCommandToEnter bool)
createArgs = append(createArgs, mntMount...)
createArgs = append(createArgs, runMediaMount...)
createArgs = append(createArgs, toolboxShMount...)
createArgs = append(createArgs, dnfCacheMount...)

createArgs = append(createArgs, []string{
imageFull,
Expand Down