From 8fa9f0cf28ecc55c969432062cf8fa7db412882e Mon Sep 17 00:00:00 2001 From: Jeremy Unruh Date: Mon, 28 Mar 2016 13:44:48 -0700 Subject: [PATCH] Fix Makefile copy command. Add docker support - run a depcon docker image --- Makefile | 13 +++++++++++-- README.md | 5 +++++ cliconfig/create_environment.go | 11 ++++++++--- docker-release/.gitignore | 1 + docker-release/Dockerfile | 10 ++++++++++ docker-release/env.sample | 6 ++++++ 6 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 docker-release/.gitignore create mode 100644 docker-release/Dockerfile create mode 100644 docker-release/env.sample diff --git a/Makefile b/Makefile index c18b0e1..cd5785a 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = 0.8.1 +VERSION = 0.8.2 GO_FMT = gofmt -s -w -l . GO_XC = goxc -os="linux darwin windows" -tasks-="rmbin" @@ -20,7 +20,7 @@ goxc: $(shell echo ' "include": "*.zip,*.tar.gz,*.deb,depcon_$(VERSION)_linux_amd64-bin"' >> $(GOXC_FILE)) $(shell echo ' }\n } \n}' >> $(GOXC_FILE)) $(GO_XC) - cp build/$(VERSION)/linux_amd64/depcon build/$(VERSION)/depcon_0.8.1_linux_amd64-bin + cp build/$(VERSION)/linux_amd64/depcon build/$(VERSION)/depcon_$(VERSION)_linux_amd64-bin deps: go get @@ -33,3 +33,12 @@ bintray: github: $(GO_XC) publish-github + +docker-build: + cp build/$(VERSION)/linux_amd64/depcon docker-release/depcon + docker build -t pacesys/depcon docker-release/ + docker tag pacesys/depcon pacesys/depcon:$(VERSION) + +docker-push: + docker push pacesys/depcon + docker push pacesys/depcon:$(VERSION) diff --git a/README.md b/README.md index 3f13ef3..3bb0cbc 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,11 @@ To update Depcon's dependencies, use `go get` with the `-u` option. go get -u -v github.com/gondor/depcon +### Running Depcon in Docker + +With each release we publish a very small docker image containing depcon. For instructions in testing depcon within docker (useful for CI systems) see the docker hub repository at: https://hub.docker.com/r/pacesys/depcon/ + + ## Global options in Depcon #### Output Options diff --git a/cliconfig/create_environment.go b/cliconfig/create_environment.go index d799933..9cabfb0 100644 --- a/cliconfig/create_environment.go +++ b/cliconfig/create_environment.go @@ -6,6 +6,7 @@ import ( "github.com/gondor/depcon/utils" "net/url" "regexp" + "os" ) const ( @@ -50,7 +51,11 @@ func getPasswordWithVerify() string { } // Asks the user for the remote URI of the Marathon service -func getMarathonURL() string { +func getMarathonURL(count int) string { + if count > 5 { + fmt.Printf("Too many retries obtaining Marathon URL. If depcon is running within docker please insure 'docker run -it' is set.\n") + os.Exit(1) + } var response string fmt.Print("Marathon URL (eg. http://hostname:8080) : ") fmt.Scanf("%s", &response) @@ -61,13 +66,13 @@ func getMarathonURL() string { } fmt.Printf("\nERROR: '%s' must be a valid URL\n", response) - return getMarathonURL() + return getMarathonURL(count+1) } func createEnvironment() *ServiceConfig { service := ServiceConfig{} service.Name = getAlpaNumDash("Environment Name (eg. test, stage, prod) ") - service.HostUrl = getMarathonURL() + service.HostUrl = getMarathonURL(0) if getBoolAnswer("Authentication Required", false) { service.Username = getAlpaNumDash("Username") diff --git a/docker-release/.gitignore b/docker-release/.gitignore new file mode 100644 index 0000000..1789332 --- /dev/null +++ b/docker-release/.gitignore @@ -0,0 +1 @@ +depcon diff --git a/docker-release/Dockerfile b/docker-release/Dockerfile new file mode 100644 index 0000000..2e229ad --- /dev/null +++ b/docker-release/Dockerfile @@ -0,0 +1,10 @@ +FROM alpine + +ADD depcon /usr/bin + +ENV DEPCON_MODE="" \ + MARATHON_HOST="http://localhost:8080" \ + MARATHON_USER="" \ + MARATHON_PASS="" + +ENTRYPOINT ["/usr/bin/depcon"] \ No newline at end of file diff --git a/docker-release/env.sample b/docker-release/env.sample new file mode 100644 index 0000000..ebf2aa3 --- /dev/null +++ b/docker-release/env.sample @@ -0,0 +1,6 @@ +DEPCON_MODE=marathon +MARATHON_HOST=http://hostname:8080 + +# Uncomment below if authentication is enabled within Marathon +#MARATHON_USER=someuser +#MARATHON_PASS=somepass