From 9004da1ebe2d9d9fade81a00b278ba3d06d45150 Mon Sep 17 00:00:00 2001 From: Matheus Alcantara Date: Mon, 6 Dec 2021 11:12:13 -0300 Subject: [PATCH] deployments/Dockerfile:chore - improve approach to build cli 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 --- deployments/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deployments/Dockerfile b/deployments/Dockerfile index 489f9518e..d77d72163 100644 --- a/deployments/Dockerfile +++ b/deployments/Dockerfile @@ -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" ] \ No newline at end of file +CMD [ "sh" ]