forked from jutge-org/jutge-server-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjutge-test-run
executable file
·39 lines (28 loc) · 1.03 KB
/
jutge-test-run
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
#!/usr/bin/env bash
function usage() {
fmt <<EOF
Usage: jutge-test-run <image-name> <command> [args...]
Execute commands in a container using one of the Jutge images.
The <image-name> will be prefixed with "jutgeorg/" (so you don't need
to include it). Available images are stored at Docker Hub
(https://hub.docker.com/u/jutgeorg).
Example <image-name>s: "gcc", "python", "java", "haskell" and "extra".
This test version maps the current directory as /home/worker in the
container, sets the UID to the current user (to avoid permission issues)
and starts the command interactively.
EOF
}
if [ "$#" -lt 2 ] || [ "$1" = '-h' ] || [ "$1" = '--help' ] || [ "$2" = '-h' ] || [ "$2" = '--help' ]; then
usage
exit
fi
image="$1"
shift # consume first argument so that $@ contains the rest
if [ -t 1 ]; then # check if stdout is a TTY
term="-t"
fi
volume="-v $(pwd):/home/worker"
user="-u $(id -u):$(id -g)"
jail="--network=none --memory=1g --cpus=1"
# Run it
docker run --rm -i $term $jail $user $volume jutgeorg/$image $@