-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This changes some things in the mariner2 target so we can share as much as makes sense for azlinux3. Note: mariner was renamed to azure linux, hence mariner2 -> azlinux3. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
- Loading branch information
Showing
10 changed files
with
246 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package azlinux | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"path/filepath" | ||
|
||
"github.com/Azure/dalec" | ||
"github.com/moby/buildkit/client/llb" | ||
"github.com/moby/buildkit/client/llb/sourceresolver" | ||
gwclient "github.com/moby/buildkit/frontend/gateway/client" | ||
) | ||
|
||
const ( | ||
AzLinux3TargetKey = "azlinux3" | ||
tdnfCacheNameAzlinux3 = "azlinux3-tdnf-cache" | ||
|
||
azlinux3Ref = "azurelinuxpreview.azurecr.io/public/azurelinux/base/core:3.0" | ||
azlinux3DistrolessRef = "azurelinuxpreview.azurecr.io/public/azurelinux/distroless/base:3.0" | ||
) | ||
|
||
func NewAzlinux3Handler() gwclient.BuildFunc { | ||
return newHandler(azlinux3{}) | ||
} | ||
|
||
type azlinux3 struct{} | ||
|
||
func (w azlinux3) Base(client gwclient.Client, opts ...llb.ConstraintsOpt) llb.State { | ||
return llb.Image(azlinux3Ref, llb.WithMetaResolver(client), dalec.WithConstraints(opts...)).Run( | ||
w.Install([]string{"rpm-build", "mariner-rpm-macros", "build-essential"}), | ||
).Root() | ||
} | ||
|
||
func (w azlinux3) Install(pkgs []string, opts ...installOpt) llb.RunOption { | ||
var cfg installConfig | ||
setInstallOptions(&cfg, opts) | ||
return dalec.WithRunOptions(tdnfInstall(&cfg, "3.0", pkgs), w.tdnfCacheMount(cfg.root)) | ||
} | ||
|
||
func (azlinux3) DefaultImageConfig(ctx context.Context, client gwclient.Client) (*dalec.DockerImageSpec, error) { | ||
_, _, dt, err := client.ResolveImageConfig(ctx, azlinux3DistrolessRef, sourceresolver.Opt{}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var cfg dalec.DockerImageSpec | ||
if err := json.Unmarshal(dt, &cfg); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &cfg, nil | ||
} | ||
|
||
func (azlinux3) tdnfCacheMount(root string) llb.RunOption { | ||
return llb.AddMount(filepath.Join(root, tdnfCacheDir), llb.Scratch(), llb.AsPersistentCacheDir(tdnfCacheNameAzlinux3, llb.CacheMountLocked)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.