docker-tests: simplify build step

pull/162/head
Jake McGinty 2021-09-18 16:15:29 +09:00
parent 072ac4bf96
commit cac46dbf30
2 changed files with 18 additions and 31 deletions

View File

@ -1,47 +1,34 @@
#################################################################################################### ####################################################################################################
## Builder ## WireGuard
#################################################################################################### ####################################################################################################
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
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
ARG wg_tools_tag=v1.0.20210315 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 && \ RUN mkdir /repo \
cd wireguard-go && \ && curl -L https://github.com/WireGuard/wireguard-go/archive/refs/tags/0.0.20210424.tar.gz \
make && \ | tar -xzC /repo --strip-components=1 \
make install && cd /repo \
&& make
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 ## Final image
#################################################################################################### ####################################################################################################
FROM debian:buster-slim FROM rust:slim
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y --no-install-recommends libsqlite3-dev iproute2 iputils-ping && \ apt-get install -y --no-install-recommends libsqlite3-dev iproute2 iputils-ping build-essential clang libclang-dev && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
WORKDIR /app WORKDIR /app
COPY . .
RUN cargo build \
&& strip /app/target/debug/innernet /app/target/debug/innernet-server \
&& cp /app/target/debug/innernet /app/target/debug/innernet-server /usr/bin/ \
&& cargo clean
COPY ./docker-tests/start-client.sh ./ COPY ./docker-tests/start-client.sh ./
COPY ./docker-tests/start-server.sh ./ COPY ./docker-tests/start-server.sh ./
COPY --from=wireguard /usr/bin/wireguard-go /usr/bin/wg* /usr/bin/ COPY --from=wireguard /repo/wireguard-go /usr/bin/
COPY --from=builder /app/target/debug/innernet /usr/bin/
COPY --from=builder /app/target/debug/innernet-server /usr/bin/
CMD ["/app/start-server.sh"] CMD ["/app/start-server.sh"]

View File

@ -60,7 +60,7 @@ cmd docker start -a "$SERVER_CONTAINER" &
info "server started as $SERVER_CONTAINER" info "server started as $SERVER_CONTAINER"
info "Waiting for server to initialize." info "Waiting for server to initialize."
cmd sleep 10 cmd sleep 5
info "Starting first peer." info "Starting first peer."
cmd docker cp "$SERVER_CONTAINER:/app/peer1.toml" "$tmp_dir" cmd docker cp "$SERVER_CONTAINER:/app/peer1.toml" "$tmp_dir"
@ -125,11 +125,11 @@ cmd docker exec "$PEER1_CONTAINER" innernet \
--admin false \ --admin false \
--ip "10.66.2.100" \ --ip "10.66.2.100" \
--save-config "/app/peer3.toml" \ --save-config "/app/peer3.toml" \
--invite-expires "5s" \ --invite-expires "1s" \
--yes --yes
info "waiting 15 seconds to see if the server clears out the IP address." info "waiting 15 seconds to see if the server clears out the IP address."
sleep 15 sleep 11
info "Re-requesting invite after expiration with the same parameters." info "Re-requesting invite after expiration with the same parameters."
cmd docker exec "$PEER1_CONTAINER" innernet \ cmd docker exec "$PEER1_CONTAINER" innernet \