Skip to content

Commit

Permalink
fix: authentication for private base image (#1639)
Browse files Browse the repository at this point in the history
Signed-off-by: Keming <[email protected]>
  • Loading branch information
kemingy authored Jun 8, 2023
1 parent 1af61d3 commit edf21bf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/google/uuid v1.3.0
github.com/hashicorp/go-getter v1.7.1
github.com/mattn/go-isatty v0.0.19
github.com/moby/buildkit v0.11.4
github.com/moby/buildkit v0.11.6
github.com/moby/term v0.5.0
github.com/morikuni/aec v1.0.0
github.com/olekukonko/tablewriter v0.0.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,8 @@ github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZX
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/moby/buildkit v0.11.4 h1:mleVHr+n7HUD65QNUkgkT3d8muTzhYUoHE9FM3Ej05s=
github.com/moby/buildkit v0.11.4/go.mod h1:P5Qi041LvCfhkfYBHry+Rwoo3Wi6H971J2ggE+PcIoo=
github.com/moby/buildkit v0.11.6 h1:VYNdoKk5TVxN7k4RvZgdeM4GOyRvIi4Z8MXOY7xvyUs=
github.com/moby/buildkit v0.11.6/go.mod h1:GCqKfHhz+pddzfgaR7WmHVEE3nKKZMMDPpK8mh3ZLv4=
github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg=
github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc=
github.com/moby/patternmatcher v0.5.0 h1:YCZgJOeULcxLw1Q+sVR636pmS7sPEn1Qo2iAN6M7DBo=
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func New() EnvdApp {
&cli.StringFlag{
Name: flag.FlagBuildkitdImage,
Usage: "docker image to use for buildkitd",
Value: "docker.io/moby/buildkit:v0.10.3",
Value: "docker.io/moby/buildkit:v0.10.6",
Hidden: true,
},
&cli.StringFlag{
Expand Down
17 changes: 8 additions & 9 deletions pkg/lang/ir/v1/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

"github.com/cockroachdb/errors"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/client/llb/imagemetaresolver"
"github.com/sirupsen/logrus"

"github.com/tensorchord/envd/pkg/config"
Expand Down Expand Up @@ -332,14 +331,19 @@ func (g *generalGraph) compileBaseImage() (llb.State, error) {

// Fix https://github.com/tensorchord/envd/issues/1147.
// Fetch the image metadata from base image.
base := llb.Image(g.Image, llb.WithMetaResolver(imagemetaresolver.Default()))
envs, err := base.Env(context.Background())
base := llb.Image(g.Image)
// fetching the image config may take some time
config, err := ir.FetchImageConfig(context.Background(), g.Image, g.Platform)
if err != nil {
return llb.State{}, err
}
if err != nil {
return llb.State{}, errors.Wrap(err, "failed to get the image metadata")
}

// Set the environment variables to RuntimeEnviron to keep it in the resulting image.
for _, e := range envs {
logger.Logger.Debugf("inherit envs from base image: %s", config.Env)
for _, e := range config.Env {
// in case the env value also contains `=`
kv := strings.SplitN(e, "=", 2)
g.RuntimeEnviron[kv[0]] = kv[1]
Expand All @@ -354,11 +358,6 @@ func (g *generalGraph) compileBaseImage() (llb.State, error) {
}

if !g.Dev {
// fetching the image config may take some time
config, err := ir.FetchImageConfig(context.Background(), g.Image, g.Platform)
if err != nil {
return llb.State{}, err
}
if len(g.Entrypoint) == 0 {
g.Entrypoint = config.Entrypoint
}
Expand Down

0 comments on commit edf21bf

Please sign in to comment.