Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit e5fea9d

Browse files
committed
Tag service images according to compose spec
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent e3115da commit e5fea9d

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

internal/commands/build/build.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ func updateBundle(bundle *bundle.Bundle, resp map[string]*client.SolveResponse)
159159
bundle.InvocationImages[0].Digest = digest
160160
} else {
161161
image := bundle.Images[service]
162-
image.Image = fmt.Sprintf("%s:%s-%s", bundle.Name, bundle.Version, service)
163162
image.ImageType = cnab.ImageTypeDocker
164163
image.Digest = digest
165164
bundle.Images[service] = image

internal/commands/build/compose.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ func parseCompose(app *types.App, options buildOptions) (map[string]build.Option
2828
if service.Build == nil {
2929
continue
3030
}
31+
32+
var tags []string
33+
if service.Image != nil {
34+
tags = []string{*service.Image}
35+
}
36+
3137
// FIXME docker app init should update relative paths
3238
// compose file has been copied to x.dockerapp, so the relative path to build context get broken
3339
contextPath := path.Join(app.Path, "..", service.Build.Context)
@@ -43,7 +49,7 @@ func parseCompose(app *types.App, options buildOptions) (map[string]build.Option
4349
BuildArgs: flatten(service.Build.Args),
4450
NoCache: options.noCache,
4551
Pull: options.pull,
46-
Tags: []string{fmt.Sprintf("%s:%s-%s", app.Metadata().Name, app.Metadata().Version, service.Name)},
52+
Tags: tags,
4753
}
4854
}
4955
return opts, nil

internal/commands/build/compose_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func Test_parseCompose(t *testing.T) {
2323
ContextPath: "testdata/web",
2424
DockerfilePath: "testdata/web/Dockerfile",
2525
},
26-
Tags: []string{"simple:1.1.0-beta1-web"},
26+
Tags: []string{"frontend"},
2727
},
2828
},
2929
{
@@ -34,7 +34,6 @@ func Test_parseCompose(t *testing.T) {
3434
ContextPath: "testdata/web",
3535
DockerfilePath: "testdata/web/Dockerfile.custom",
3636
},
37-
Tags: []string{"context:1.1.0-beta1-web"},
3837
},
3938
},
4039
{
@@ -46,7 +45,6 @@ func Test_parseCompose(t *testing.T) {
4645
DockerfilePath: "testdata/web/Dockerfile",
4746
},
4847
BuildArgs: map[string]string{"foo": "bar"},
49-
Tags: []string{"withargs:1.1.0-beta1-web"},
5048
},
5149
},
5250
}

internal/commands/build/testdata/simple.dockerapp/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ version: "3.6"
22
services:
33
web:
44
build: ./web
5+
image: frontend
56
dontwant:
67
image: postgres:9.3

internal/commands/build/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type ServiceConfig struct {
1515
Name string `yaml:"-" json:"-"`
1616

1717
Build *ImageBuildConfig
18+
Image *string
1819
}
1920

2021
type ImageBuildConfig struct {

0 commit comments

Comments
 (0)