diff --git a/packages/ciphernode/net/tests/Dockerfile b/packages/ciphernode/net/tests/Dockerfile index 584f7cfc..d983a17d 100644 --- a/packages/ciphernode/net/tests/Dockerfile +++ b/packages/ciphernode/net/tests/Dockerfile @@ -1,6 +1,20 @@ -FROM rust:1.81 -RUN apt-get update && apt-get install -y iptables +# Stage 1: Build +FROM rust:1.81 AS builder + WORKDIR /app -COPY ./net/tests/entrypoint.sh entrypoint.sh COPY . . -RUN cargo build --bin p2p_test +RUN cargo build --release --bin p2p_test + +# Stage 2: Runtime +FROM debian:bookworm-slim + +WORKDIR /app + +RUN apt-get update && apt-get install -y --no-install-recommends iptables ca-certificates && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +COPY --from=builder /app/target/release/p2p_test /app/ +COPY net/tests/entrypoint.sh /app/ +RUN chmod +x /app/entrypoint.sh + +ENTRYPOINT ["/app/entrypoint.sh"] diff --git a/packages/ciphernode/net/tests/docker-compose.yaml b/packages/ciphernode/net/tests/docker-compose.yaml index 20f8eb59..f55d3698 100644 --- a/packages/ciphernode/net/tests/docker-compose.yaml +++ b/packages/ciphernode/net/tests/docker-compose.yaml @@ -1,56 +1,51 @@ services: alice: - build: + build: dockerfile: net/tests/Dockerfile context: ../.. + image: p2p-test-image networks: app_net: ipv4_address: 172.16.238.10 - command: cargo run --bin p2p_test alice + command: ["/app/p2p_test", "alice"] environment: QUIC_PORT: 9091 DIAL_TO: "/ip4/172.16.238.12/udp/9091/quic-v1" - BLOCK_MDNS: ${BLOCK_MDNS:-false} + BLOCK_MDNS: "${BLOCK_MDNS:-false}" entrypoint: ["/app/entrypoint.sh"] cap_add: - NET_ADMIN - NET_RAW bob: - build: - dockerfile: net/tests/Dockerfile - context: ../.. + image: p2p-test-image networks: app_net: ipv4_address: 172.16.238.11 - command: cargo run --bin p2p_test bob + command: ["/app/p2p_test", "bob"] environment: QUIC_PORT: 9091 DIAL_TO: "/ip4/172.16.238.12/udp/9091/quic-v1" - BLOCK_MDNS: ${BLOCK_MDNS:-false} + BLOCK_MDNS: "${BLOCK_MDNS:-false}" entrypoint: ["/app/entrypoint.sh"] cap_add: - NET_ADMIN - NET_RAW - charlie: - build: - dockerfile: net/tests/Dockerfile - context: ../.. + image: p2p-test-image networks: app_net: ipv4_address: 172.16.238.12 - command: cargo run --bin p2p_test charlie + command: ["/app/p2p_test", "charlie"] environment: QUIC_PORT: 9091 - BLOCK_MDNS: ${BLOCK_MDNS:-false} + BLOCK_MDNS: "${BLOCK_MDNS:-false}" entrypoint: ["/app/entrypoint.sh"] cap_add: - NET_ADMIN - NET_RAW - networks: app_net: driver: bridge diff --git a/packages/ciphernode/net/tests/run.sh b/packages/ciphernode/net/tests/run.sh index aeed9457..3b0e3359 100755 --- a/packages/ciphernode/net/tests/run.sh +++ b/packages/ciphernode/net/tests/run.sh @@ -2,6 +2,11 @@ set -e +echo "" +echo "Building docker image" +echo "" +docker compose build + echo "" echo "TEST 1: Using MDNS with separate IP addresses" echo ""