From 890b6808a2d307e56cac94893383783ea05e23e2 Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Wed, 2 Mar 2022 15:21:26 +0100 Subject: [PATCH] support cache_from|to|no|pull Signed-off-by: Nicolas De Loof --- go.mod | 2 +- go.sum | 4 ++-- pkg/compose/build.go | 13 +++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7d92e0efd..3dabf2171 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/AlecAivazis/survey/v2 v2.3.2 github.com/buger/goterm v1.0.4 github.com/cnabio/cnab-to-oci v0.3.1-beta1 - github.com/compose-spec/compose-go v1.1.0 + github.com/compose-spec/compose-go v1.2.1 github.com/containerd/console v1.0.3 github.com/containerd/containerd v1.6.1 github.com/distribution/distribution/v3 v3.0.0-20210316161203-a01c71e2477e diff --git a/go.sum b/go.sum index fa4ddc9e0..57fad434f 100644 --- a/go.sum +++ b/go.sum @@ -302,8 +302,8 @@ github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoC github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI= github.com/codahale/hdrhistogram v0.0.0-20160425231609-f8ad88b59a58/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/compose-spec/compose-go v1.0.8/go.mod h1:REnCbBugoIdHB7S1sfkN/aJ7AJpNApGNjNiVjA9L8x4= -github.com/compose-spec/compose-go v1.1.0 h1:n/0O7Fl90doi5AG9bfF0SOSLXtveXxLkGXblSrxVC5Q= -github.com/compose-spec/compose-go v1.1.0/go.mod h1:pAy7Mikpeft4pxkFU565/DRHEbDfR84G6AQuiL+Hdg8= +github.com/compose-spec/compose-go v1.2.1 h1:8+DAP7Mt/Ohl5y6YbZdilLMvIhMxvuSZcNZyywjQmJE= +github.com/compose-spec/compose-go v1.2.1/go.mod h1:pAy7Mikpeft4pxkFU565/DRHEbDfR84G6AQuiL+Hdg8= github.com/compose-spec/godotenv v1.1.1/go.mod h1:zF/3BOa18Z24tts5qnO/E9YURQanJTBUf7nlcCTNsyc= github.com/containerd/aufs v0.0.0-20200908144142-dab0cbea06f4/go.mod h1:nukgQABAEopAHvB6j7cnP5zJ+/3aVcE7hCYqvIwAHyE= github.com/containerd/aufs v0.0.0-20201003224125-76a6863f2989/go.mod h1:AkGGQs9NM2vtYHaUen+NljV0/baGCAPELGm2q9ZXpWU= diff --git a/pkg/compose/build.go b/pkg/compose/build.go index 829479690..b88fe3310 100644 --- a/pkg/compose/build.go +++ b/pkg/compose/build.go @@ -234,11 +234,24 @@ func (s *composeService) toBuildOptions(project *types.Project, service types.Se plats = append(plats, p) } + cacheFrom, err := buildflags.ParseCacheEntry(service.Build.CacheFrom) + if err != nil { + return build.Options{}, err + } + cacheTo, err := buildflags.ParseCacheEntry(service.Build.CacheTo) + if err != nil { + return build.Options{}, err + } + return build.Options{ Inputs: build.Inputs{ ContextPath: service.Build.Context, DockerfilePath: dockerFilePath(service.Build.Context, service.Build.Dockerfile), }, + CacheFrom: cacheFrom, + CacheTo: cacheTo, + NoCache: service.Build.NoCache, + Pull: service.Build.Pull, BuildArgs: buildArgs, Tags: tags, Target: service.Build.Target,