@@ -39,6 +39,7 @@ const (
3939 serviceCfgEnvPrefix = "ENCORE_CFG_"
4040 listenEnvVar = "ENCORE_LISTEN_ADDR"
4141 metaEnvVar = "ENCORE_APP_META"
42+ metaPathEnvVar = "ENCORE_APP_META_PATH"
4243)
4344
4445type RuntimeConfigGenerator struct {
@@ -76,8 +77,11 @@ type RuntimeConfigGenerator struct {
7677 Gateways map [string ]GatewayConfig
7778 AuthKey config.EncoreAuthKey
7879
79- // Whether to include the metadata as an environment variable.
80- IncludeMetaEnv bool
80+ // Whether to include the metadata.
81+ IncludeMeta bool
82+ // If set, write the metadata to the given path
83+ // instead of including it as an environment variable.
84+ MetaPath option.Option [string ]
8185
8286 // The values of defined secrets.
8387 DefinedSecrets map [string ]string
@@ -96,7 +100,6 @@ type GatewayConfig struct {
96100func (g * RuntimeConfigGenerator ) initialize () error {
97101 return g .initOnce .Do (func () error {
98102 g .conf = rtconfgen .NewBuilder ()
99-
100103 newRid := func () string { return "res_" + xid .New ().String () }
101104
102105 if deployID , ok := g .DeployID .Get (); ok {
@@ -719,7 +722,7 @@ func (g *RuntimeConfigGenerator) ForTests(newRuntimeConf bool) (envs []string, e
719722 svcNames := fns .Map (g .md .Svcs , func (svc * meta.Service ) string { return svc .Name })
720723 envs = append (envs , g .encodeConfigs (svcNames ... )... )
721724
722- if g .IncludeMetaEnv {
725+ if g .IncludeMeta {
723726 metaBytes , err := proto .Marshal (g .md )
724727 if err != nil {
725728 return nil , errors .Wrap (err , "failed to marshal metadata" )
@@ -779,14 +782,21 @@ func (g *RuntimeConfigGenerator) ProcEnvs(proc *ProcConfig, useRuntimeConfigV2 b
779782 env = append (env , fmt .Sprintf ("%s=%s" , runtimeCfgEnvVar , runtimeCfgStr ))
780783 }
781784
782- if g .IncludeMetaEnv {
785+ if g .IncludeMeta {
783786 metaBytes , err := proto .Marshal (g .md )
784787 if err != nil {
785788 return nil , errors .Wrap (err , "failed to marshal metadata" )
786789 }
787- gzipped := gzipBytes (metaBytes )
788- metaEnvStr := "gzip:" + base64 .StdEncoding .EncodeToString (gzipped )
789- env = append (env , fmt .Sprintf ("%s=%s" , metaEnvVar , metaEnvStr ))
790+ if metaPath , ok := g .MetaPath .Get (); ok {
791+ if err := os .WriteFile (metaPath , metaBytes , 0644 ); err != nil {
792+ return nil , errors .Wrap (err , "failed to write metadata" )
793+ }
794+ env = append (env , fmt .Sprintf ("%s=%s" , metaPathEnvVar , metaPath ))
795+ } else {
796+ gzipped := gzipBytes (metaBytes )
797+ metaEnvStr := "gzip:" + base64 .StdEncoding .EncodeToString (gzipped )
798+ env = append (env , fmt .Sprintf ("%s=%s" , metaEnvVar , metaEnvStr ))
799+ }
790800 }
791801
792802 if runtimeLibPath := encoreEnv .EncoreRuntimeLib (); runtimeLibPath != "" {
0 commit comments