AppManager: Add API endpoint to install dodo app

Refactors cue definitions.

Next steps:
* Needs some cleanup, namespace is hard coded ...
* Maybe merge with regular install API
* Support exposing ports across clusters

Change-Id: Ibfc3c3f742b61f2c5874012fe6c77b958eae81d9
diff --git a/apps/app-runner/server.go b/apps/app-runner/server.go
index 1779a76..ad8c7bc 100644
--- a/apps/app-runner/server.go
+++ b/apps/app-runner/server.go
@@ -8,6 +8,7 @@
 	"net/http"
 	"os"
 	"os/exec"
+	"path/filepath"
 	"sync"
 	"syscall"
 	"time"
@@ -23,6 +24,7 @@
 	cmd         *exec.Cmd
 	repoAddr    string
 	branch      string
+	rootDir     string
 	signer      ssh.Signer
 	appDir      string
 	runCommands []Command
@@ -32,7 +34,7 @@
 	currDir     string
 }
 
-func NewServer(port int, appId string, repoAddr, branch string, signer ssh.Signer, appDir string, runCommands []Command, self string, manager string) *Server {
+func NewServer(port int, appId string, repoAddr, branch, rootDir string, signer ssh.Signer, appDir string, runCommands []Command, self string, manager string) *Server {
 	return &Server{
 		l:           &sync.Mutex{},
 		port:        port,
@@ -40,6 +42,7 @@
 		appId:       appId,
 		repoAddr:    repoAddr,
 		branch:      branch,
+		rootDir:     rootDir,
 		signer:      signer,
 		appDir:      appDir,
 		runCommands: runCommands,
@@ -94,7 +97,7 @@
 	if err != nil {
 		return err
 	}
-	if err := CloneRepositoryBranch(s.repoAddr, s.branch, s.signer, newDir); err != nil {
+	if err := CloneRepositoryBranch(s.repoAddr, s.branch, s.rootDir, s.signer, newDir); err != nil {
 		return err
 	}
 	logM := io.MultiWriter(os.Stdout, s.logs)
@@ -102,7 +105,7 @@
 		args := []string{c.Bin}
 		args = append(args, c.Args...)
 		cmd := &exec.Cmd{
-			Dir:    newDir,
+			Dir:    filepath.Join(newDir, s.rootDir),
 			Path:   c.Bin,
 			Args:   args,
 			Env:    append(os.Environ(), c.Env...),