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

@@ -26,8 +26,7 @@ else
BUILD_STACK_TARGETS = build-in-docker
endif
.PHONY: all apt-update install version copyfiles man-db plugins dependencies sshcommand plugn docker aufs stack count dokku-installer vagrant-acl-add vagrant-dokku go-build force
force :;
.PHONY: all apt-update install version copyfiles man-db plugins dependencies sshcommand plugn docker aufs stack count dokku-installer vagrant-acl-add vagrant-dokku go-build
include tests.mk
include deb.mk
@@ -54,7 +53,7 @@ package_cloud:
packer:
packer build contrib/packer.json
go-build: force
go-build:
basedir=$(PWD); \
for dir in plugins/*; do \
if [ -e $$dir/Makefile ]; then \
@@ -62,6 +61,14 @@ go-build: force
fi ;\
done
go-clean:
basedir=$(PWD); \
for dir in plugins/*; do \
if [ -e $$dir/Makefile ]; then \
$(MAKE) -C $$dir clean ;\
fi ;\
done
copyfiles:
$(MAKE) go-build || exit 1
cp dokku /usr/local/bin/dokku
@@ -81,7 +88,7 @@ copyfiles:
PLUGIN_PATH=${CORE_PLUGINS_PATH} plugn enable $$plugin ;\
PLUGIN_PATH=${PLUGINS_PATH} plugn enable $$plugin ;\
done
find ./plugins/* -type f -executable -exec file -i '{}' \; | grep 'x-executable; charset=binary' | awk -F: '{ print $$1 }' | xargs rm -f
$(MAKE) go-clean
chown dokku:dokku -R ${PLUGINS_PATH} ${CORE_PLUGINS_PATH} || true
$(MAKE) addman

2
plugins/repo/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/commands
/subcommands/*

View File

@@ -1,5 +1,8 @@
.PHONY: build-in-docker build clean
GO_REPO_ROOT ?= /go/src/github.com/dokku/dokku
BUILD_IMAGE ?= golang:1.7.1
build-in-docker: clean
docker run --rm \
-v $$PWD/../..:$(GO_REPO_ROOT) \
@@ -7,8 +10,17 @@ build-in-docker: clean
$(BUILD_IMAGE) \
bash -c "make build" || exit $$?
build:
cd src && go build -a -o ../commands
build: commands subcommands
subcommands: subcommands/gc subcommands/purge-cache
commands: **/**/commands.go
go build -a -o commands src/commands/commands.go
subcommands/gc: **/**/**/gc.go
go build -a -o subcommands/gc src/subcommands/gc/gc.go
subcommands/purge-cache: **/**/**/purge-cache.go
go build -a -o subcommands/purge-cache src/subcommands/purge-cache/purge-cache.go
clean:
rm -f commands
rm -rf commands subcommands

View File

@@ -1,15 +0,0 @@
#!/usr/bin/env bash
[[ " help repo:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
source "$PLUGIN_AVAILABLE_PATH/repo/internal-functions"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
case "$1" in
help | repo:help)
repo_help_cmd "$@"
;;
*)
exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
;;
esac

View File

@@ -33,10 +33,6 @@ func main() {
usage()
case "help":
fmt.Print(helpContent)
case "repo:gc":
gitGC()
case "repo:purge-cache":
purgeCache()
default:
dokkuNotImplementExitCode, err := strconv.Atoi(os.Getenv("DOKKU_NOT_IMPLEMENTED_EXIT"))
if err != nil {

View File

@@ -8,7 +8,7 @@ import (
)
// runs 'git gc --aggressive' against the application's repo
func gitGC() {
func main() {
flag.Parse()
appName := flag.Arg(1)
if appName == "" {

View File

@@ -9,7 +9,7 @@ import (
)
// deletes the contents of the build cache stored in the repository
func purgeCache() {
func main() {
flag.Parse()
appName := flag.Arg(1)
if appName == "" {

View File

@@ -1,15 +0,0 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
repo_gc() {
declare desc="runs 'git gc --aggressive' against the application's repo"
local cmd="repo:gc"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
local APP="$2"; local APP_DIR="$DOKKU_ROOT/$APP"
verify_app_name "$APP"
GIT_DIR="$APP_DIR" git gc --aggressive
}
repo_gc "$@"