content: # Dockerfile for Inspektor Gadget.
  
  ARG BUILDER_IMAGE=golang:1.24.6-bullseye@sha256:75fd40c4f96cdec80e57a948b95ce06fb77531e776c4e338472315497f7847e8
  ARG BASE_IMAGE=gcr.io/distroless/static-debian12@sha256:ce46866b3a5170db3b49364900fb3168dc0833dfb46c26da5c77f22abb01d8c3
  
  # Prepare and build gadget artifacts in a container
  FROM --platform=${BUILDPLATFORM} ${BUILDER_IMAGE} AS builder
  
  ARG TARGETARCH
  ARG BUILDARCH
  ARG VERSION=v0.0.0
  ENV VERSION=${VERSION}
  
  ARG GOPROXY
  ENV GOPROXY=${GOPROXY}
  
  # Cache go modules so they won't be downloaded at each build
  COPY go.mod go.sum /gadget/
  RUN cd /gadget && go mod download
  
  # This COPY is limited by .dockerignore
  COPY ./ /gadget
  RUN \
      --mount=type=cache,target=/root/.cache/go-build \
      --mount=type=cache,target=/go/pkg \
      cd /gadget/gadget-container && \
  	make -j$(nproc) TARGET_ARCH=${TARGETARCH} gadget-container-deps
  
  # Main gadget image
  FROM ${BASE_IMAGE}
  
  LABEL org.opencontainers.image.source=https://github.com/inspektor-gadget/inspektor-gadget
  LABEL org.opencontainers.image.title="Inspektor Gadget k8s DaemonSet"
  LABEL org.opencontainers.image.description="Inspektor Gadget is a collection of tools (or gadgets) to debug and inspect Kubernetes resources and applications. This image is used as a long-running DaemonSet in Kubernetes via the kubectl-gadget deploy command or via the Helm charts."
  LABEL org.opencontainers.image.documentation="https://inspektor-gadget.io/docs"
  LABEL org.opencontainers.image.licenses=Apache-2.0
  
  COPY --from=builder /gadget/gadget-container/bin/cleanup /
  
  COPY --from=builder /gadget/gadget-container/bin/gadgettracermanager /bin/
  
  ## Hooks Begins
  
  # OCI
  COPY gadget-container/hooks/oci/prestart.sh gadget-container/hooks/oci/poststop.sh /opt/hooks/oci/
  COPY --from=builder /gadget/gadget-container/bin/ocihookgadget /opt/hooks/oci/
  
  # cri-o
  COPY gadget-container/hooks/crio/gadget-prestart.json gadget-container/hooks/crio/gadget-poststop.json /opt/hooks/crio/
  
  # nri
  COPY --from=builder /gadget/gadget-container/bin/nrigadget /opt/hooks/nri/
  COPY gadget-container/hooks/nri/conf.json /opt/hooks/nri/
  
  ## Hooks Ends
  