github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/pkg/compilers/osv/osv_node.go (about) 1 package osv 2 3 import ( 4 "github.com/solo-io/unik/pkg/compilers" 5 "github.com/solo-io/unik/pkg/types" 6 ) 7 8 type OSvNodeCompiler struct { 9 ImageFinisher ImageFinisher 10 } 11 12 func (r *OSvNodeCompiler) CompileRawImage(params types.CompileImageParams) (*types.RawImage, error) { 13 14 // Prepare meta/run.yaml for node runtime. 15 if err := addRuntimeStanzaToMetaRun(params.SourcesDir, "node"); err != nil { 16 return nil, err 17 } 18 19 // Create meta/package.yaml if not exist. 20 if err := assureMetaPackage(params.SourcesDir); err != nil { 21 return nil, err 22 } 23 24 // Parse image size from manifest.yaml. 25 params.SizeMB = int(readImageSizeFromManifest(params.SourcesDir)) 26 27 // Compose image inside Docker container. 28 imagePath, err := CreateImageDynamic(params, r.ImageFinisher.UseEc2()) 29 if err != nil { 30 return nil, err 31 } 32 33 // And finalize it. 34 convertParams := FinishParams{ 35 CompileParams: params, 36 CapstanImagePath: imagePath, 37 } 38 return r.ImageFinisher.FinishImage(convertParams) 39 } 40 41 func (r *OSvNodeCompiler) Usage() *compilers.CompilerUsage { 42 return &compilers.CompilerUsage{ 43 PrepareApplication: "Install all libraries using `npm install`.", 44 ConfigurationFiles: map[string]string{ 45 "/meta/run.yaml": ` 46 config_set: 47 conf1: 48 main: <relative-path-to-your-entrypoint> 49 config_set_default: conf1 50 `, 51 "/manifest.yaml": ` 52 image_size: "10GB" # logical image size 53 `, 54 }, 55 } 56 }