diff --git a/docker/tester/entrypoint.sh b/docker/tester/entrypoint.sh deleted file mode 100755 index 1a1c2626..00000000 --- a/docker/tester/entrypoint.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -set -euxo pipefail - -SOURCE_DIR=/source -BUILD_DIR=/build -TASK=${1:-test} - -if [ $TASK == "test" ]; then - echo "Building local docker image falcosecurity/falco:test from latest debian package..." - cp $BUILD_DIR/$BUILD_TYPE/falco*.deb $BUILD_DIR/$BUILD_TYPE/docker/local - cd $BUILD_DIR/$BUILD_TYPE/docker/local && docker build --build-arg FALCO_VERSION=${FALCO_VERSION} -t falcosecurity/falco:test . - - echo "Running regression tests" - cd $SOURCE_DIR/falco/test - bash run_regression_tests.sh $BUILD_DIR/$BUILD_TYPE - - docker rmi falcosecurity/falco:test || true - exit 0 -fi - -if [ $TASK == "bash" ]; then - exec /bin/bash -fi diff --git a/docker/tester/root/usr/bin/entrypoint b/docker/tester/root/usr/bin/entrypoint new file mode 100755 index 00000000..9374ab2c --- /dev/null +++ b/docker/tester/root/usr/bin/entrypoint @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +set -eu -o pipefail + +SOURCE_DIR=/source +BUILD_DIR=/build +CMD=${1:-test} +shift + +# Build type can be "debug" or "release", fallbacks to "release" by default +BUILD_TYPE=$(echo "$BUILD_TYPE" | tr "[:upper:]" "[:lower:]") +case "$BUILD_TYPE" in +"debug") + ;; +*) + BUILD_TYPE="release" + ;; +esac + +case "$CMD" in +"test") + if [ ! -d "$BUILD_DIR/$BUILD_TYPE/docker/local" ]; then + echo "Missing $BUILD_DIR/$BUILD_TYPE/docker/local directory." >&2 + exit 1 + fi + if [ -z "$FALCO_VERSION" ]; then + echo "Missing Falco version." >&2 + exit 1 + fi + if [ ! -f "$BUILD_DIR/$BUILD_TYPE/falco-$FALCO_VERSION-x86_64.deb" ]; then + echo "Package(s) not found." >&2 + exit 1 + fi + DOCKER_IMAGE_NAME="falcosecurity/falco:test" + echo "Building local docker image $DOCKER_IMAGE_NAME from latest debian package..." + cp "$BUILD_DIR/$BUILD_TYPE/falco-$FALCO_VERSION-x86_64.deb" $BUILD_DIR/$BUILD_TYPE/docker/local + cd $BUILD_DIR/$BUILD_TYPE/docker/local + docker build --build-arg FALCO_VERSION="$FALCO_VERSION" -t "$DOCKER_IMAGE_NAME" . + + # Check that source directory contains Falco and Sysdig + if [ ! -d "$SOURCE_DIR/falco/test" ]; then + echo "Missing $SOURCE_DIR/falco/test directory." >&2 + exit 1 + fi + echo "Running regression tests ..." + cd $SOURCE_DIR/falco/test + bash run_regression_tests.sh $BUILD_DIR/$BUILD_TYPE + docker rmi "$DOCKER_IMAGE_NAME" || true + ;; +"bash") + CMD=/bin/bash + ;& # fallthrough +"usage") + exec "$CMD" "$@" + ;; +esac \ No newline at end of file