blob: f60def42c0eb7ef5602b29751bb2009bf5f522a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#!/bin/bash
source ./functions.sh
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=$(docker build -q .) || exit 1
catch compiler_stdout compiler_stderr docker run \
--rm \
--network none \
-e APPLICATION_NAME=$application_name \
-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=$(\
docker build \
--build-arg "EXEC_DIR_HOST=$exec_path_relative" \
-q \
-f "containers/runner/Dockerfile" .
) || exit 1
catch runner_stdout runner_stderr timeout 60 docker run \
--rm \
-h "java-runner-$runner_id" \
--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
php generate-status-object.php $runner_id
rm -rf "$runner_dir"
|