@@ -2,6 +2,7 @@ package leeway
22
33import (
44 "context"
5+ "encoding/base64"
56 "encoding/json"
67 "fmt"
78 "io"
@@ -16,6 +17,7 @@ import (
1617 log "github.com/sirupsen/logrus"
1718 "golang.org/x/sync/semaphore"
1819 "golang.org/x/xerrors"
20+ "gopkg.in/yaml.v3"
1921)
2022
2123// PkgNotBuiltErr is used when a package's dependency hasn't been built yet
@@ -66,14 +68,18 @@ const (
6668 // dockerImageNamesFiles is the name of the file store in poushed Docker build artifacts
6769 // which contains the names of the Docker images we just pushed
6870 dockerImageNamesFiles = "imgnames.txt"
71+
72+ // dockerMetadataFile is the name of the file we YAML seralize the DockerPkgConfig.Metadata field to
73+ // when building Docker images. We use this mechanism to produce the version manifest as part of the Gitpod build.
74+ dockerMetadataFile = "metadata.yaml"
6975)
7076
7177// buildProcessVersions contain the current version of the respective build processes.
7278// Increment this value if you change any of the build procedures.
7379var buildProcessVersions = map [PackageType ]int {
7480 YarnPackage : 6 ,
7581 GoPackage : 2 ,
76- DockerPackage : 1 ,
82+ DockerPackage : 2 ,
7783 GenericPackage : 1 ,
7884}
7985
@@ -1028,7 +1034,15 @@ func (p *Package) buildDocker(buildctx *buildContext, wd, result string) (err er
10281034 for _ , img := range cfg .Image {
10291035 commands = append (commands , []string {"sh" , "-c" , fmt .Sprintf ("echo %s >> %s" , img , dockerImageNamesFiles )})
10301036 }
1031- commands = append (commands , []string {"tar" , "cfz" , result , dockerImageNamesFiles })
1037+ // In addition to the imgnames.txt we also produce a file that contains the configured metadata,
1038+ // which provides a sensible way to add metadata to the image names.
1039+ consts , err := yaml .Marshal (cfg .Metadata )
1040+ if err != nil {
1041+ return err
1042+ }
1043+ commands = append (commands , []string {"sh" , "-c" , fmt .Sprintf ("echo %s | base64 -d > %s" , base64 .StdEncoding .EncodeToString (consts ), dockerMetadataFile )})
1044+
1045+ commands = append (commands , []string {"tar" , "cfz" , result , dockerImageNamesFiles , dockerMetadataFile })
10321046 }
10331047
10341048 return executeCommandsForPackage (buildctx , p , wd , commands )
0 commit comments