From 5f0f8f89a6d72d9163981f445321ed8edb61089a Mon Sep 17 00:00:00 2001 From: Amber Wiens Date: Thu, 3 Aug 2017 11:50:58 -0600 Subject: [PATCH 1/2] Adding Docker container and changing README --- Dockerfile | 22 ++++++++++++++++++++++ README.md | 17 +++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..a1aa448073 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +# Builds the Gas scanner with 'docker build' command, and runs Gas on all Go +# files in your current directory with 'docker run' command. +# +# Docker version must be 17.05 or higher to allow multistage build +# + +FROM golang:1.8.1-alpine as builder +ENV workspace /go/src/github.com/GoASTScanner/gas +COPY . $workspace +WORKDIR $workspace + +RUN go vet $(go list ./... | grep -v /vendor/) +RUN CGO_ENABLED=0 go build -o gas . + +FROM alpine:3.6 + +LABEL MAINTAINER="David Graves " + +COPY --from=builder /go/src/github.com/GoASTScanner/gas/gas / + +# Mounted directory should be placed into the workdir +CMD /gas $(find . -path ./vendor -prune -o -type f -name "*.go") diff --git a/README.md b/README.md index 23a824a91c..81c2ed5e3f 100644 --- a/README.md +++ b/README.md @@ -112,3 +112,20 @@ file. The output format is controlled by the '-fmt' flag, and the output file is # Write output in json format to results.json $ gas -fmt=json -out=results.json *.go ``` + +### Docker container + +A Dockerfile is included with the Gas source code to provide a container that +allows users to easily run Gas on their code. It builds Gas, then runs it on +all Go files in your current directory. Use the following commands to build +and run locally: + +To build: (run command in cloned Gas source code directory) + docker build --build-arg http_proxy --build-arg https_proxy + --build-arg no_proxy -t goastscanner/gas:latest . + +To run: (run command in desired directory with Go files) + docker run -v $PWD:$PWD --workdir $PWD goastscanner/gas:latest + +Note: Docker version 17.05 or later is required (to permit multistage build). +``` From b120a3ec3fc59b2fc58e793254b0cc4ab1496fbe Mon Sep 17 00:00:00 2001 From: Amber Wiens Date: Wed, 9 Aug 2017 13:00:19 -0600 Subject: [PATCH 2/2] Updating Dockerfile with requested changes --- Dockerfile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index a1aa448073..7fea92ca2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,21 @@ -# Builds the Gas scanner with 'docker build' command, and runs Gas on all Go -# files in your current directory with 'docker run' command. -# # Docker version must be 17.05 or higher to allow multistage build -# +# See build and run instructions in README.md +# Builds Gas for utilization FROM golang:1.8.1-alpine as builder ENV workspace /go/src/github.com/GoASTScanner/gas +ENV GOPATH /go COPY . $workspace WORKDIR $workspace RUN go vet $(go list ./... | grep -v /vendor/) RUN CGO_ENABLED=0 go build -o gas . -FROM alpine:3.6 +######################################################## -LABEL MAINTAINER="David Graves " +# Runs Gas on all Go files in the current directory when +# 'docker run' command in README is given +FROM alpine:3.6 COPY --from=builder /go/src/github.com/GoASTScanner/gas/gas /