nim-libplum/tests/Dockerfile

47 lines
2.1 KiB
Docker
Raw Permalink Normal View History

FROM nimlang/nim:latest
2026-05-18 11:43:28 +04:00
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc make git curl ca-certificates xz-utils \
2026-05-18 11:43:28 +04:00
libc-dev \
iproute2 \
&& apt-get dist-clean
2026-05-18 11:43:28 +04:00
# Build miniupnpd with stub redirector: no iptables/nftables needed, always
# returns success for port mapping requests — safe for isolated test containers.
COPY tests/miniupnpd_stub_rdr.c /tmp/stub_rdr.c
RUN git clone --depth=1 --branch miniupnpd_2_3_9 \
https://github.com/miniupnp/miniupnp.git /tmp/miniupnp \
&& cd /tmp/miniupnp/miniupnpd \
&& ./configure \
&& cp /tmp/stub_rdr.c . \
&& make NETFILTEROBJS=stub_rdr.o miniupnpd \
&& install -m 755 miniupnpd /usr/local/sbin/miniupnpd \
2026-05-19 11:28:39 +04:00
# Build another miniupnpd for pmp: we need to disable explictly PCP for that
# check miniupnpd configure for more info.
# https://github.com/miniupnp/miniupnp/blob/50cb0582d4a659e319050069aa84efbc1f353b14/miniupnpd/configure#L878-L880
2026-05-19 11:42:19 +04:00
&& sed -i 's/^#define ENABLE_PCP$/\/*#define ENABLE_PCP*\//' config.h \
2026-05-18 15:16:27 +04:00
&& make NETFILTEROBJS=stub_rdr.o miniupnpd \
&& install -m 755 miniupnpd /usr/local/sbin/miniupnpd-natpmponly \
2026-05-18 11:43:28 +04:00
&& rm -rf /tmp/miniupnp /tmp/stub_rdr.c
# Install nim deps (cached layer)
WORKDIR /app
COPY libplum.nimble .
COPY libplum_units.c .
2026-05-18 11:43:28 +04:00
COPY libplum/ libplum/
COPY vendor/ vendor/
RUN nimble setup -y
# Compile test binaries (protocol x memory manager)
COPY tests/ tests/
2026-05-26 14:28:09 +04:00
RUN nim c -d:miniupnp_protocol=pcp --mm:orc --threads:on -o:tests/test_pcp_orc tests/test_plum.nim && \
nim c -d:miniupnp_protocol=pcp --mm:refc --threads:on -o:tests/test_pcp_refc tests/test_plum.nim && \
nim c -d:miniupnp_protocol=upnp --mm:orc --threads:on -o:tests/test_upnp_orc tests/test_plum.nim && \
nim c -d:miniupnp_protocol=upnp --mm:refc --threads:on -o:tests/test_upnp_refc tests/test_plum.nim && \
nim c -d:miniupnp_protocol=natpmp --mm:orc --threads:on -o:tests/test_natpmp_orc tests/test_plum.nim && \
nim c -d:miniupnp_protocol=natpmp --mm:refc --threads:on -o:tests/test_natpmp_refc tests/test_plum.nim
2026-05-18 11:43:28 +04:00
COPY tests/docker-entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]