#!/bin/bash source ./functions.sh unset DOCKER_HOST if [ "$1" == "" ]; then echo "Parameter 1 is empty" exit 1 fi if [ "$2" == "" ]; then echo "Parameter 2 is empty" exit 1 fi runner_id="$1" application_name="$2" runner_dir="./_runners/$runner_id" src_path="$runner_dir/src" exec_path="$runner_dir/exec" exec_path_relative="$exec_path" results_path="$runner_dir/results" mkdir -p $src_path $exec_path $results_path src_path="$(realpath "$src_path")" exec_path="$(realpath "$exec_path")" results_path="$(realpath "$results_path")" pushd containers/compiler > /dev/null compiler_image="ic$runner_id" docker build -q -t $compiler_image . || exit 1 catch compiler_stdout compiler_stderr docker run \ --rm \ --network none \ -e APPLICATION_NAME=$application_name \ --memory=128m \ --cpus=1 \ -v "$src_path:/opt/src:ro" \ -v "$exec_path:/tmp/exec" \ $compiler_image compiler_status=$? docker image rm -f $compiler_image > /dev/null || exit 1 popd > /dev/null printf '%s' "$compiler_status" > $results_path/c.s printf '%s' "$compiler_stdout" > $results_path/c.0 printf '%s' "$compiler_stderr" > $results_path/c.1 if [ $compiler_status -eq 0 ]; then runner_image="ir$runner_id" docker build \ --build-arg "EXEC_DIR_HOST=$exec_path_relative" \ -q \ -t "$runner_image" \ -f "containers/runner/Dockerfile" . \ || exit 1 catch runner_stdout runner_stderr timeout 60 docker run \ --rm \ -h "java-runner-$runner_id" \ --memory=32m \ --cpus=0.25 \ --network none \ -e "APPLICATION_NAME=$application_name" \ "$runner_image" runner_status=$? docker image rm -f $runner_image > /dev/null || exit 1 printf '%s' "$runner_status" > $results_path/r.s printf '%s' "$runner_stdout" > $results_path/r.0 printf '%s' "$runner_stderr" > $results_path/r.1 fi