restructure to build individual binaries

This commit is contained in:
Michael Hobbs
2017-01-14 20:22:37 -08:00
parent e61475c7ea
commit fc31b28ab6
8 changed files with 30 additions and 43 deletions

View File

@@ -0,0 +1,29 @@
package main
import (
"flag"
"strings"
common "github.com/dokku/dokku/plugins/common"
)
// runs 'git gc --aggressive' against the application's repo
func main() {
flag.Parse()
appName := flag.Arg(1)
if appName == "" {
common.LogFail("Please specify an app to run the command on")
}
err := common.VerifyAppName(appName)
if err != nil {
common.LogFail(err.Error())
}
appRoot := strings.Join([]string{common.MustGetEnv("DOKKU_ROOT"), appName}, "/")
cmdEnv := map[string]string{
"GIT_DIR": appRoot,
}
gitGcCmd := common.NewDokkuCmd("git gc --aggressive")
gitGcCmd.Env = cmdEnv
gitGcCmd.Execute()
}

View File

@@ -0,0 +1,36 @@
package main
import (
"flag"
"os"
"strings"
common "github.com/dokku/dokku/plugins/common"
)
// deletes the contents of the build cache stored in the repository
func main() {
flag.Parse()
appName := flag.Arg(1)
if appName == "" {
common.LogFail("Please specify an app to run the command on")
}
err := common.VerifyAppName(appName)
if err != nil {
common.LogFail(err.Error())
}
cacheDir := strings.Join([]string{common.MustGetEnv("DOKKU_ROOT"), appName, "cache"}, "/")
dokkuGlobalRunArgs := common.MustGetEnv("DOKKU_GLOBAL_RUN_ARGS")
image := common.GetDeployingAppImageName(appName, "", "")
if info, _ := os.Stat(cacheDir); info != nil && info.IsDir() {
purgeCacheCmd := common.NewDokkuCmd(strings.Join([]string{"docker run --rm", dokkuGlobalRunArgs,
"-v", strings.Join([]string{cacheDir, ":/cache"}, ""), image,
`find /cache -depth -mindepth 1 -maxdepth 1 -exec rm -Rf {} ;`}, " "))
purgeCacheCmd.Execute()
err := os.MkdirAll(cacheDir, 0644)
if err != nil {
common.LogFail(err.Error())
}
}
}