Skip to content

Commit

Permalink
Make sure worker images have gpg installed
Browse files Browse the repository at this point in the history
gpg is a pretty big dependency, so we don't implicitly install this as
part of the base worker image.
This makes sure that in the cases where we do need to setup keys that
gpg is actually installed.

There's probably some room for optimization here, but I'll leave that
for future work.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
  • Loading branch information
cpuguy83 committed Oct 31, 2024
1 parent 0a33896 commit 2360e0f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontend/azlinux/handle_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func specToContainerLLB(w worker, spec *dalec.Spec, targetKey string, rpmDir llb
}

installTimeRepos := spec.GetInstallRepos(targetKey)
importRepos, err := repoMountInstallOpts(builderImg, installTimeRepos, sOpt, opts...)
importRepos, err := repoMountInstallOpts(w, builderImg, installTimeRepos, sOpt, opts...)
if err != nil {
return llb.Scratch(), err
}
Expand Down
14 changes: 11 additions & 3 deletions frontend/azlinux/handle_rpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,15 @@ var azLinuxRepoConfig = dalec.RepoPlatformConfig{
GPGKeyRoot: "/etc/pki/rpm-gpg",
}

func repoMountInstallOpts(worker llb.State, repos []dalec.PackageRepositoryConfig, sOpt dalec.SourceOpts, opts ...llb.ConstraintsOpt) ([]installOpt, error) {
func repoMountInstallOpts(w worker, base llb.State, repos []dalec.PackageRepositoryConfig, sOpt dalec.SourceOpts, opts ...llb.ConstraintsOpt) ([]installOpt, error) {
worker := base.Run(
w.Install(
[]string{"gnupg2"},
installWithConstraints(opts),
),
dalec.WithConstraints(opts...),
).Root()

withRepos, err := dalec.WithRepoConfigs(repos, &azLinuxRepoConfig, sOpt, opts...)
if err != nil {
return nil, err
Expand All @@ -129,7 +137,7 @@ func withTestDeps(w worker, spec *dalec.Spec, sOpt dalec.SourceOpts, targetKey s
}

testRepos := spec.GetTestRepos(targetKey)
importRepos, err := repoMountInstallOpts(base, testRepos, sOpt, opts...)
importRepos, err := repoMountInstallOpts(w, base, testRepos, sOpt, opts...)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -207,7 +215,7 @@ func installBuildDeps(ctx context.Context, w worker, client gwclient.Client, spe
return nil, err
}

importRepos, err := repoMountInstallOpts(base, repos, sOpt, opts...)
importRepos, err := repoMountInstallOpts(w, base, repos, sOpt, opts...)
if err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions frontend/jammy/handle_deb.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ var jammyRepoPlatformCfg = dalec.RepoPlatformConfig{
}

func customRepoMounts(worker llb.State, repos []dalec.PackageRepositoryConfig, sOpt dalec.SourceOpts, opts ...llb.ConstraintsOpt) (llb.RunOption, error) {
worker = worker.Run(installPackages([]string{"gnupg2"}, opts...), dalec.WithConstraints(opts...)).Root() // make sure we have gpg installed
withRepos, err := dalec.WithRepoConfigs(repos, &jammyRepoPlatformCfg, sOpt, opts...)
if err != nil {
return nil, err
Expand Down
6 changes: 6 additions & 0 deletions frontend/windows/handle_zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ var jammyRepoPlatformCfg = dalec.RepoPlatformConfig{
}

func customRepoMounts(worker llb.State, repos []dalec.PackageRepositoryConfig, sOpt dalec.SourceOpts, opts ...llb.ConstraintsOpt) (llb.RunOption, error) {
worker = worker.Run(
dalec.ShArgs("apt update && apt install -y gnupg2"),
dalec.WithMountedAptCache(aptCachePrefix),
dalec.WithConstraints(opts...),
).Root() // make sure we have gpg installed

withRepos, err := dalec.WithRepoConfigs(repos, &jammyRepoPlatformCfg, sOpt, opts...)
if err != nil {
return nil, err
Expand Down

0 comments on commit 2360e0f

Please sign in to comment.