2023-04-25 15:54:28 +00:00
|
|
|
# BUILD NIM APP ----------------------------------------------------------------
|
2020-09-21 19:27:22 +00:00
|
|
|
|
2023-07-24 17:25:28 +00:00
|
|
|
# alpine:edge supports building rust binaries, alpine:3.16 doesn't for some reason
|
|
|
|
FROM alpine@sha256:880fafbab5a7602db21ac37f0d17088a29a9a48f98d581f01ce17312c22ccbb5 AS nim-build
|
2020-05-26 12:04:40 +00:00
|
|
|
|
2022-05-17 19:11:07 +00:00
|
|
|
ARG NIMFLAGS
|
2022-02-21 15:42:27 +00:00
|
|
|
ARG MAKE_TARGET=wakunode2
|
2023-04-25 15:54:28 +00:00
|
|
|
ARG NIM_COMMIT
|
2023-05-23 08:44:57 +00:00
|
|
|
ARG LOG_LEVEL=TRACE
|
2020-05-26 12:04:40 +00:00
|
|
|
|
|
|
|
# Get build tools and required header files
|
2023-09-19 10:28:12 +00:00
|
|
|
RUN apk add --no-cache bash git build-base pcre-dev linux-headers curl jq rust cargo
|
2022-10-05 11:28:41 +00:00
|
|
|
|
2020-05-26 12:04:40 +00:00
|
|
|
WORKDIR /app
|
2020-09-21 19:27:22 +00:00
|
|
|
COPY . .
|
2020-05-26 12:04:40 +00:00
|
|
|
|
|
|
|
# Ran separately from 'make' to avoid re-doing
|
|
|
|
RUN git submodule update --init --recursive
|
|
|
|
|
2020-09-21 19:27:22 +00:00
|
|
|
# Slowest build step for the sake of caching layers
|
2023-05-23 08:44:57 +00:00
|
|
|
RUN make -j$(nproc) deps QUICK_AND_DIRTY_COMPILER=1 ${NIM_COMMIT}
|
2020-09-21 19:27:22 +00:00
|
|
|
|
|
|
|
# Build the final node binary
|
2023-09-11 06:32:31 +00:00
|
|
|
RUN make -j$(nproc) ${NIM_COMMIT} $MAKE_TARGET LOG_LEVEL=${LOG_LEVEL} NIMFLAGS="${NIMFLAGS}"
|
2022-11-30 20:02:39 +00:00
|
|
|
|
2022-10-05 11:28:41 +00:00
|
|
|
|
2022-12-01 11:45:06 +00:00
|
|
|
# PRODUCTION IMAGE -------------------------------------------------------------
|
2020-09-21 19:27:22 +00:00
|
|
|
|
2022-12-01 11:45:06 +00:00
|
|
|
FROM alpine:3.16 as prod
|
2020-09-21 19:27:22 +00:00
|
|
|
|
2020-10-20 02:36:27 +00:00
|
|
|
ARG MAKE_TARGET=wakunode2
|
2020-05-26 12:04:40 +00:00
|
|
|
|
|
|
|
LABEL maintainer="jakub@status.im"
|
2022-11-30 20:02:39 +00:00
|
|
|
LABEL source="https://github.com/waku-org/nwaku"
|
2023-08-09 17:11:50 +00:00
|
|
|
LABEL description="Wakunode: Waku client"
|
2022-02-21 15:42:27 +00:00
|
|
|
LABEL commit="unknown"
|
2020-05-26 12:04:40 +00:00
|
|
|
|
2020-09-21 19:27:22 +00:00
|
|
|
# DevP2P, LibP2P, and JSON RPC ports
|
|
|
|
EXPOSE 30303 60000 8545
|
2020-05-26 12:04:40 +00:00
|
|
|
|
|
|
|
# Referenced in the binary
|
2023-06-27 13:59:17 +00:00
|
|
|
RUN apk add --no-cache libgcc pcre-dev libpq-dev
|
2020-05-26 12:04:40 +00:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2020-09-21 19:27:22 +00:00
|
|
|
# Copy to separate location to accomodate different MAKE_TARGET values
|
|
|
|
COPY --from=nim-build /app/build/$MAKE_TARGET /usr/local/bin/
|
|
|
|
|
2021-12-08 09:38:43 +00:00
|
|
|
# Copy migration scripts for DB upgrades
|
2022-11-04 12:35:51 +00:00
|
|
|
COPY --from=nim-build /app/migrations/ /app/migrations/
|
2021-12-08 09:38:43 +00:00
|
|
|
|
2020-09-21 19:27:22 +00:00
|
|
|
# Symlink the correct wakunode binary
|
|
|
|
RUN ln -sv /usr/local/bin/$MAKE_TARGET /usr/bin/wakunode
|
2020-05-26 12:04:40 +00:00
|
|
|
|
2020-11-04 15:21:17 +00:00
|
|
|
ENTRYPOINT ["/usr/bin/wakunode"]
|
2023-04-25 15:54:28 +00:00
|
|
|
|
2020-05-26 12:04:40 +00:00
|
|
|
# By default just show help if called without arguments
|
|
|
|
CMD ["--help"]
|
2023-04-25 15:54:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
# DEBUG IMAGE ------------------------------------------------------------------
|
|
|
|
|
|
|
|
# Build debug tools: heaptrack
|
2023-05-18 08:03:47 +00:00
|
|
|
FROM alpine:3.16 AS heaptrack-build
|
2023-04-25 15:54:28 +00:00
|
|
|
|
|
|
|
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
|
2023-09-01 06:17:12 +00:00
|
|
|
# going to a commit that builds properly. We will revisit this for new releases
|
|
|
|
RUN git reset --hard f9cc35ebbdde92a292fe3870fe011ad2874da0ca
|
2023-04-25 15:54:28 +00:00
|
|
|
RUN cmake -DCMAKE_BUILD_TYPE=Release ..
|
|
|
|
RUN make -j$(nproc)
|
|
|
|
|
|
|
|
|
|
|
|
# Debug image
|
|
|
|
FROM prod AS debug
|
|
|
|
|
|
|
|
RUN apk add --no-cache gdb libunwind
|
|
|
|
|
|
|
|
# Add heaptrack
|
|
|
|
COPY --from=heaptrack-build /heaptrack/build/ /heaptrack/build/
|
|
|
|
|
|
|
|
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"]
|