Merge pull request #338 from dagger/pushcontainer-image-ref
Pushcontainer image ref
This commit is contained in:
commit
d000b2912b
@ -627,7 +627,7 @@ func (p *Pipeline) PushContainer(ctx context.Context, op *compiler.Value, st llb
|
|||||||
// Add the default tag "latest" to a reference if it only has a repo name.
|
// Add the default tag "latest" to a reference if it only has a repo name.
|
||||||
ref = reference.TagNameOnly(ref)
|
ref = reference.TagNameOnly(ref)
|
||||||
|
|
||||||
_, err = p.s.Export(ctx, p.State(), &p.image, bk.ExportEntry{
|
resp, err := p.s.Export(ctx, p.State(), &p.image, bk.ExportEntry{
|
||||||
Type: bk.ExporterImage,
|
Type: bk.ExporterImage,
|
||||||
Attrs: map[string]string{
|
Attrs: map[string]string{
|
||||||
"name": ref.String(),
|
"name": ref.String(),
|
||||||
@ -635,6 +635,29 @@ func (p *Pipeline) PushContainer(ctx context.Context, op *compiler.Value, st llb
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return st, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if digest, ok := resp.ExporterResponse["containerimage.digest"]; ok {
|
||||||
|
imageRef := fmt.Sprintf(
|
||||||
|
"%s@%s",
|
||||||
|
resp.ExporterResponse["image.name"],
|
||||||
|
digest,
|
||||||
|
)
|
||||||
|
|
||||||
|
return st.File(
|
||||||
|
llb.Mkdir("/dagger", fs.FileMode(0755)),
|
||||||
|
llb.WithCustomName(p.vertexNamef("Mkdir /dagger")),
|
||||||
|
).File(
|
||||||
|
llb.Mkfile("/dagger/image_digest", fs.FileMode(0644), []byte(digest)),
|
||||||
|
llb.WithCustomName(p.vertexNamef("Storing image digest to /dagger/image_digest")),
|
||||||
|
).File(
|
||||||
|
llb.Mkfile("/dagger/image_ref", fs.FileMode(0644), []byte(imageRef)),
|
||||||
|
llb.WithCustomName(p.vertexNamef("Storing image ref to /dagger/image_ref")),
|
||||||
|
), nil
|
||||||
|
}
|
||||||
|
|
||||||
return st, err
|
return st, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,10 @@ import (
|
|||||||
target: pushTarget
|
target: pushTarget
|
||||||
}
|
}
|
||||||
|
|
||||||
push: #up: [
|
ref: {
|
||||||
|
string
|
||||||
|
|
||||||
|
#up: [
|
||||||
// Build the docker image
|
// Build the docker image
|
||||||
op.#DockerBuild & {
|
op.#DockerBuild & {
|
||||||
context: source
|
context: source
|
||||||
@ -38,8 +41,10 @@ import (
|
|||||||
op.#PushContainer & {
|
op.#PushContainer & {
|
||||||
ref: pushTarget
|
ref: pushTarget
|
||||||
},
|
},
|
||||||
|
op.#Export & {
|
||||||
|
source: "/dagger/image_ref"
|
||||||
|
format: "string"
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
}
|
||||||
// FIXME: ref does not include the sha256: https://github.com/dagger/dagger/issues/303
|
|
||||||
ref: pushTarget
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user