Skip to content

Commit 63094c9

Browse files
committed
Merge branch 'dle-docker-debug' into 'master'
feat(engine): debug DLE locally in Docker container See merge request postgres-ai/database-lab!548
2 parents 340e5f8 + 0fa6871 commit 63094c9

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

engine/Dockerfile.dblab-server-debug

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# How to start a container: https://postgres.ai/docs/how-to-guides/administration/engine-manage
2+
3+
# Compile stage
4+
FROM golang:1.18 AS build-env
5+
6+
# Build Delve
7+
RUN go install github.com/go-delve/delve/cmd/dlv@latest
8+
9+
# Build DLE (Uncomment if the binary doesn't compile locally).
10+
# ADD . /dockerdev
11+
# WORKDIR /dockerdev
12+
# RUN GO111MODULE=on CGO_ENABLED=0 go build -gcflags="all=-N -l" -o /dblab-server-debug ./cmd/database-lab/main.go
13+
14+
# Final stage
15+
FROM docker:20.10.12
16+
17+
# Install dependencies
18+
RUN apk update \
19+
&& apk add zfs=2.1.4-r0 --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/main \
20+
&& apk add --no-cache lvm2 bash util-linux
21+
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.13/main' >> /etc/apk/repositories \
22+
&& echo 'http://dl-cdn.alpinelinux.org/alpine/v3.13/community' >> /etc/apk/repositories \
23+
&& apk add bcc-tools=0.18.0-r0 bcc-doc=0.18.0-r0 && ln -s $(which python3) /usr/bin/python \
24+
# TODO: remove after release the PR: https://github.com/iovisor/bcc/pull/3286 (issue: https://github.com/iovisor/bcc/issues/3099)
25+
&& wget https://raw.githubusercontent.com/iovisor/bcc/master/tools/biosnoop.py -O /usr/share/bcc/tools/biosnoop
26+
27+
ENV PATH="${PATH}:/usr/share/bcc/tools"
28+
29+
WORKDIR /home/dblab
30+
31+
EXPOSE 2345 40000
32+
33+
# Replace if the binary doesn't compile locally.
34+
# COPY --from=build-env /dblab-server-debug ./bin/dblab-server-debug
35+
COPY ./bin/dblab-server-debug ./bin/dblab-server-debug
36+
37+
COPY --from=build-env /go/bin/dlv ./
38+
COPY ./configs/standard ./standard
39+
COPY ./api ./api
40+
COPY ./scripts ./scripts
41+
42+
CMD ["./dlv", "--listen=:40000", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "./bin/dblab-server-debug"]

engine/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ build: ## Build binary files of all Database Lab components (Engine, CI Checker,
4444
${GOBUILD} -o bin/${RUN_CI_BINARY} ./cmd/runci/main.go
4545
${GOBUILD} -o bin/${CLI_BINARY} ./cmd/cli/main.go
4646

47+
build-debug: ## Build the Database Lab Server binary for debugging
48+
${GOBUILD} -ldflags "-X gitlab.com/postgres-ai/database-lab/v3/version.version=${VERSION} \
49+
-X gitlab.com/postgres-ai/database-lab/v3/version.buildTime=${BUILD_TIME}" \
50+
-gcflags="all=-N -l" -o bin/${SERVER_BINARY}-debug ./cmd/database-lab/main.go
51+
4752
build-ci-checker: ## Build the Database Lab CI Checker binary
4853
${GOBUILD} -o bin/${RUN_CI_BINARY} ./cmd/runci/main.go
4954

0 commit comments

Comments
 (0)