From c4738ef26fe46d84dddd1a138aacae326b05736e Mon Sep 17 00:00:00 2001 From: zcong1993 <1005997919@qq.com> Date: Fri, 23 Feb 2018 11:52:41 +0800 Subject: [PATCH 1/2] reduce docker image size --- Dockerfile | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7a9cba68..63c3aee9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,24 @@ -FROM golang:1.10.0-alpine3.7 +FROM golang:1.10.0 AS build -WORKDIR /app +ENV PROJECT /go/src/github.com/zricethezav/gitleaks + +RUN mkdir -p $PROJECT + +WORKDIR ${PROJECT} + +RUN git clone https://github.com/zricethezav/gitleaks.git . \ + && CGO_ENABLED=0 go build -o bin/gitleaks *.go + +FROM alpine:3.7 + +ENV PROJECT /go/src/github.com/zricethezav/gitleaks RUN apk update && apk upgrade && apk add --no-cache bash git openssh -COPY . ./ - -RUN go get -u github.com/zricethezav/gitleaks -RUN go build +COPY --from=build $PROJECT/bin/* /usr/bin/ ENTRYPOINT ["gitleaks"] - # How to use me : # docker build -t gitleaks . From 780123c5be07c66d65dd610c76514d4a2f3976a1 Mon Sep 17 00:00:00 2001 From: zcong1993 <1005997919@qq.com> Date: Fri, 23 Feb 2018 12:08:52 +0800 Subject: [PATCH 2/2] add docker WORKDIR --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 63c3aee9..20cef68e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,8 @@ FROM alpine:3.7 ENV PROJECT /go/src/github.com/zricethezav/gitleaks +WORKDIR /app + RUN apk update && apk upgrade && apk add --no-cache bash git openssh COPY --from=build $PROJECT/bin/* /usr/bin/