1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Merge branch 'patch-1' of github.com:firecat53/wtf into firecat53-patch-1

This commit is contained in:
Chris Cummer 2020-01-28 04:07:13 -08:00
commit 9551428908
4 changed files with 68 additions and 7 deletions

View File

@ -1,8 +1,11 @@
FROM golang:1.13-alpine FROM golang:1.13-alpine as build
RUN apk add --no-cache make ncurses ARG version=master
COPY . $GOPATH/src/github.com/wtfutil/wtf RUN apk add git make ncurses && \
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 GOPROXY=https://proxy.golang.org,direct
ENV GO111MODULE=on ENV GO111MODULE=on
@ -14,4 +17,10 @@ ENV PATH=$PATH:./bin
RUN make build RUN make build
ENTRYPOINT "wtfutil" FROM alpine
COPY --from=build /go/src/github.com/wtfutil/wtf/bin/wtfutil /usr/local/bin/
RUN adduser -h /config -DG users -u 20000 wtf
USER wtf
ENTRYPOINT ["wtfutil"]

18
Dockerfile.build Normal file
View File

@ -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/

View File

@ -1,4 +1,4 @@
.PHONY: build clean contrib_check coverage help install isntall lint run size test uninstall .PHONY: build clean contrib_check coverage docker-build docker-install help install isntall lint run size test uninstall
# detect GOPATH if not set # detect GOPATH if not set
ifndef $(GOPATH) ifndef $(GOPATH)
@ -48,6 +48,21 @@ coverage:
go test -coverprofile=coverage.out ./... go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out go tool cover -html=coverage.out
## docker-build: builds in docker
docker-build:
@echo "Building ${APP} in Docker..."
docker build -t wtfutil:build --build-arg=version=master -f Dockerfile.build .
@echo "Done with docker build"
## docker-install: installs a local version of the app from docker build
docker-install:
@echo "Installing ${APP}..."
docker create --name wtf_build wtfutil:build
docker cp wtf_build:/usr/local/bin/wtfutil ~/.local/bin/
$(eval INSTALLPATH = $(shell which ${APP}))
@echo "${APP} installed into ${INSTALLPATH}"
docker rm wtf_build
## gosec: runs the gosec static security scanner against the source code ## gosec: runs the gosec static security scanner against the source code
gosec: gosec:
gosec -tests ./... gosec -tests ./...

View File

@ -115,6 +115,19 @@ make install
make run 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. **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 ## Running via Docker
@ -122,14 +135,20 @@ make run
You can run `wtf` inside a docker container: You can run `wtf` inside a docker container:
```bash ```bash
# download the source # download or create the Dockerfile
git clone https://github.com/wtfutil/wtf curl -o Dockerfile https://raw.githubusercontent.com/wtfutil/wtf/master/Dockerfile
# build the docker container # build the docker container
docker build -t wtfutil . docker build -t wtfutil .
# or for a particular tag or branch
docker build --build-args=version=v0.25.0 -t wtfutil .
# run the container # run the container
docker run -it wtfutil docker run -it wtfutil
# run container with a local config file
docker run -it -v path/to/config.yml:/config/config.yml wtfutil --config=/config/config.yml
``` ```
## Communication ## Communication