diff --git a/README.md b/README.md index 9f8ac74..90cf890 100644 --- a/README.md +++ b/README.md @@ -23,4 +23,4 @@ Currently we have following images - - [nodejs6](containers/nodejs6) - [nodejs](containers/nodejs8) - [py2](containers/py2) - + - [ruby](containers/ruby) diff --git a/containers/ruby/Dockerfile b/containers/ruby/Dockerfile new file mode 100644 index 0000000..5f66556 --- /dev/null +++ b/containers/ruby/Dockerfile @@ -0,0 +1,7 @@ +FROM alpine:3.6 + +RUN apk add --no-cache ruby bash +COPY ./compile.sh /bin/compile.sh +COPY ./run.sh /bin/run.sh +RUN chmod 777 /bin/compile.sh; \ + chmod 777 /bin/run.sh \ No newline at end of file diff --git a/containers/ruby/compile.sh b/containers/ruby/compile.sh new file mode 100644 index 0000000..212c4ba --- /dev/null +++ b/containers/ruby/compile.sh @@ -0,0 +1 @@ +#!/usr/bin/env bash \ No newline at end of file diff --git a/containers/ruby/run.sh b/containers/ruby/run.sh new file mode 100644 index 0000000..4916f60 --- /dev/null +++ b/containers/ruby/run.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +ruby script.rb < run.stdin 1> run.stdout 2> run.stderr diff --git a/tests/ruby/run.stdin b/tests/ruby/run.stdin new file mode 100644 index 0000000..beef906 --- /dev/null +++ b/tests/ruby/run.stdin @@ -0,0 +1 @@ +World \ No newline at end of file diff --git a/tests/ruby/runbox/run.stderr b/tests/ruby/runbox/run.stderr new file mode 100644 index 0000000..e69de29 diff --git a/tests/ruby/runbox/run.stdin b/tests/ruby/runbox/run.stdin new file mode 100644 index 0000000..beef906 --- /dev/null +++ b/tests/ruby/runbox/run.stdin @@ -0,0 +1 @@ +World \ No newline at end of file diff --git a/tests/ruby/runbox/run.stdout b/tests/ruby/runbox/run.stdout new file mode 100644 index 0000000..5e1c309 --- /dev/null +++ b/tests/ruby/runbox/run.stdout @@ -0,0 +1 @@ +Hello World \ No newline at end of file diff --git a/tests/ruby/runbox/script.rb b/tests/ruby/runbox/script.rb new file mode 100644 index 0000000..ac3e255 --- /dev/null +++ b/tests/ruby/runbox/script.rb @@ -0,0 +1 @@ +puts "Hello " + gets.to_s \ No newline at end of file diff --git a/tests/ruby/script.rb b/tests/ruby/script.rb new file mode 100644 index 0000000..ac3e255 --- /dev/null +++ b/tests/ruby/script.rb @@ -0,0 +1 @@ +puts "Hello " + gets.to_s \ No newline at end of file diff --git a/tests/ruby/test_worker.sh b/tests/ruby/test_worker.sh new file mode 100644 index 0000000..03ce079 --- /dev/null +++ b/tests/ruby/test_worker.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +pushd $(dirname "$0") +DIR=$(pwd) +RUNBOX="${DIR}/runbox" + +echo $RUNBOX +# Remove RUNBOX +rm -rf $RUNBOX + +# Create runbox +mkdir -p $RUNBOX + +# Copy source to runbox +cp $DIR/script.rb $RUNBOX/script.rb +cp $DIR/run.stdin $RUNBOX/run.stdin + +# Test Compile +docker run \ + --cpus="0.5" \ + --memory="20m" \ + --ulimit nofile=64:64 \ + --rm \ + --read-only \ + -v "$RUNBOX":/usr/src/runbox \ + -w /usr/src/runbox codingblocks/judge-worker-ruby \ + bash -c "/bin/compile.sh && /bin/run.sh" + + +# Delete runbox +#rm -rf $RUNBOX