docker-tests: speed up tests, combine client and server into one image
parent
74eda56cbe
commit
4265a1fbf1
|
@ -7,8 +7,8 @@ RUN apt-get update && \
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN cargo build --release --bin innernet
|
RUN cargo build
|
||||||
RUN strip /app/target/release/innernet
|
RUN strip /app/target/debug/innernet /app/target/debug/innernet-server
|
||||||
|
|
||||||
FROM golang:latest as wireguard
|
FROM golang:latest as wireguard
|
||||||
ARG wg_go_tag=0.0.20210323
|
ARG wg_go_tag=0.0.20210323
|
||||||
|
@ -39,7 +39,9 @@ RUN apt-get update && \
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY ./docker-tests/start-client.sh ./
|
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=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"]
|
||||||
|
|
|
@ -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"]
|
|
|
@ -4,5 +4,4 @@ set -ex
|
||||||
SELF_DIR="$(dirname "$0")"
|
SELF_DIR="$(dirname "$0")"
|
||||||
cd "$SELF_DIR/.."
|
cd "$SELF_DIR/.."
|
||||||
|
|
||||||
docker build -t innernet-server -f "$SELF_DIR/Dockerfile.innernet-server" .
|
|
||||||
docker build -t innernet -f "$SELF_DIR/Dockerfile.innernet" .
|
docker build -t innernet -f "$SELF_DIR/Dockerfile.innernet" .
|
||||||
|
|
|
@ -55,7 +55,7 @@ SERVER_CONTAINER=$(cmd docker create -it --rm \
|
||||||
--env RUST_LOG=debug \
|
--env RUST_LOG=debug \
|
||||||
--env INNERNET_ARGS="$INNERNET_ARGS" \
|
--env INNERNET_ARGS="$INNERNET_ARGS" \
|
||||||
--cap-add NET_ADMIN \
|
--cap-add NET_ADMIN \
|
||||||
innernet-server)
|
innernet)
|
||||||
cmd docker start -a "$SERVER_CONTAINER" &
|
cmd docker start -a "$SERVER_CONTAINER" &
|
||||||
|
|
||||||
info "server started as $SERVER_CONTAINER"
|
info "server started as $SERVER_CONTAINER"
|
||||||
|
@ -71,7 +71,7 @@ PEER1_CONTAINER=$(cmd docker create --rm -it \
|
||||||
--env INTERFACE=evilcorp \
|
--env INTERFACE=evilcorp \
|
||||||
--env INNERNET_ARGS="$INNERNET_ARGS" \
|
--env INNERNET_ARGS="$INNERNET_ARGS" \
|
||||||
--cap-add NET_ADMIN \
|
--cap-add NET_ADMIN \
|
||||||
innernet)
|
innernet /app/start-client.sh)
|
||||||
info "peer1 started as $PEER1_CONTAINER"
|
info "peer1 started as $PEER1_CONTAINER"
|
||||||
cmd docker cp "$tmp_dir/peer1.toml" "$PEER1_CONTAINER:/app/invite.toml"
|
cmd docker cp "$tmp_dir/peer1.toml" "$PEER1_CONTAINER:/app/invite.toml"
|
||||||
cmd docker start "$PEER1_CONTAINER"
|
cmd docker start "$PEER1_CONTAINER"
|
||||||
|
@ -111,7 +111,7 @@ PEER2_CONTAINER=$(docker create --rm -it \
|
||||||
--cap-add NET_ADMIN \
|
--cap-add NET_ADMIN \
|
||||||
--env INTERFACE=evilcorp \
|
--env INTERFACE=evilcorp \
|
||||||
--env INNERNET_ARGS="$INNERNET_ARGS" \
|
--env INNERNET_ARGS="$INNERNET_ARGS" \
|
||||||
innernet)
|
innernet /app/start-client.sh)
|
||||||
info "peer2 started as $PEER2_CONTAINER"
|
info "peer2 started as $PEER2_CONTAINER"
|
||||||
cmd docker cp "$tmp_dir/peer2.toml" "$PEER2_CONTAINER:/app/invite.toml"
|
cmd docker cp "$tmp_dir/peer2.toml" "$PEER2_CONTAINER:/app/invite.toml"
|
||||||
cmd docker start "$PEER2_CONTAINER"
|
cmd docker start "$PEER2_CONTAINER"
|
||||||
|
|
Loading…
Reference in New Issue