Răsfoiți Sursa

reduce docker image size

zcong1993 8 ani în urmă
părinte
comite
c4738ef26f
1 a modificat fișierele cu 14 adăugiri și 7 ștergeri
  1. 14 7
      Dockerfile

+ 14 - 7
Dockerfile

@@ -1,16 +1,23 @@
-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 apk update && apk upgrade && apk add --no-cache bash git openssh
+RUN mkdir -p $PROJECT
 
-COPY . ./
+WORKDIR ${PROJECT}
 
-RUN go get -u github.com/zricethezav/gitleaks
-RUN go build
+RUN git clone https://github.com/zricethezav/gitleaks.git . \
+  && CGO_ENABLED=0 go build -o bin/gitleaks *.go
 
-ENTRYPOINT ["gitleaks"]
+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 --from=build $PROJECT/bin/* /usr/bin/
+
+ENTRYPOINT ["gitleaks"]
 
 # How to use me :