diff --git a/Dockerfile b/Dockerfile index e4456cd533..6e82040893 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -# BUILD IMAGE ------------------------------------------------------------------ +# BUILD NIM APP ---------------------------------------------------------------- FROM alpine:edge AS nim-build @@ -52,5 +52,35 @@ COPY --from=nim-build /app/migrations/ /app/migrations/ RUN ln -sv /usr/local/bin/$MAKE_TARGET /usr/bin/wakunode ENTRYPOINT ["/usr/bin/wakunode"] + # By default just show help if called without arguments CMD ["--help"] + + +# DEBUG IMAGE ------------------------------------------------------------------ + +# Build debug tools: heaptrack +FROM alpine:edge AS heaptrack-build + +RUN apk update +RUN apk add -- gdb git g++ make cmake zlib-dev boost-dev libunwind-dev +RUN git clone https://github.com/KDE/heaptrack.git /heaptrack + +WORKDIR /heaptrack/build +RUN cmake -DCMAKE_BUILD_TYPE=Release .. +RUN make -j$(nproc) + + +# Debug image +FROM prod AS debug + +RUN apk add --no-cache gdb + +# Add heaptrack +COPY --from=heaptrack-build /heaptrack/build/ /heaptrack/build/ +COPY --from=heaptrack-build /usr/lib/ /usr/lib/ + +ENV LD_LIBRARY_PATH=/heaptrack/build/lib/heaptrack/ +RUN ln -s /heaptrack/build/bin/heaptrack /usr/local/bin/heaptrack + +ENTRYPOINT ["/heaptrack/build/bin/heaptrack", "/usr/bin/wakunode"] diff --git a/Dockerfile_with_heaptrack b/Dockerfile_with_heaptrack deleted file mode 100644 index 1cd8198f3a..0000000000 --- a/Dockerfile_with_heaptrack +++ /dev/null @@ -1,72 +0,0 @@ -# BUILD IMAGE ------------------------------------------------------------------ -FROM alpine:edge AS nim-build - -ARG NIMFLAGS -ARG MAKE_TARGET=wakunode2 -ARG EXPERIMENTAL=false - -# Get build tools and required header files -RUN apk add --no-cache bash git cargo build-base pcre-dev linux-headers - -WORKDIR /app -COPY . . - -# Ran separately from 'make' to avoid re-doing -RUN git submodule update --init --recursive - -# Slowest build step for the sake of caching layers -RUN make -j$(nproc) deps - -# Build the final node binary -RUN make -j$(nproc) $MAKE_TARGET NIM_COMMIT=heaptrack_support NIMFLAGS="${NIMFLAGS}" EXPERIMENTAL="${EXPERIMENTAL}" - - -# BUILD HEAPTRACK -------------------------------------------------------------- -FROM alpine:edge AS heaptrack-build - -RUN apk update -RUN apk add -- gdb git g++ make cmake zlib-dev boost-dev libunwind-dev -RUN git clone https://github.com/KDE/heaptrack.git -WORKDIR /heaptrack/build -RUN cmake -DCMAKE_BUILD_TYPE=Release .. -RUN make -j$(nproc) - - -# PRODUCTION IMAGE ------------------------------------------------------------- -FROM alpine:3.16 as prod - -ARG MAKE_TARGET=wakunode2 - -LABEL maintainer="jakub@status.im" -LABEL source="https://github.com/waku-org/nwaku" -LABEL description="Wakunode: Waku and Whisper client" -LABEL commit="unknown" - -# DevP2P, LibP2P, and JSON RPC ports -EXPOSE 30303 60000 8545 - -# Referenced in the binary -RUN apk add --no-cache libgcc pcre-dev - -# Fix for 'Error loading shared library libpcre.so.3: No such file or directory' -RUN ln -s /usr/lib/libpcre.so /usr/lib/libpcre.so.3 - -# Copy to separate location to accomodate different MAKE_TARGET values -COPY --from=nim-build /app/build/$MAKE_TARGET /usr/local/bin/ - -# Copy migration scripts for DB upgrades -COPY --from=nim-build /app/migrations/ /app/migrations/ - -# Symlink the correct wakunode binary -RUN ln -sv /usr/local/bin/$MAKE_TARGET /usr/bin/wakunode - -# Heaptrack -COPY --from=heaptrack-build /heaptrack/build/ /heaptrack/build/ -COPY --from=heaptrack-build /usr/lib/ /usr/lib/ -RUN apk add -- gdb -ENV LD_LIBRARY_PATH=/heaptrack/build/lib/heaptrack/ -RUN ln -s /heaptrack/build/bin/heaptrack /usr/local/bin/heaptrack - -ENTRYPOINT ["/heaptrack/build/bin/heaptrack", "/usr/bin/wakunode"] -# By default just show help if called without arguments -CMD ["--help"] diff --git a/Makefile b/Makefile index d3d46e2a1c..bd0bdf052c 100644 --- a/Makefile +++ b/Makefile @@ -245,12 +245,14 @@ DOCKER_IMAGE_NIMFLAGS ?= -d:chronicles_colors:none -d:insecure docker-image: MAKE_TARGET ?= wakunode2 docker-image: DOCKER_IMAGE_TAG ?= $(MAKE_TARGET)-$(GIT_VERSION) docker-image: DOCKER_IMAGE_NAME ?= statusteam/nim-waku:$(DOCKER_IMAGE_TAG) +docker-image: DOCKER_IMAGE_TARGET ?= prod docker-image: docker build \ --build-arg="MAKE_TARGET=$(MAKE_TARGET)" \ --build-arg="NIMFLAGS=$(DOCKER_IMAGE_NIMFLAGS)" \ --build-arg="EXPERIMENTAL=$(EXPERIMENTAL)" \ --label="commit=$(GIT_VERSION)" \ + --target $(DOCKER_IMAGE_TARGET) \ --tag $(DOCKER_IMAGE_NAME) . docker-push: