DodoApp: Support pre build commands in deno app

Pass env vars to deno build as well.

Change-Id: Ia8938d0bdef695bd4932d9c817229705be686092
diff --git a/core/installer/app_configs/dodo_app.cue b/core/installer/app_configs/dodo_app.cue
index 7e2b7bc..cb172bb 100644
--- a/core/installer/app_configs/dodo_app.cue
+++ b/core/installer/app_configs/dodo_app.cue
@@ -105,18 +105,6 @@
 			"DODO_VOLUME_\(strings.ToUpper(v.name))=/dodo-volume/\(v.name)"
 		}
 		for v in postgresql {
-			"DODO_POSTGRESQL_\(strings.ToUpper(v.name))_ADDRESS=postgres-\(v.name).\(release.namespace).svc.cluster.local"
-		}
-		for v in postgresql {
-			"DODO_POSTGRESQL_\(strings.ToUpper(v.name))_USERNAME=postgres"
-		}
-		for v in postgresql {
-			"DODO_POSTGRESQL_\(strings.ToUpper(v.name))_PASSWORD=postgres"
-		}
-		for v in postgresql {
-			"DODO_POSTGRESQL_\(strings.ToUpper(v.name))_DATABASE=postgres"
-		}
-		for v in postgresql {
 			"DODO_POSTGRESQL_\(strings.ToUpper(v.name))_URL=postgresql://postgres:postgres@postgres-\(v.name).\(release.namespace).svc.cluster.local/postgres"
 		}
     ]
@@ -227,15 +215,25 @@
 	type: "nextjs:deno-2.0.0"
 	port: int | *8080
 	rootDir: _appDir
+	preBuildCommands: [...#Command] | *[]
 
 	lastCmdEnv: [...string]
 
 	runConfiguration: [{
 		bin: "/usr/bin/npm",
 		args: ["install"]
-	}, {
+	},
+	for c in preBuildCommands {
+		{
+			bin: c.bin
+			args: c.args
+			env: list.Concat([lastCmdEnv, c.env])
+		}
+	}
+	{
 		bin: "/usr/bin/deno",
 		args: ["task", "build"]
+		env: lastCmdEnv
 	}, {
 		bin: "/usr/bin/deno",
 		args: ["task", "start", "-p", "\(port)"]
diff --git a/core/installer/server/dodo-app/schemas/app.schema.json b/core/installer/server/dodo-app/schemas/app.schema.json
index 60e4f0c..455829c 100644
--- a/core/installer/server/dodo-app/schemas/app.schema.json
+++ b/core/installer/server/dodo-app/schemas/app.schema.json
@@ -131,6 +131,9 @@
         },
         "dev": {
           "$ref": "#/definitions/dev"
+        },
+        "preBuildCommands": {
+          "$ref": "#/definitions/commands"
         }
       },
       "additionalProperties": false,
@@ -254,6 +257,28 @@
         "network",
         "subdomain"
       ]
+    },
+    "command": {
+      "type": "object",
+      "properties": {
+        "bin": { "type": "string" },
+        "args": {
+          "type": "array",
+          "items": { "type": "string" }
+        },
+        "env": {
+          "type": "array",
+          "items": { "type": "string" }
+        }
+      },
+      "additionalProperties": false,
+      "required": ["bin"]
+    },
+    "commands": {
+      "type": "array",
+      "items": {
+        "$ref": "#/definitions/command"
+      }
     }
   }
 }