Skip to content

Commit

Permalink
Merge pull request #2399 from replicatedhq/skaffold-profile-enable-dlv
Browse files Browse the repository at this point in the history
Skaffold profile to enable delve
  • Loading branch information
emosbaugh committed Dec 10, 2021
2 parents ccca8a0 + 7ca02f3 commit 4a4be66
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
10 changes: 5 additions & 5 deletions Makefile.build
Expand Up @@ -24,24 +24,24 @@ define GIT_SHA
endef
endif

ifndef DEBUG_KOTSADM
ifeq ("$(DEBUG_KOTSADM)", "1")
define LDFLAGS
-ldflags "\
-s -w \
-X ${VERSION_PACKAGE}.version=${VERSION} \
-X ${VERSION_PACKAGE}.gitSHA=${GIT_SHA} \
-X ${VERSION_PACKAGE}.buildTime=${DATE} \
"
endef
define GCFLAGS
-gcflags="all=-N -l"
endef
else
define LDFLAGS
-ldflags "\
-s -w \
-X ${VERSION_PACKAGE}.version=${VERSION} \
-X ${VERSION_PACKAGE}.gitSHA=${GIT_SHA} \
-X ${VERSION_PACKAGE}.buildTime=${DATE} \
"
endef
define GCFLAGS
-gcflags="all=-N -l"
endef
endif
6 changes: 6 additions & 0 deletions hack/CONTRIBUTING.md
Expand Up @@ -25,6 +25,12 @@ Next, you can build and run all server components in the Kubernetes cluster with
skaffold dev
```

To enable delve run:

```
DEBUG_KOTSADM=1 skaffold dev
```

## Notes:
- Go code will not be rebuilt automatically. Run `make kotsadm` again to make the new binary and restart the pod.
- After installing restic/velero, `kubectl -n velero edit daemonset restic` to change the volume hostPath mount from:
Expand Down
14 changes: 11 additions & 3 deletions hack/dev/Dockerfile.skaffold
Expand Up @@ -12,9 +12,12 @@ COPY web/webcontent.go ./web/webcontent.go
COPY web/dist ./web/dist
COPY kotskinds ./kotskinds

RUN DEBUG_KOTSADM="true" make kotsadm
ARG DEBUG_KOTSADM=0

RUN make kotsadm

FROM debian:buster

RUN apt-get update && apt-get install -y --no-install-recommends curl gnupg2 \
&& curl -k https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main" > /etc/apt/sources.list.d/PostgreSQL.list \
Expand Down Expand Up @@ -165,5 +168,10 @@ COPY --from=builder /go/src/github.com/replicatedhq/kots/bin/kotsadm .
EXPOSE 40000

# Should be entrypoint
ENTRYPOINT [ "/dlv", "--listen=:40000", "--continue", "--headless=true", "--api-version=2", "--accept-multiclient", "exec"]
CMD ["/kotsadm", "api"]

ARG DEBUG_KOTSADM=0

ENV DEBUG_KOTSADM=${DEBUG_KOTSADM}

ADD hack/dev/entrypoint.sh .
ENTRYPOINT [ "./entrypoint.sh"]
7 changes: 7 additions & 0 deletions hack/dev/entrypoint.sh
@@ -0,0 +1,7 @@
#!/bin/bash

if [ "$DEBUG_KOTSADM" = "1" ]; then
/dlv --listen=:40000 --continue --headless=true --api-version=2 --accept-multiclient exec /kotsadm api
else
/kotsadm api
fi
10 changes: 9 additions & 1 deletion skaffold.yaml
Expand Up @@ -9,9 +9,17 @@ profiles:
kustomize:
paths:
- "./kustomize/overlays/kotsstore"
- name: debug
activation:
- env: DEBUG_KOTSADM=1
patches:
- op: add
path: /build/artifacts/1/docker/buildArgs
value:
DEBUG_KOTSADM: 1
- name: codespace
activation:
- env: USER=codespace
- env: USER=codespace
build:
local:
concurrency: 0
Expand Down

0 comments on commit 4a4be66

Please sign in to comment.