Skip to content

Commit 124cdd1

Browse files
authored
Merge pull request zalando#217 from erthalion/feature/debug-mode
Add debug mode
2 parents a3c840d + 09abdce commit 124cdd1

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

Makefile

+12-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ endif
1010

1111
LOCAL_BUILD_FLAGS ?= $(BUILD_FLAGS)
1212
LDFLAGS ?= -X=main.version=$(VERSION)
13-
DOCKERFILE = docker/Dockerfile
13+
DOCKERDIR = docker
14+
1415
IMAGE ?= registry.opensource.zalan.do/acid/$(BINARY)
1516
TAG ?= $(VERSION)
1617
GITHEAD = $(shell git rev-parse --short HEAD)
@@ -21,6 +22,14 @@ VERSION ?= $(shell git describe --tags --always --dirty)
2122
DIRS := cmd pkg
2223
PKG := `go list ./... | grep -v /vendor/`
2324

25+
ifeq ($(DEBUG),1)
26+
DOCKERFILE = DebugDockerfile
27+
DEBUG_POSTFIX := -debug
28+
BUILD_FLAGS += -gcflags "-N -l"
29+
else
30+
DOCKERFILE = Dockerfile
31+
endif
32+
2433
PATH := $(GOPATH)/bin:$(PATH)
2534
SHELL := env PATH=$(PATH) $(SHELL)
2635

@@ -42,8 +51,8 @@ docker-context: scm-source.json linux
4251
mkdir -p docker/build/
4352
cp build/linux/${BINARY} scm-source.json docker/build/
4453

45-
docker: ${DOCKERFILE} docker-context
46-
cd docker && docker build --rm -t "$(IMAGE):$(TAG)" .
54+
docker: ${DOCKERDIR}/${DOCKERFILE} docker-context
55+
cd "${DOCKERDIR}" && docker build --rm -t "$(IMAGE):$(TAG)$(DEBUG_POSTFIX)" -f "${DOCKERFILE}" .
4756

4857
indocker-race:
4958
docker run --rm -v "${GOPATH}":"${GOPATH}" -e GOPATH="${GOPATH}" -e RACE=1 -w ${PWD} golang:1.8.1 bash -c "make linux"

docker/DebugDockerfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM alpine
2+
MAINTAINER Team ACID @ Zalando <[email protected]>
3+
4+
# We need root certificates to deal with teams api over https
5+
RUN apk --no-cache add ca-certificates go git musl-dev
6+
RUN go get github.com/derekparker/delve/cmd/dlv
7+
8+
COPY build/* /
9+
10+
CMD ["/root/go/bin/dlv", "--listen=:777", "--headless=true", "--api-version=2", "exec", "/postgres-operator"]

0 commit comments

Comments
 (0)