From 571526b9938dfdd4067be559a4fd66ec444a7c24 Mon Sep 17 00:00:00 2001 From: Scott Hansen Date: Sun, 12 Jan 2020 16:22:55 -0800 Subject: [PATCH] Add build Dockerfile to build wtfutil from source in Docker and then copy binary to local machine --- Dockerfile.build | 18 ++++++++++++++++++ README.md | 13 +++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 Dockerfile.build diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 00000000..7e672aab --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,18 @@ +FROM golang:1.13 as build + +ARG version=master + +RUN git clone https://github.com/wtfutil/wtf.git $GOPATH/src/github.com/wtfutil/wtf && \ + cd $GOPATH/src/github.com/wtfutil/wtf && \ + git checkout $version + +ENV GOPROXY=https://proxy.golang.org,direct +ENV GO111MODULE=on +ENV GOSUMDB=off + +WORKDIR $GOPATH/src/github.com/wtfutil/wtf + +ENV PATH=$PATH:./bin + +RUN make build && \ + cp bin/wtfutil /usr/local/bin/ diff --git a/README.md b/README.md index eab37e2f..a30fc078 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,19 @@ make install make run ``` +### Installing from Source using Docker + +All building is done inside a docker container. You can then copy the binary to +your local machine. + +```bash +curl -o Dockerfile.build https://raw.githubusercontent.com/wtfutil/wtf/master/Dockerfile.build +docker build -f Dockerfile.build -t wtfutil --build-args=version=master . +docker create --name wtf_build wtfutil +docker cp wtf_build:/usr/local/bin/wtfutil ~/.local/bin +docker rm wtf_build +``` + **Note:** WTF is _only_ compatible with Go versions **1.12.0** or later (due to the use of Go modules and newer standard library functions). If you would like to use `gccgo` to compile, you _must_ use `gccgo-9` or later which introduces support for Go modules. ## Running via Docker