Dockerfile 935 B

123456789101112131415161718192021222324
  1. FROM golang:1.18 AS build
  2. WORKDIR /go/src/github.com/zricethezav/gitleaks
  3. COPY . .
  4. RUN VERSION=$(git describe --tags --abbrev=0) && \
  5. CGO_ENABLED=0 go build -o bin/gitleaks -ldflags "-X="github.com/zricethezav/gitleaks/v8/cmd.Version=${VERSION}
  6. FROM alpine:3.15.4
  7. RUN adduser -D gitleaks && \
  8. apk add --no-cache bash git openssh-client
  9. COPY --from=build /go/src/github.com/zricethezav/gitleaks/bin/* /usr/bin/
  10. USER gitleaks
  11. # default to avoid the follow error:
  12. # 11:09PM ERR fatal: unsafe repository ('/path' is owned by someone else)
  13. # 11:09PM ERR To add an exception for this directory, call:
  14. # 11:09PM ERR
  15. # 11:09PM ERR git config --global --add safe.directory /path
  16. # This means that when you run gitleaks from docker you must mount to /path
  17. # in order to avoid this error.
  18. # TODO waiting to push this until I've thought a bit more about it
  19. # RUN git config --global --add safe.directory /path
  20. ENTRYPOINT ["gitleaks"]