From b7e87641a69a3face2d760e0a4dc7118c93202a2 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Sat, 10 Oct 2015 22:32:38 +0200 Subject: [PATCH 1/2] Add Makefile --- .gitignore | 1 + Makefile | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index f707010..ef71393 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/gotty-client /dist # Compiled Object files, Static and Dynamic libs (Shared Objects) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b379605 --- /dev/null +++ b/Makefile @@ -0,0 +1,34 @@ +COMMANDS := $(addprefix ./,$(wildcard cmd/*)) +PACKAGES := . +VERSION := $(shell cat .goxc.json | jq -c .PackageVersion | sed 's/"//g') +SOURCES := $(shell find . -name "*.go") + + +.PHONY: build +build: $(notdir $(COMMANDS)) + + +.PHONY: build-docker +build-docker: contrib/docker/.docker-container-built + + +$(notdir $(COMMANDS)): $(SOURCES) + gofmt -w $(PACKAGES) ./cmd/$@ + go test -i $(PACKAGES) ./cmd/$@ + go build -o $@ ./cmd/$@ + @# ./$@ --version + + +.PHONY: clean +clean: + rm -f $(notdir $(COMMANDS)) + + +.PHONY: install +install: + go install $(COMMANDS) + + +.PHONY: release +release: + goxc From b8785aa33976a58de9e66e7e337b501cc7a3b4ef Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Sat, 10 Oct 2015 22:40:05 +0200 Subject: [PATCH 2/2] Add Docker support (fix #7) --- .gitignore | 2 +- Makefile | 49 ++++++++++++++++++++++++++++++--------- contrib/docker/Dockerfile | 5 ++++ 3 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 contrib/docker/Dockerfile diff --git a/.gitignore b/.gitignore index ef71393..53cf198 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -/gotty-client +gotty-client /dist # Compiled Object files, Static and Dynamic libs (Shared Objects) diff --git a/Makefile b/Makefile index b379605..7072065 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ -COMMANDS := $(addprefix ./,$(wildcard cmd/*)) -PACKAGES := . -VERSION := $(shell cat .goxc.json | jq -c .PackageVersion | sed 's/"//g') -SOURCES := $(shell find . -name "*.go") +COMMANDS := $(addprefix ./,$(wildcard cmd/*)) +PACKAGES := . +VERSION := $(shell cat .goxc.json | jq -c .PackageVersion | sed 's/"//g') +SOURCES := $(shell find . -name "*.go") +GOTTY_URL := http://localhost:8080 .PHONY: build @@ -12,13 +13,6 @@ build: $(notdir $(COMMANDS)) build-docker: contrib/docker/.docker-container-built -$(notdir $(COMMANDS)): $(SOURCES) - gofmt -w $(PACKAGES) ./cmd/$@ - go test -i $(PACKAGES) ./cmd/$@ - go build -o $@ ./cmd/$@ - @# ./$@ --version - - .PHONY: clean clean: rm -f $(notdir $(COMMANDS)) @@ -32,3 +26,36 @@ install: .PHONY: release release: goxc + + +.PHONY: build-docker +build-docker: contrib/docker/.docker-container-built + + +.PHONY: run-docker +run-docker: build-docker + docker run -it --rm moul/gotty-client $(GOTTY_URL) + + +$(notdir $(COMMANDS)): $(SOURCES) + gofmt -w $(PACKAGES) ./cmd/$@ + go test -i $(PACKAGES) ./cmd/$@ + go build -o $@ ./cmd/$@ + @# ./$@ --version + + +dist/latest/gotty-client_latest_linux_386: $(SOURCES) + mkdir -p dist + rm -f dist/latest + (cd dist; ln -s $(VERSION) latest) + goxc -bc="linux,386" xc + cp dist/latest/gotty-client_$(VERSION)_linux_386 dist/latest/gotty-client_latest_linux_386 + + +contrib/docker/.docker-container-built: dist/latest/gotty-client_latest_linux_386 + cp dist/latest/gotty-client_latest_linux_386 contrib/docker/gotty-client + docker build -t moul/gotty-client:latest contrib/docker + docker tag moul/gotty-client:latest moul/gotty-client:$(VERSION) + docker run -it --rm moul/gotty-client --version + docker inspect --type=image --format="{{ .Id }}" moul/gotty-client > $@.tmp + mv $@.tmp $@ diff --git a/contrib/docker/Dockerfile b/contrib/docker/Dockerfile new file mode 100644 index 0000000..420997d --- /dev/null +++ b/contrib/docker/Dockerfile @@ -0,0 +1,5 @@ +FROM scratch + +ADD ./gotty-client /gotty-client + +ENTRYPOINT ["/gotty-client"]