Skip to content

Commit

Permalink
fix(build): Fix image config (#651)
Browse files Browse the repository at this point in the history
Signed-off-by: Ce Gao <cegao@tensorchord.ai>
  • Loading branch information
gaocegege committed Jul 23, 2022
1 parent 4c1df28 commit 62091a4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
6 changes: 6 additions & 0 deletions examples/python-basic/build.envd
Original file line number Diff line number Diff line change
@@ -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",
])
8 changes: 8 additions & 0 deletions pkg/builder/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"

"github.com/cockroachdb/errors"
"github.com/moby/buildkit/exporter/containerimage/exptypes"
"github.com/moby/buildkit/frontend/gateway/client"
)

Expand All @@ -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(),
}
Expand All @@ -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
}
}
7 changes: 0 additions & 7 deletions pkg/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 62091a4

Please sign in to comment.