Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use multistage to reduce test image size #187

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions packages/ciphernode/net/tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
25 changes: 10 additions & 15 deletions packages/ciphernode/net/tests/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions packages/ciphernode/net/tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down
Loading