feat(inter-op): make Dockerfile generic over test binary (#3382)

We make the binary that should be copied into the container configurable via a build time `ARG`. This will allow us to reuse the same `Dockerfile` once we write more tests.
Additionally, this allows us to remove some of the directory switching and creation code. In order to not send the entire repository over to the docker daemon as a build context, we introduce a `.dockerignore` file that only allows select binary to be sent over.

The downside of this is that we need to extend this ignore file every time we add a new test. This shouldn't happen very often though and is easily discovered because the building of the docker container will fail.
This commit is contained in:
Thomas Eizinger 2023-01-26 14:46:51 +11:00 committed by GitHub
parent 1b45d5e4dd
commit c94aabf8f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 6 deletions

10
.dockerignore Normal file
View File

@ -0,0 +1,10 @@
# This Docker ignore file aims to optimise the build process of the interop tests.
# The Dockerfile in ./interop-tests/Dockerfile copies a locally built binary into the container and
# thus does not need anything else to be present in the working directory.
*
# CI will build and copy over the release binary.
!target/release/ping
# Locally, we might want to build it as `debug` binary to accelerate the build process.
!target/debug/ping

View File

@ -24,13 +24,10 @@ jobs:
- name: Install Protoc
run: sudo apt-get install protobuf-compiler
- name: Build image
working-directory: ./interop-tests
run: |
cargo build --release -p interop-tests
mkdir -p target/release/
cp ../target/release/ping target/release
docker build -t rust-libp2p-head .
docker image save -o ping-image.tar rust-libp2p-head
docker build -t rust-libp2p-head --build-arg=TEST_BINARY=target/release/ping . -f ./interop-tests/Dockerfile
docker image save -o ./interop-tests/ping-image.tar rust-libp2p-head
- name: Upload ping versions info
uses: actions/upload-artifact@v3
with:

View File

@ -1,4 +1,5 @@
FROM ubuntu:22.04
COPY target/release/ping /usr/local/bin/testplan
ARG TEST_BINARY
COPY $TEST_BINARY /usr/local/bin/testplan
ENV RUST_BACKTRACE=1
ENTRYPOINT ["testplan"]