diff --git a/.gitignore b/.gitignore index 3b0ce5d..da0bf3e 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,6 @@ # Files without extension (Linux binary, for example) * !Makefile - +!Dockerfile # Golang vendor directory vendor/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7c6feed --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM golang:1.11.3 + +ADD ./ $GOPATH/src/Ethr + +RUN mkdir /out + +WORKDIR $GOPATH/src/Ethr + +RUN go get -u github.com/golang/dep/cmd/dep +RUN dep ensure -v diff --git a/Makefile b/Makefile index e84597a..ac2b94b 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,10 @@ fmt: do $(GO_FMT) -w -s "$$file"; \ done +.PHONY: build-docker +build-docker: + $(GO_BIN) build -o /out/$(BINARY_NAME) + .PHONY: build build: $(GO_BIN) build -o $(BINARY_NAME) . diff --git a/README.md b/README.md index c32f97a..aa4150e 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,26 @@ dep ensure -v go build ``` +## Docker + +Build image using command: +``` +docker build -t microsoft/ethr . +``` + +Make binary: + +**Linux** +``` +docker run -e GOOS=linux -v $(pwd):/out microsoft/ethr make build-docker +``` + +**Windows** + +``` +docker run -e BINARY_NAME=ethr.exe -e GOOS=windows -v $(pwd):/out microsoft/ethr make build-docker +``` + ## Using go get ```