Skip to content

Commit 4c3f0f0

Browse files
resource limiting
Signed-off-by: Arnav Gupta <arnav@codingblocks.com>
1 parent dcddbb6 commit 4c3f0f0

File tree

20 files changed

+85
-11
lines changed

20 files changed

+85
-11
lines changed

build_workers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ DIR=$(cd -)
55
for i in $(ls "$DIR/containers")
66
do
77
cd $DIR/containers/$i
8-
docker image rm codingblocks/judge-worker-$i
8+
#docker image rm codingblocks/judge-worker-$i
99
docker build -t codingblocks/judge-worker-$i .
1010
cd $DIR
1111
done

containers/c/compile.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
22

3-
gcc -o exe source.c
3+
gcc -o exe source.c 2> compile.stderr 1> compile.stdout

containers/cpp/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
FROM alpine:3.6
22

33
RUN apk add --no-cache g++ musl-dev bash
4+
COPY ./compile.sh /bin/compile.sh

containers/cpp/compile.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
g++ -o exe source.cpp 2> compile.stderr 1> compile.stdout

containers/java8/compile.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
22

3-
javac Main.java
3+
javac Main.java 2> compile.stderr 1> compile.stdout

tests/c/runbox/compile.stderr

Whitespace-only changes.

tests/c/runbox/compile.stdout

Whitespace-only changes.

tests/c/runbox/exe

10.4 KB
Binary file not shown.

tests/c/runbox/source.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <stdio.h>
2+
3+
int main () {
4+
printf("Hello World");
5+
return 0;
6+
}

tests/c/test_worker.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
#!/usr/bin/env bash
2-
SCRIPTPATH=$(dirname "$0")
3-
RUNBOX="${SCRIPTPATH}/runbox"
2+
pushd $(dirname "$0")
3+
DIR=$(pwd)
4+
RUNBOX="${DIR}/runbox"
45

56
echo $RUNBOX
67
# Create runbox
78
mkdir -p $RUNBOX
89

910
# Copy source to runbox
10-
cp $SCRIPTPATH/source.c $RUNBOX/source.c
11+
cp $DIR/source.c $RUNBOX/source.c
1112

1213
# Test Compile
13-
docker run --rm -v "$PWD/runbox":/usr/src/runbox -w /usr/src/runbox codingblocks/judge-worker-c /bin/compile.sh
14+
docker run \
15+
--cpus="0.5" \
16+
--memory="20m" \
17+
--ulimit nofile=64:64 \
18+
--rm \
19+
--read-only \
20+
-v "$RUNBOX":/usr/src/runbox \
21+
-w /usr/src/runbox codingblocks/judge-worker-c \
22+
/bin/compile.sh
1423

1524
# Delete runbox
1625
#rm -rf $RUNBOX

0 commit comments

Comments
 (0)