1
1
use crate :: { RubyBuildpack , RubyBuildpackError } ;
2
- use commons:: layer:: DefaultEnvLayer ;
2
+ use libcnb:: layer:: UncachedLayerDefinition ;
3
+ use libcnb:: layer_env:: { LayerEnv , ModificationBehavior } ;
3
4
use libcnb:: {
4
5
build:: BuildContext ,
5
6
data:: { layer_name, store:: Store } ,
@@ -9,7 +10,6 @@ use libcnb::{
9
10
use rand:: Rng ;
10
11
11
12
// Set default environment values
12
- #[ allow( deprecated) ]
13
13
pub ( crate ) fn default_env (
14
14
context : & BuildContext < RubyBuildpack > ,
15
15
platform_env : & Env ,
@@ -24,25 +24,32 @@ pub(crate) fn default_env(
24
24
}
25
25
26
26
let ( default_secret_key_base, store) = fetch_secret_key_base_from_store ( & context. store ) ;
27
-
28
- let env_defaults_layer = context //
29
- . handle_layer (
30
- layer_name ! ( "env_defaults" ) ,
31
- DefaultEnvLayer :: new (
32
- [
33
- ( "SECRET_KEY_BASE" , default_secret_key_base. as_str ( ) ) ,
34
- ( "JRUBY_OPTS" , "-Xcompile.invokedynamic=false" ) ,
35
- ( "RACK_ENV" , "production" ) ,
36
- ( "RAILS_ENV" , "production" ) ,
37
- ( "RAILS_SERVE_STATIC_FILES" , "enabled" ) ,
38
- ( "RAILS_LOG_TO_STDOUT" , "enabled" ) ,
39
- ( "MALLOC_ARENA_MAX" , "2" ) ,
40
- ( "DISABLE_SPRING" , "1" ) ,
41
- ]
42
- . into_iter ( ) ,
43
- ) ,
44
- ) ?;
45
- env = env_defaults_layer. env . apply ( Scope :: Build , & env) ;
27
+ let layer_ref = context. uncached_layer (
28
+ layer_name ! ( "env_defaults" ) ,
29
+ UncachedLayerDefinition {
30
+ build : true ,
31
+ launch : true ,
32
+ } ,
33
+ ) ?;
34
+ let env = layer_ref
35
+ . write_env ( {
36
+ [
37
+ ( "SECRET_KEY_BASE" , default_secret_key_base. as_str ( ) ) ,
38
+ ( "JRUBY_OPTS" , "-Xcompile.invokedynamic=false" ) ,
39
+ ( "RACK_ENV" , "production" ) ,
40
+ ( "RAILS_ENV" , "production" ) ,
41
+ ( "RAILS_SERVE_STATIC_FILES" , "enabled" ) ,
42
+ ( "RAILS_LOG_TO_STDOUT" , "enabled" ) ,
43
+ ( "MALLOC_ARENA_MAX" , "2" ) ,
44
+ ( "DISABLE_SPRING" , "1" ) ,
45
+ ]
46
+ . iter ( )
47
+ . fold ( LayerEnv :: new ( ) , |layer_env, ( name, value) | {
48
+ layer_env. chainable_insert ( Scope :: All , ModificationBehavior :: Default , name, value)
49
+ } )
50
+ } )
51
+ . and_then ( |( ) | layer_ref. read_env ( ) ) ?
52
+ . apply ( Scope :: Build , & env) ;
46
53
47
54
Ok ( ( env, store) )
48
55
}
0 commit comments