Rework the Dockerfile for Go modules

Signed-off-by: Cosmin Cojocar <cosmin.cojocar@gmx.ch>
This commit is contained in:
Cosmin Cojocar 2019-04-25 12:48:22 +02:00 committed by Cosmin Cojocar
parent 806908a805
commit 7935fd85b9
2 changed files with 14 additions and 11 deletions

View file

@ -1,11 +1,14 @@
FROM golang:1.11.5-alpine3.9 as build ARG GO_VERSION=1.12
WORKDIR /go/src/github.com/securego/gosec FROM golang:${GO_VERSION}-alpine AS builder
COPY . . RUN apk add --update --no-cache ca-certificates make git curl
RUN apk add -U git make RUN mkdir -p /build
RUN go get -u github.com/golang/dep/cmd/dep WORKDIR /build
RUN make COPY . /build/
RUN go mod download
RUN make build-linux
FROM golang:1.11.5-alpine3.9 FROM golang:${GO_VERSION}-alpine
RUN apk add -U gcc musl-dev RUN apk add --update --no-cache ca-certificates git
COPY --from=build /go/src/github.com/securego/gosec/gosec /usr/local/bin/gosec ENV GO111MODULE on
ENTRYPOINT ["gosec"] COPY --from=builder /build/gosec /bin/gosec
ENTRYPOINT ["/bin/gosec"]

View file

@ -2,7 +2,7 @@ GIT_TAG?= $(shell git describe --always --tags)
BIN = gosec BIN = gosec
FMT_CMD = $(gofmt -s -l -w $(find . -type f -name '*.go' -not -path './vendor/*') | tee /dev/stderr) FMT_CMD = $(gofmt -s -l -w $(find . -type f -name '*.go' -not -path './vendor/*') | tee /dev/stderr)
IMAGE_REPO = securego IMAGE_REPO = securego
BUILDFLAGS := '' BUILDFLAGS := '-w -s'
CGO_ENABLED = 0 CGO_ENABLED = 0
default: default: