diff --git a/Dockerfile b/Dockerfile index 838a65ae0d..d76b85399d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,27 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM golang:alpine@sha256:fd9d9d7194ec40a9a6ae89fcaef3e47c47de7746dd5848ab5343695dbbd09f8c +FROM golang:alpine@sha256:fd9d9d7194ec40a9a6ae89fcaef3e47c47de7746dd5848ab5343695dbbd09f8c AS builder -RUN mkdir /src WORKDIR /src - -COPY ./go.mod /src/go.mod -COPY ./go.sum /src/go.sum +COPY ./go.mod ./go.sum ./ RUN go mod download -COPY ./ /src/ +COPY ./ ./ RUN go build -o osv-scanner ./cmd/osv-scanner/ FROM alpine:3.18@sha256:82d1e9d7ed48a7523bdebc18cf6290bdb97b82302a8a9c27d4fe885949ea94d1 -RUN apk --no-cache add \ - ca-certificates \ - git -# Allow git to run on mounted directories -RUN git config --global --add safe.directory '*' +RUN apk --no-cache add ca-certificates git && \ + git config --global --add safe.directory '*' WORKDIR /root/ -COPY --from=0 /src/osv-scanner ./ +COPY --from=builder /src/osv-scanner . ENTRYPOINT ["/root/osv-scanner"]