Multi-stage builds from hash images

Implement multi-stage copy from images part of the build cache of a
package.

Note, this is not the final images where are we copying files from, but
the underlying build container.

Skipping the test on img backend because it fails when pulling external
images during multi-stage build...

Fixes #190
This commit is contained in:
Ettore Di Giacinto
2021-05-18 11:54:45 +02:00
parent 356350f724
commit 7f047e4fc2
11 changed files with 158 additions and 15 deletions

View File

@@ -55,12 +55,13 @@ import (
type PackageArtifact struct {
Path string `json:"path"`
Dependencies []*PackageArtifact `json:"dependencies"`
CompileSpec *compilerspec.LuetCompilationSpec `json:"compilationspec"`
Checksums Checksums `json:"checksums"`
SourceAssertion solver.PackagesAssertions `json:"-"`
CompressionType compression.Implementation `json:"compressiontype"`
Files []string `json:"files"`
Dependencies []*PackageArtifact `json:"dependencies"`
CompileSpec *compilerspec.LuetCompilationSpec `json:"compilationspec"`
Checksums Checksums `json:"checksums"`
SourceAssertion solver.PackagesAssertions `json:"-"`
CompressionType compression.Implementation `json:"compressiontype"`
Files []string `json:"files"`
PackageCacheImage string `json:"package_cacheimage"`
}
func (p *PackageArtifact) ShallowCopy() *PackageArtifact {

View File

@@ -89,8 +89,8 @@ func (specs *LuetCompilationspecs) Unique() *LuetCompilationspecs {
type CopyField struct {
Package *pkg.DefaultPackage `json:"package"`
Image string `json:"image"`
Source string `json:"src"`
Destination string `json:"dst"`
Source string `json:"source"`
Destination string `json:"destination"`
}
type LuetCompilationSpec struct {
@@ -268,7 +268,8 @@ ADD ` + s + ` /luetbuild/`
for _, c := range cs.Copy {
if c.Image != "" {
spec = spec + fmt.Sprintf("\nCOPY --from=%s %s %s\n", c.Image, c.Source, c.Destination)
copyLine := fmt.Sprintf("\nCOPY --from=%s %s %s\n", c.Image, c.Source, c.Destination)
spec = spec + copyLine
}
}