From 4265a1fbf10822415a7469c2cffbc17a861bb22f Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Wed, 15 Sep 2021 22:57:48 +0900 Subject: [PATCH] docker-tests: speed up tests, combine client and server into one image --- docker-tests/Dockerfile.innernet | 10 +++--- docker-tests/Dockerfile.innernet-server | 45 ------------------------- docker-tests/build-docker-images.sh | 1 - docker-tests/run-docker-tests.sh | 6 ++-- 4 files changed, 9 insertions(+), 53 deletions(-) delete mode 100644 docker-tests/Dockerfile.innernet-server diff --git a/docker-tests/Dockerfile.innernet b/docker-tests/Dockerfile.innernet index fb8c26b..4b648ed 100644 --- a/docker-tests/Dockerfile.innernet +++ b/docker-tests/Dockerfile.innernet @@ -7,8 +7,8 @@ RUN apt-get update && \ WORKDIR /app COPY . . -RUN cargo build --release --bin innernet -RUN strip /app/target/release/innernet +RUN cargo build +RUN strip /app/target/debug/innernet /app/target/debug/innernet-server FROM golang:latest as wireguard ARG wg_go_tag=0.0.20210323 @@ -39,7 +39,9 @@ RUN apt-get update && \ WORKDIR /app COPY ./docker-tests/start-client.sh ./ +COPY ./docker-tests/start-server.sh ./ COPY --from=wireguard /usr/bin/wireguard-go /usr/bin/wg* /usr/bin/ -COPY --from=builder /app/target/release/innernet /usr/bin/ +COPY --from=builder /app/target/debug/innernet /usr/bin/ +COPY --from=builder /app/target/debug/innernet-server /usr/bin/ -CMD ["/app/start-client.sh"] +CMD ["/app/start-server.sh"] diff --git a/docker-tests/Dockerfile.innernet-server b/docker-tests/Dockerfile.innernet-server deleted file mode 100644 index 03520dd..0000000 --- a/docker-tests/Dockerfile.innernet-server +++ /dev/null @@ -1,45 +0,0 @@ -#################################################################################################### -## Builder -#################################################################################################### -FROM rust:slim as builder -RUN apt-get update && \ - apt-get install -y --no-install-recommends build-essential clang libclang-dev libsqlite3-dev -WORKDIR /app - -COPY . . -RUN cargo build --release --bin innernet-server -RUN strip /app/target/release/innernet-server - -FROM golang:latest as wireguard -ARG wg_go_tag=0.0.20210323 -ARG wg_tools_tag=v1.0.20210315 -RUN apt-get update && \ - apt-get install -y --no-install-recommends git - -RUN git clone -b $wg_go_tag --depth 1 https://git.zx2c4.com/wireguard-go && \ - cd wireguard-go && \ - make && \ - make install - -ENV WITH_WGQUICK=yes -RUN git clone -b $wg_tools_tag --depth 1 https://git.zx2c4.com/wireguard-tools && \ - cd wireguard-tools && \ - cd src && \ - make && \ - make install - -#################################################################################################### -## Final image -#################################################################################################### -FROM debian:buster-slim -RUN apt-get update && \ - apt-get install -y --no-install-recommends libsqlite3-dev iproute2 iputils-ping && \ - rm -rf /var/lib/apt/lists/* -WORKDIR /app - -COPY ./docker-tests/start-server.sh ./ -COPY --from=wireguard /usr/bin/wireguard-go /usr/bin/wg* /usr/bin/ -COPY --from=builder /app/target/release/innernet-server /usr/bin/ -EXPOSE 51820/udp - -CMD ["/app/start-server.sh"] diff --git a/docker-tests/build-docker-images.sh b/docker-tests/build-docker-images.sh index bc4cb6b..e6f1889 100755 --- a/docker-tests/build-docker-images.sh +++ b/docker-tests/build-docker-images.sh @@ -4,5 +4,4 @@ set -ex SELF_DIR="$(dirname "$0")" cd "$SELF_DIR/.." -docker build -t innernet-server -f "$SELF_DIR/Dockerfile.innernet-server" . docker build -t innernet -f "$SELF_DIR/Dockerfile.innernet" . diff --git a/docker-tests/run-docker-tests.sh b/docker-tests/run-docker-tests.sh index 4b635f5..1b61c26 100755 --- a/docker-tests/run-docker-tests.sh +++ b/docker-tests/run-docker-tests.sh @@ -55,7 +55,7 @@ SERVER_CONTAINER=$(cmd docker create -it --rm \ --env RUST_LOG=debug \ --env INNERNET_ARGS="$INNERNET_ARGS" \ --cap-add NET_ADMIN \ - innernet-server) + innernet) cmd docker start -a "$SERVER_CONTAINER" & info "server started as $SERVER_CONTAINER" @@ -71,7 +71,7 @@ PEER1_CONTAINER=$(cmd docker create --rm -it \ --env INTERFACE=evilcorp \ --env INNERNET_ARGS="$INNERNET_ARGS" \ --cap-add NET_ADMIN \ - innernet) + innernet /app/start-client.sh) info "peer1 started as $PEER1_CONTAINER" cmd docker cp "$tmp_dir/peer1.toml" "$PEER1_CONTAINER:/app/invite.toml" cmd docker start "$PEER1_CONTAINER" @@ -111,7 +111,7 @@ PEER2_CONTAINER=$(docker create --rm -it \ --cap-add NET_ADMIN \ --env INTERFACE=evilcorp \ --env INNERNET_ARGS="$INNERNET_ARGS" \ - innernet) + innernet /app/start-client.sh) info "peer2 started as $PEER2_CONTAINER" cmd docker cp "$tmp_dir/peer2.toml" "$PEER2_CONTAINER:/app/invite.toml" cmd docker start "$PEER2_CONTAINER"