Skip to content

Commit

Permalink
deployments/Dockerfile:chore - improve approach to build cli (#853)
Browse files Browse the repository at this point in the history
Previously we was download the dependencies using `go get`, but since we
are using go modules, a better approach should be use `go mod download`
to download and cache all dependencies.

This commit also add a new build flags on binary to remove debug
information which will make de final binary smaller.

Signed-off-by: Matheus Alcantara <matheus.alcantara@zup.com.br>
  • Loading branch information
matheusalcantarazup authored Dec 7, 2021
1 parent 4204e88 commit a96b0ae
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions deployments/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ RUN apk update && apk add --no-cache git
ADD . /horusec
WORKDIR /horusec

RUN go get -t -v -d ./...
RUN go mod download

RUN env GOOS=linux go build -o /bin/horusec ./cmd/app/main.go
RUN env GOOS=linux go build -ldflags '-s -w' -o /bin/horusec ./cmd/app/main.go

FROM docker:20.10-git

COPY --from=builder /bin/horusec /usr/local/bin
RUN chmod +x /usr/local/bin/horusec

CMD [ "sh" ]
CMD [ "sh" ]

0 comments on commit a96b0ae

Please sign in to comment.