@@ -4,21 +4,16 @@ import (
4
4
"bytes"
5
5
"context"
6
6
"encoding/json"
7
- "errors"
8
7
"fmt"
9
8
"io/ioutil"
10
9
"os"
11
10
"path/filepath"
12
11
"strconv"
13
12
"strings"
14
13
15
- errors2 "github.com/pkg/errors"
16
-
17
- "github.com/docker/app/internal"
18
- "github.com/docker/cnab-to-oci/remotes"
19
-
20
14
"github.com/deislabs/cnab-go/bundle"
21
15
cnab "github.com/deislabs/cnab-go/driver"
16
+ "github.com/docker/app/internal"
22
17
"github.com/docker/app/internal/packager"
23
18
"github.com/docker/app/types"
24
19
"github.com/docker/buildx/build"
@@ -27,24 +22,27 @@ import (
27
22
"github.com/docker/buildx/util/progress"
28
23
"github.com/docker/cli/cli"
29
24
"github.com/docker/cli/cli/command"
25
+ "github.com/docker/cnab-to-oci/remotes"
30
26
"github.com/docker/distribution/reference"
31
27
"github.com/moby/buildkit/client"
32
28
"github.com/moby/buildkit/session"
33
29
"github.com/moby/buildkit/session/auth/authprovider"
34
30
"github.com/moby/buildkit/util/appcontext"
31
+ "github.com/pkg/errors"
35
32
"github.com/sirupsen/logrus"
36
33
"github.com/spf13/cobra"
37
34
)
38
35
39
36
type buildOptions struct {
40
- noCache bool
41
- progress string
42
- pull bool
43
- tag string
44
- folder string
45
- imageIDFile string
46
- args []string
47
- quiet bool
37
+ noCache bool
38
+ progress string
39
+ pull bool
40
+ tag string
41
+ folder string
42
+ imageIDFile string
43
+ args []string
44
+ quiet bool
45
+ noResolveImage bool
48
46
}
49
47
50
48
func Cmd (dockerCli command.Cli ) * cobra.Command {
@@ -63,6 +61,7 @@ $ docker app build . -f myapp.dockerapp -t myrepo/myapp:1.0.0`,
63
61
flags := cmd .Flags ()
64
62
flags .BoolVar (& opts .noCache , "no-cache" , false , "Do not use cache when building the App image" )
65
63
flags .StringVar (& opts .progress , "progress" , "auto" , "Set type of progress output (auto, plain, tty). Use plain to show container output" )
64
+ flags .BoolVar (& opts .noResolveImage , "no-resolve-image" , false , "Do not query the registry to resolve image digest" )
66
65
flags .StringVarP (& opts .tag , "tag" , "t" , "" , "App image tag, optionally in the 'repo:tag' format" )
67
66
flags .StringVarP (& opts .folder , "folder" , "f" , "" , "App definition as a .dockerapp directory" )
68
67
flags .BoolVar (& opts .pull , "pull" , false , "Always attempt to pull a newer version of the App image" )
@@ -196,22 +195,22 @@ func buildImageUsingBuildx(app *types.App, contextPath string, opt buildOptions,
196
195
func fixServiceImageReferences (ctx context.Context , dockerCli command.Cli , bundle * bundle.Bundle , pulledServices []ServiceConfig ) error {
197
196
insecureRegistries , err := internal .InsecureRegistriesFromEngine (dockerCli )
198
197
if err != nil {
199
- return errors2 .Wrapf (err , "could not retrieve insecure registries" )
198
+ return errors .Wrapf (err , "could not retrieve insecure registries" )
200
199
}
201
200
resolver := remotes .CreateResolver (dockerCli .ConfigFile (), insecureRegistries ... )
202
201
for _ , service := range pulledServices {
203
202
image := bundle .Images [service .Name ]
204
203
ref , err := reference .ParseNormalizedNamed (* service .Image )
205
204
if err != nil {
206
- return errors2 .Wrapf (err , "could not resolve image %s" , * service .Image )
205
+ return errors .Wrapf (err , "could not resolve image %s" , * service .Image )
207
206
}
208
207
_ , desc , err := resolver .Resolve (ctx , ref .String ())
209
208
if err != nil {
210
- return errors2 .Wrapf (err , "could not resolve image %s" , ref .Name ())
209
+ return errors .Wrapf (err , "could not resolve image %s" , ref .Name ())
211
210
}
212
211
canonical , err := reference .WithDigest (ref , desc .Digest )
213
212
if err != nil {
214
- return errors2 .Wrapf (err , "could not resolve image %s" , ref .Name ())
213
+ return errors .Wrapf (err , "could not resolve image %s" , ref .Name ())
215
214
}
216
215
image .Image = canonical .String ()
217
216
bundle .Images [service .Name ] = image
@@ -251,7 +250,7 @@ func checkMinimalEngineVersion(dockerCli command.Cli) error {
251
250
return err
252
251
}
253
252
if majorVersion < 19 {
254
- return errors . New ("'build' require docker engine 19.03 or later" )
253
+ return fmt . Errorf ("'build' require docker engine 19.03 or later" )
255
254
}
256
255
return nil
257
256
}
0 commit comments