@@ -386,7 +386,7 @@ const countryQuestions = [
386386 }
387387]
388388
389- const infrastructureQuestions = [
389+ const diskQuestions = [
390390 {
391391 name : 'diskSpace' ,
392392 type : 'text' as const ,
@@ -397,8 +397,10 @@ const infrastructureQuestions = [
397397 validate : notEmpty ,
398398 valueLabel : 'DISK_SPACE' ,
399399 initial : process . env . DISK_SPACE || '200g' ,
400- scope : 'ENVIRONMENT' as const
400+ scope : 'ENVIRONMENT' as const ,
401401 } ,
402+ ]
403+ const infrastructureQuestions = [
402404 {
403405 name : 'domain' ,
404406 type : 'text' as const ,
@@ -780,6 +782,7 @@ ALL_QUESTIONS.push(
780782 ...dockerhubQuestions ,
781783 ...sshQuestions ,
782784 ...sshKeyQuestions ,
785+ ...diskQuestions ,
783786 ...infrastructureQuestions ,
784787 ...countryQuestions ,
785788 ...databaseAndMonitoringQuestions ,
@@ -887,7 +890,7 @@ const SPECIAL_NON_APPLICATION_ENVIRONMENTS = ['jump', 'backup']
887890 ...existingRepositoryVariable ,
888891 ...existingEnvironmentSecrets
889892 ]
890-
893+ let enableEncryption = true
891894 if (
892895 existingEnvironmentVariables . length > 0 ||
893896 existingEnvironmentSecrets . length > 0
@@ -967,7 +970,32 @@ const SPECIAL_NON_APPLICATION_ENVIRONMENTS = ['jump', 'backup']
967970 )
968971 }
969972 } else {
970- log ( '\n' , kleur . bold ( ) . underline ( 'Server setup' ) )
973+ log ( '\n' , kleur . bold ( ) . underline ( 'Server setup' ) , '\n' )
974+ const encryption_key_defined = findExistingValue (
975+ 'ENCRYPTION_KEY' ,
976+ 'SECRET' ,
977+ 'ENVIRONMENT' ,
978+ existingValues
979+ )
980+
981+ if ( ! encryption_key_defined ) {
982+ const answers_enable_encryption = await prompts (
983+ [
984+ {
985+ name : 'enableEncryption' ,
986+ type : 'confirm' as const ,
987+ message : 'Do you want to enable disk encryption?' ,
988+ scope : 'ENVIRONMENT' as const ,
989+ initial : Boolean ( process . env . ENABLE_ENCRYPTION )
990+ }
991+ ] . map ( questionToPrompt )
992+ )
993+ enableEncryption = answers_enable_encryption . enableEncryption
994+ }
995+ if ( enableEncryption ) {
996+ console . log ( '\n' , kleur . bold ( ) . green ( '✔' ) , kleur . bold ( ) . yellow ( ' Disk encryption is enabled' ) )
997+ await promptAndStoreAnswer ( environment , diskQuestions , existingValues )
998+ }
971999 const { domain } = await promptAndStoreAnswer (
9721000 environment ,
9731001 infrastructureQuestions ,
@@ -1101,6 +1129,26 @@ const SPECIAL_NON_APPLICATION_ENVIRONMENTS = ['jump', 'backup']
11011129 }
11021130 ]
11031131
1132+ if ( enableEncryption ) {
1133+ derivedUpdates . push ( {
1134+ name : 'ENCRYPTION_KEY' ,
1135+ type : 'SECRET' as const ,
1136+ didExist : findExistingValue (
1137+ 'ENCRYPTION_KEY' ,
1138+ 'SECRET' ,
1139+ 'ENVIRONMENT' ,
1140+ existingValues
1141+ ) ,
1142+ value : findExistingOrDefine (
1143+ 'ENCRYPTION_KEY' ,
1144+ 'SECRET' ,
1145+ 'ENVIRONMENT' ,
1146+ generateLongPassword ( )
1147+ ) ,
1148+ scope : 'ENVIRONMENT' as const
1149+ } )
1150+ }
1151+
11041152 if ( [ 'production' , 'staging' ] . includes ( environment ) ) {
11051153 derivedUpdates . push ( {
11061154 name : 'BACKUP_ENCRYPTION_PASSPHRASE' ,
@@ -1275,23 +1323,6 @@ const SPECIAL_NON_APPLICATION_ENVIRONMENTS = ['jump', 'backup']
12751323 ) ,
12761324 scope : 'ENVIRONMENT' as const
12771325 } ,
1278- {
1279- name : 'ENCRYPTION_KEY' ,
1280- type : 'SECRET' as const ,
1281- didExist : findExistingValue (
1282- 'ENCRYPTION_KEY' ,
1283- 'SECRET' ,
1284- 'ENVIRONMENT' ,
1285- existingValues
1286- ) ,
1287- value : findExistingOrDefine (
1288- 'ENCRYPTION_KEY' ,
1289- 'SECRET' ,
1290- 'ENVIRONMENT' ,
1291- generateLongPassword ( )
1292- ) ,
1293- scope : 'ENVIRONMENT' as const
1294- } ,
12951326 {
12961327 type : 'VARIABLE' as const ,
12971328 name : 'ACTIVATE_USERS' ,
0 commit comments