diff --git a/Dockerfile b/Dockerfile index 822928ca4..70d7de3a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,6 +30,11 @@ COPY pkg/ pkg/ # Build RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /usr/local/bin/manager +FROM builder as debug + +RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go install github.com/go-delve/delve/cmd/dlv@latest + +CMD ["/go/bin/dlv", "--listen=:40000", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "/usr/local/bin/manager"] FROM gcr.io/distroless/static:latest@sha256:6706c73aae2afaa8201d63cc3dda48753c09bcd6c300762251065c0f7e602b25 diff --git a/Makefile b/Makefile index 024943029..2b42a62b9 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ GOVERSION := $(shell go env GOVERSION) # Image name to use for building/pushing image targets IMG ?= controller:local +IMG_DEBUG ?= controller:debug # Produce CRDs that work back to Kubernetes 1.11 (no version conversion) CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false,maxDescLen=0" @@ -79,6 +80,10 @@ docker-build: ## Build the docker image @echo "updating kustomize image patch file for manager resource" sed -i'' -e 's@image: .*@image: '"${IMG}"'@' ./config/default/manager_image_patch.yaml +.PHONY: docker-build-debug +docker-build-debug: ## Build the debug docker image + ${DOCKER} build --target debug -t ${IMG_DEBUG} . + .PHONY: docker-build-drain-watch docker-build-drain-watch: ## Build the drain-watch docker image ${DOCKER} build drain-watch-image -t ${DRAIN_WATCH_IMAGE_TAG_NAME}:${DRAIN_WATCH_IMAGE_TAG_VERSION}