diff --git a/examples/python-basic/build.envd b/examples/python-basic/build.envd new file mode 100644 index 000000000..3937935f2 --- /dev/null +++ b/examples/python-basic/build.envd @@ -0,0 +1,6 @@ +def build(): + base(os="ubuntu20.04", language="python3") + #config.pip_index(url = "https://pypi.tuna.tsinghua.edu.cn/simple") + install.python_packages([ + "via", + ]) diff --git a/pkg/builder/build.go b/pkg/builder/build.go index 6e87f6efd..e9390c9fe 100644 --- a/pkg/builder/build.go +++ b/pkg/builder/build.go @@ -18,6 +18,7 @@ import ( "context" "github.com/cockroachdb/errors" + "github.com/moby/buildkit/exporter/containerimage/exptypes" "github.com/moby/buildkit/frontend/gateway/client" ) @@ -28,6 +29,11 @@ func (b generalBuilder) BuildFunc() func(ctx context.Context, c client.Client) ( return nil, errors.Wrap(err, "failed to compile") } + imageConfig, err := b.imageConfig(ctx) + if err != nil { + return nil, errors.Wrap(err, "failed to get labels") + } + sreq := client.SolveRequest{ Definition: def.ToPB(), } @@ -43,6 +49,8 @@ func (b generalBuilder) BuildFunc() func(ctx context.Context, c client.Client) ( return nil, err } + res.AddMeta(exptypes.ExporterImageConfigKey, []byte(imageConfig)) + return res, nil } } diff --git a/pkg/builder/builder.go b/pkg/builder/builder.go index 239c19e30..6a7541406 100644 --- a/pkg/builder/builder.go +++ b/pkg/builder/builder.go @@ -190,11 +190,6 @@ func (b generalBuilder) imageConfig(ctx context.Context) (string, error) { } func (b generalBuilder) build(ctx context.Context, pw progresswriter.Writer) error { - imageConfig, err := b.imageConfig(ctx) - if err != nil { - return errors.Wrap(err, "failed to get labels") - } - ce, err := ParseExportCache([]string{b.ExportCache}, nil) if err != nil { return errors.Wrap(err, "failed to parse export cache") @@ -222,8 +217,6 @@ func (b generalBuilder) build(ctx context.Context, pw progresswriter.Writer) err Type: client.ExporterDocker, Attrs: map[string]string{ "name": b.Tag, - // Ref https://github.com/r2d4/mockerfile/blob/140c6a912bbfdae220febe59ab535ef0acba0e1f/pkg/build/build.go#L65 - "containerimage.config": imageConfig, }, Output: func(map[string]string) (io.WriteCloser, error) { return pipeW, nil