Skip to content

Commit 91885fb

Browse files
chore: heaptrack support build for Nim v2.0.12 builds (#3424)
* fix heaptrack build for Nim v2.0.12 builds, fixed docker image creation and local image with copying * fix Dockerfile.bn.amd64 to support nwaku-compose * Fix heaptrack image build with jenkins.release * Fix NIM_COMMIT for heaptrack support in jenkins.release * Remove leftover echo Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix dockerfile naming * Fix assignment of NIM_COMMIT in Makefile --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 5628dc6 commit 91885fb

File tree

5 files changed

+100
-17
lines changed

5 files changed

+100
-17
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ RUN make -j$(nproc)
7878

7979

8080
# Debug image
81-
FROM prod AS debug
81+
FROM prod AS debug-with-heaptrack
8282

8383
RUN apk add --no-cache gdb libunwind
8484

Makefile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,18 @@ HEAPTRACKER ?= 0
8282
HEAPTRACKER_INJECT ?= 0
8383
ifeq ($(HEAPTRACKER), 1)
8484
# Needed to make nimbus-build-system use the Nim's 'heaptrack_support' branch
85-
DOCKER_NIM_COMMIT := NIM_COMMIT=heaptrack_support
86-
TARGET := heaptrack-build
85+
DOCKER_NIM_COMMIT := NIM_COMMIT=heaptrack_support_v2.0.12
86+
TARGET := debug-with-heaptrack
87+
NIM_COMMIT := heaptrack_support_v2.0.12
8788

8889
ifeq ($(HEAPTRACKER_INJECT), 1)
8990
# the Nim compiler will load 'libheaptrack_inject.so'
9091
HEAPTRACK_PARAMS := -d:heaptracker -d:heaptracker_inject
92+
NIM_PARAMS := $(NIM_PARAMS) -d:heaptracker -d:heaptracker_inject
9193
else
9294
# the Nim compiler will load 'libheaptrack_preload.so'
9395
HEAPTRACK_PARAMS := -d:heaptracker
96+
NIM_PARAMS := $(NIM_PARAMS) -d:heaptracker
9497
endif
9598

9699
endif
@@ -209,6 +212,7 @@ testwaku: | build deps anvil librln
209212

210213
wakunode2: | build deps librln
211214
echo -e $(BUILD_MSG) "build/$@" && \
215+
\
212216
$(ENV_SCRIPT) nim wakunode2 $(NIM_PARAMS) waku.nims
213217

214218
benchmarks: | build deps librln
@@ -343,12 +347,12 @@ docker-image:
343347
docker-quick-image: MAKE_TARGET ?= wakunode2
344348
docker-quick-image: DOCKER_IMAGE_TAG ?= $(MAKE_TARGET)-$(GIT_VERSION)
345349
docker-quick-image: DOCKER_IMAGE_NAME ?= wakuorg/nwaku:$(DOCKER_IMAGE_TAG)
346-
docker-quick-image: NIM_PARAMS := $(NIM_PARAMS) -d:chronicles_colors:none -d:insecure -d:postgres --passL:$(LIBRLN_FILE) --passL:-lm
347350
docker-quick-image: | build deps librln wakunode2
348351
docker build \
349352
--build-arg="MAKE_TARGET=$(MAKE_TARGET)" \
350353
--tag $(DOCKER_IMAGE_NAME) \
351-
--file docker/binaries/Dockerfile.bn.amd64 \
354+
--target $(TARGET) \
355+
--file docker/binaries/Dockerfile.bn.local \
352356
.
353357

354358
docker-push:

ci/Jenkinsfile.release

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,33 @@ pipeline {
6969
stages {
7070
stage('Build') {
7171
steps { script {
72-
image = docker.build(
73-
"${params.IMAGE_NAME}:${params.IMAGE_TAG ?: env.GIT_COMMIT.take(8)}",
74-
"--label=build='${env.BUILD_URL}' " +
75-
"--label=commit='${git.commit()}' " +
76-
"--label=version='${git.describe('--tags')}' " +
77-
"--build-arg=MAKE_TARGET='${params.MAKE_TARGET}' " +
78-
"--build-arg=NIMFLAGS='${params.NIMFLAGS} -d:postgres ' " +
79-
"--build-arg=LOG_LEVEL='${params.LOWEST_LOG_LEVEL_ALLOWED}' " +
80-
"--build-arg=DEBUG='${params.DEBUG ? "1" : "0"} ' " +
81-
"--target=${params.HEAPTRACK ? "heaptrack-build" : "prod"} ."
82-
)
72+
if (params.HEAPTRACK) {
73+
echo 'Building with heaptrack support'
74+
image = docker.build(
75+
"${params.IMAGE_NAME}:${params.IMAGE_TAG ?: env.GIT_COMMIT.take(8)}",
76+
"--label=build='${env.BUILD_URL}' " +
77+
"--label=commit='${git.commit()}' " +
78+
"--label=version='${git.describe('--tags')}' " +
79+
"--build-arg=MAKE_TARGET='${params.MAKE_TARGET}' " +
80+
"--build-arg=NIMFLAGS='${params.NIMFLAGS} -d:postgres -d:heaptracker ' " +
81+
"--build-arg=LOG_LEVEL='${params.LOWEST_LOG_LEVEL_ALLOWED}' " +
82+
"--build-arg=DEBUG='${params.DEBUG ? "1" : "0"} ' " +
83+
"--build-arg=NIM_COMMIT='NIM_COMMIT=heaptrack_support_v2.0.12' " +
84+
"--target='debug-with-heaptrack' ."
85+
)
86+
} else {
87+
image = docker.build(
88+
"${params.IMAGE_NAME}:${params.IMAGE_TAG ?: env.GIT_COMMIT.take(8)}",
89+
"--label=build='${env.BUILD_URL}' " +
90+
"--label=commit='${git.commit()}' " +
91+
"--label=version='${git.describe('--tags')}' " +
92+
"--build-arg=MAKE_TARGET='${params.MAKE_TARGET}' " +
93+
"--build-arg=NIMFLAGS='${params.NIMFLAGS} -d:postgres ' " +
94+
"--build-arg=LOG_LEVEL='${params.LOWEST_LOG_LEVEL_ALLOWED}' " +
95+
"--build-arg=DEBUG='${params.DEBUG ? "1" : "0"} ' " +
96+
"--target='prod' ."
97+
)
98+
}
8399
} }
84100
}
85101

docker/binaries/Dockerfile.bn.amd64

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ EXPOSE 30303 60000 8545
1313

1414
# Referenced in the binary
1515
RUN apt-get update &&\
16-
apt-get install -y libpcre3 libpq-dev curl iproute2 wget &&\
16+
apt-get install -y libpcre3 libpq-dev curl iproute2 wget dnsutils &&\
1717
apt-get clean && rm -rf /var/lib/apt/lists/*
1818

1919
# Fix for 'Error loading shared library libpcre.so.3: No such file or directory'
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Dockerfile to build a distributable container image from pre-existing binaries
2+
# FROM debian:stable-slim AS prod
3+
FROM ubuntu:24.04 AS prod
4+
5+
ARG MAKE_TARGET=wakunode2
6+
7+
LABEL maintainer="vaclav@status.im"
8+
LABEL source="https://github.com/waku-org/nwaku"
9+
LABEL description="Wakunode: Waku client"
10+
LABEL commit="unknown"
11+
12+
# DevP2P, LibP2P, and JSON RPC ports
13+
EXPOSE 30303 60000 8545
14+
15+
# Referenced in the binary
16+
RUN apt-get update &&\
17+
apt-get install -y libpcre3 libpq-dev curl iproute2 wget jq dnsutils &&\
18+
apt-get clean && rm -rf /var/lib/apt/lists/*
19+
20+
# Fix for 'Error loading shared library libpcre.so.3: No such file or directory'
21+
RUN ln -s /usr/lib/libpcre.so /usr/lib/libpcre.so.3
22+
23+
# Copy to separate location to accomodate different MAKE_TARGET values
24+
ADD ./build/$MAKE_TARGET /usr/local/bin/
25+
26+
# Copy migration scripts for DB upgrades
27+
ADD ./migrations/ /app/migrations/
28+
29+
# Symlink the correct wakunode binary
30+
RUN ln -sv /usr/local/bin/$MAKE_TARGET /usr/bin/wakunode
31+
32+
ENTRYPOINT ["/usr/bin/wakunode"]
33+
34+
# By default just show help if called without arguments
35+
CMD ["--help"]
36+
37+
# Build debug tools: heaptrack
38+
FROM ubuntu:24.04 AS heaptrack-build
39+
40+
RUN apt update
41+
RUN apt install -y gdb git g++ make cmake zlib1g-dev libboost-all-dev libunwind-dev
42+
RUN git clone https://github.com/KDE/heaptrack.git /heaptrack
43+
44+
WORKDIR /heaptrack/build
45+
# going to a commit that builds properly. We will revisit this for new releases
46+
RUN git reset --hard f9cc35ebbdde92a292fe3870fe011ad2874da0ca
47+
RUN cmake -DCMAKE_BUILD_TYPE=Release ..
48+
RUN make -j$(nproc)
49+
50+
51+
# Debug image
52+
FROM prod AS debug-with-heaptrack
53+
54+
RUN apt update
55+
RUN apt install -y gdb libunwind8
56+
57+
# Add heaptrack
58+
COPY --from=heaptrack-build /heaptrack/build/ /heaptrack/build/
59+
60+
ENV LD_LIBRARY_PATH=/heaptrack/build/lib/heaptrack/
61+
RUN ln -s /heaptrack/build/bin/heaptrack /usr/local/bin/heaptrack
62+
63+
ENTRYPOINT ["/heaptrack/build/bin/heaptrack", "/usr/bin/wakunode"]

0 commit comments

Comments
 (0)