Skip to content

Commit 7935fd8

Browse files
ccojocarCosmin Cojocar
authored andcommitted
Rework the Dockerfile for Go modules
Signed-off-by: Cosmin Cojocar <[email protected]>
1 parent 806908a commit 7935fd8

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

Dockerfile

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
FROM golang:1.11.5-alpine3.9 as build
2-
WORKDIR /go/src/github.com/securego/gosec
3-
COPY . .
4-
RUN apk add -U git make
5-
RUN go get -u github.com/golang/dep/cmd/dep
6-
RUN make
1+
ARG GO_VERSION=1.12
2+
FROM golang:${GO_VERSION}-alpine AS builder
3+
RUN apk add --update --no-cache ca-certificates make git curl
4+
RUN mkdir -p /build
5+
WORKDIR /build
6+
COPY . /build/
7+
RUN go mod download
8+
RUN make build-linux
79

8-
FROM golang:1.11.5-alpine3.9
9-
RUN apk add -U gcc musl-dev
10-
COPY --from=build /go/src/github.com/securego/gosec/gosec /usr/local/bin/gosec
11-
ENTRYPOINT ["gosec"]
10+
FROM golang:${GO_VERSION}-alpine
11+
RUN apk add --update --no-cache ca-certificates git
12+
ENV GO111MODULE on
13+
COPY --from=builder /build/gosec /bin/gosec
14+
ENTRYPOINT ["/bin/gosec"]

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ GIT_TAG?= $(shell git describe --always --tags)
22
BIN = gosec
33
FMT_CMD = $(gofmt -s -l -w $(find . -type f -name '*.go' -not -path './vendor/*') | tee /dev/stderr)
44
IMAGE_REPO = securego
5-
BUILDFLAGS := ''
5+
BUILDFLAGS := '-w -s'
66
CGO_ENABLED = 0
77

88
default:

0 commit comments

Comments
 (0)