Skip to content

Commit 2b76d1e

Browse files
committed
Make delve part of the Dockerfile staging
1 parent 7390ab5 commit 2b76d1e

File tree

4 files changed

+17
-40
lines changed

4 files changed

+17
-40
lines changed

docker/mongodb-agent/Dockerfile

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,20 @@
33
ARG init_database_image
44
FROM ${init_database_image} AS init_database
55

6-
FROM public.ecr.aws/docker/library/golang:1.24 AS dependency_downloader
7-
8-
WORKDIR /go/src/github.com/mongodb/mongodb-kubernetes/
9-
10-
COPY go.mod go.sum ./
11-
12-
RUN go mod download
13-
14-
FROM public.ecr.aws/docker/library/golang:1.24 AS readiness_builder
15-
16-
WORKDIR /go/src/github.com/mongodb/mongodb-kubernetes/
17-
18-
COPY --from=dependency_downloader /go/pkg /go/pkg
19-
COPY . /go/src/github.com/mongodb/mongodb-kubernetes
20-
21-
RUN CGO_ENABLED=0 GOFLAGS=-buildvcs=false go build -o /readinessprobe ./mongodb-community-operator/cmd/readiness/main.go
22-
RUN CGO_ENABLED=0 GOFLAGS=-buildvcs=false go build -o /version-upgrade-hook ./mongodb-community-operator/cmd/versionhook/main.go
23-
246
FROM scratch AS base
257
ARG mongodb_tools_url_ubi
268
ARG mongodb_agent_url_ubi
279

28-
COPY --from=readiness_builder /readinessprobe /data/
29-
COPY --from=readiness_builder /version-upgrade-hook /data/
30-
3110
ADD ${mongodb_tools_url_ubi} /data/mongodb_tools_ubi.tgz
3211
ADD ${mongodb_agent_url_ubi} /data/mongodb_agent_ubi.tgz
3312

13+
COPY --from=init_database /readinessprobe /data/
14+
COPY --from=init_database /version-upgrade-hook /data/
3415
COPY --from=init_database /probes/probe.sh /data/probe.sh
3516
COPY --from=init_database /scripts/agent-launcher-lib.sh /data/
3617
COPY --from=init_database /scripts/agent-launcher.sh /data/
3718
COPY --from=init_database /licenses/LICENSE /data/
19+
COPY --from=init_database /delve /data/
3820

3921
FROM registry.access.redhat.com/ubi9/ubi-minimal
4022

@@ -54,6 +36,7 @@ COPY --from=base /data/version-upgrade-hook /opt/scripts/version-upgrade-hook
5436
COPY --from=base /data/agent-launcher-lib.sh /opt/scripts/agent-launcher-lib.sh
5537
COPY --from=base /data/agent-launcher.sh /opt/scripts/agent-launcher.sh
5638
COPY --from=base /data/LICENSE /licenses/LICENSE
39+
COPY --from=base /data/dlv c
5740

5841
# Replace libcurl-minimal and curl-minimal with the full versions
5942
# https://bugzilla.redhat.com/show_bug.cgi?id=1994521

docker/mongodb-kubernetes-init-appdb/Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
FROM public.ecr.aws/docker/library/golang:1.24 AS readiness_builder
1+
FROM public.ecr.aws/docker/library/golang:1.24 AS builder
22

33
COPY . /go/src/github.com/mongodb/mongodb-kubernetes
44
WORKDIR /go/src/github.com/mongodb/mongodb-kubernetes
55
RUN CGO_ENABLED=0 GOFLAGS=-buildvcs=false go build -o /readinessprobe ./mongodb-community-operator/cmd/readiness/main.go
66
RUN CGO_ENABLED=0 GOFLAGS=-buildvcs=false go build -o /version-upgrade-hook ./mongodb-community-operator/cmd/versionhook/main.go
7+
RUN CGO_ENABLED=0 GOBIN=/delve go install github.com/go-delve/delve/cmd/[email protected]
78

89
FROM scratch AS base
910

1011
ARG mongodb_tools_url_ubi
1112

12-
COPY --from=readiness_builder /readinessprobe /data/
13-
COPY --from=readiness_builder /version-upgrade-hook /data/version-upgrade-hook
13+
COPY --from=builder /readinessprobe /data/readinessprobe
14+
COPY --from=builder /version-upgrade-hook /data/version-upgrade-hook
15+
COPY --from=builder /delve /data/delve
1416

1517
ADD ${mongodb_tools_url_ubi} /data/mongodb_tools_ubi.tgz
1618

@@ -37,6 +39,7 @@ COPY --from=base /data/probe.sh /probes/probe.sh
3739
COPY --from=base /data/scripts/ /scripts/
3840
COPY --from=base /data/licenses /licenses/
3941
COPY --from=base /data/version-upgrade-hook /probes/version-upgrade-hook
42+
COPY --from=base /data/delve /delve/
4043

4144
RUN microdnf -y update --nodocs \
4245
&& microdnf -y install --nodocs tar gzip \

docker/mongodb-kubernetes-init-database/Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
FROM public.ecr.aws/docker/library/golang:1.24 AS readiness_builder
1+
FROM public.ecr.aws/docker/library/golang:1.24 AS builder
22

33
COPY . /go/src/github.com/mongodb/mongodb-kubernetes
44
WORKDIR /go/src/github.com/mongodb/mongodb-kubernetes
55
RUN CGO_ENABLED=0 GOFLAGS=-buildvcs=false go build -o /readinessprobe ./mongodb-community-operator/cmd/readiness/main.go
66
RUN CGO_ENABLED=0 GOFLAGS=-buildvcs=false go build -o /version-upgrade-hook ./mongodb-community-operator/cmd/versionhook/main.go
7+
RUN CGO_ENABLED=0 GOBIN=/delve go install github.com/go-delve/delve/cmd/[email protected]
78

89
FROM scratch AS base
910

1011
ARG mongodb_tools_url_ubi
1112

12-
COPY --from=readiness_builder /readinessprobe /data/
13-
COPY --from=readiness_builder /version-upgrade-hook /data/version-upgrade-hook
13+
COPY --from=builder /readinessprobe /data/readinessprobe
14+
COPY --from=builder /version-upgrade-hook /data/version-upgrade-hook
15+
COPY --from=builder /delve /data/delve
1416

1517
ADD ${mongodb_tools_url_ubi} /data/mongodb_tools_ubi.tgz
1618

@@ -36,6 +38,7 @@ COPY --from=base /data/readinessprobe /probes/readinessprobe
3638
COPY --from=base /data/probe.sh /probes/probe.sh
3739
COPY --from=base /data/scripts/ /scripts/
3840
COPY --from=base /data/licenses /licenses/
41+
COPY --from=base /data/delve /delve/
3942

4043
RUN microdnf -y update --nodocs \
4144
&& microdnf -y install --nodocs tar gzip \

docker/mongodb-kubernetes-init-database/content/agent-launcher.sh

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -220,19 +220,7 @@ fi
220220

221221
debug="${MDB_AGENT_DEBUG-}"
222222
if [ "${debug}" = "true" ]; then
223-
cd ${mdb_downloads_dir} || true
224-
mkdir -p /var/lib/mongodb-mms-automation/gopath
225-
mkdir -p /var/lib/mongodb-mms-automation/go
226-
curl -LO https://go.dev/dl/go1.20.1.linux-amd64.tar.gz
227-
tar -xzf go1.20.1.linux-amd64.tar.gz
228-
export GOPATH=${mdb_downloads_dir}/gopath
229-
export GOCACHE=${mdb_downloads_dir}/.cache
230-
export PATH=${PATH}:${mdb_downloads_dir}/go/bin
231-
export PATH=${PATH}:${mdb_downloads_dir}/gopath/bin
232-
go install github.com/go-delve/delve/cmd/dlv@latest
233-
export PATH=${PATH}:${mdb_downloads_dir}/gopath/bin
234-
cd ${mdb_downloads_dir} || true
235-
dlv --headless=true --listen=:5006 --accept-multiclient=true --continue --api-version=2 exec "${AGENT_BINARY_PATH}" -- "${agentOpts[@]}" "${splittedAgentFlags[@]}" 2>> "${MDB_LOG_FILE_AUTOMATION_AGENT_STDERR}" > >(json_log "automation-agent-stdout") &
223+
/opt/scripts/dlv --headless=true --listen=:5006 --accept-multiclient=true --continue --api-version=2 exec "${AGENT_BINARY_PATH}" -- "${agentOpts[@]}" "${splittedAgentFlags[@]}" 2>> "${MDB_LOG_FILE_AUTOMATION_AGENT_STDERR}" > >(json_log "automation-agent-stdout") &
236224
else
237225
# Note, that we do logging in subshell - this allows us to save the correct PID to variable (not the logging one)
238226
"${AGENT_BINARY_PATH}" "${agentOpts[@]}" "${splittedAgentFlags[@]}" 2>> "${MDB_LOG_FILE_AUTOMATION_AGENT_STDERR}" >> >(json_log "automation-agent-stdout") &

0 commit comments

Comments
 (0)