From b8f50bb7a62442c33b17cb820d2634a4c3cd6db9 Mon Sep 17 00:00:00 2001 From: Kapil Date: Wed, 13 Jun 2018 14:29:20 +0530 Subject: [PATCH 1/5] Add support for ruby --- README.md | 2 ++ containers/ruby/Dockerfile | 9 +++++++++ containers/ruby/compile.sh | 1 + containers/ruby/run.sh | 2 ++ tests/ruby/run.stdin | 1 + tests/ruby/runbox/run.stderr | 0 tests/ruby/runbox/run.stdin | 1 + tests/ruby/runbox/run.stdout | 1 + tests/ruby/runbox/script.rb | 1 + tests/ruby/script.rb | 1 + tests/ruby/test_worker.sh | 30 ++++++++++++++++++++++++++++++ 11 files changed, 49 insertions(+) create mode 100644 containers/ruby/Dockerfile create mode 100644 containers/ruby/compile.sh create mode 100644 containers/ruby/run.sh create mode 100644 tests/ruby/run.stdin create mode 100644 tests/ruby/runbox/run.stderr create mode 100644 tests/ruby/runbox/run.stdin create mode 100644 tests/ruby/runbox/run.stdout create mode 100644 tests/ruby/runbox/script.rb create mode 100644 tests/ruby/script.rb create mode 100644 tests/ruby/test_worker.sh diff --git a/README.md b/README.md index fc443ff..50bc03e 100644 --- a/README.md +++ b/README.md @@ -25,4 +25,6 @@ Currently we have following images - - [nodejs6](containers/nodejs6) - [nodejs](containers/nodejs8) - [py2](containers/py2) + - [py3](containers/py3) + - [ruby](containers/ruby) diff --git a/containers/ruby/Dockerfile b/containers/ruby/Dockerfile new file mode 100644 index 0000000..b6db57b --- /dev/null +++ b/containers/ruby/Dockerfile @@ -0,0 +1,9 @@ +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 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..98629e8 --- /dev/null +++ b/containers/ruby/run.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +ruby script.rb < run.stdin 1> run.stdout 2> run.stderr \ No newline at end of file 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..557db03 --- /dev/null +++ b/tests/ruby/runbox/run.stdout @@ -0,0 +1 @@ +Hello World 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..39d0a45 --- /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 \ No newline at end of file From 8279222e6aa733334c169f898e0ebb411be81744 Mon Sep 17 00:00:00 2001 From: Kapil Date: Mon, 18 Jun 2018 00:22:31 +0530 Subject: [PATCH 2/5] Fix Ruby version --- containers/ruby/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/containers/ruby/Dockerfile b/containers/ruby/Dockerfile index b6db57b..ff6a0a1 100644 --- a/containers/ruby/Dockerfile +++ b/containers/ruby/Dockerfile @@ -1,6 +1,6 @@ FROM alpine:3.6 -RUN apk add --no-cache ruby bash +RUN apk add --no-cache ruby=2.5.1 bash COPY ./compile.sh /bin/compile.sh COPY ./run.sh /bin/run.sh From f9dff0c8c13a8466ae42e21dfefbd57e5098d407 Mon Sep 17 00:00:00 2001 From: Arnav Gupta Date: Fri, 6 Jul 2018 05:41:12 +0530 Subject: [PATCH 3/5] Create test.sh --- test.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test.sh b/test.sh index ee3af42..d9eb218 100755 --- a/test.sh +++ b/test.sh @@ -28,3 +28,7 @@ sh tests/py3/test_worker.sh } +@test "test ruby" { + sh tests/ruby/test_worker.sh +} + From 0f7d0409f6c4db90c7ba91f5a2e3af3aadb16711 Mon Sep 17 00:00:00 2001 From: Kapil Date: Fri, 6 Jul 2018 11:14:35 +0530 Subject: [PATCH 4/5] Update Ruby Dockerfile --- containers/ruby/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/containers/ruby/Dockerfile b/containers/ruby/Dockerfile index ff6a0a1..275645b 100644 --- a/containers/ruby/Dockerfile +++ b/containers/ruby/Dockerfile @@ -1,6 +1,6 @@ FROM alpine:3.6 -RUN apk add --no-cache ruby=2.5.1 bash +RUN apk add --no-cache ruby="2.4.4-r0" bash COPY ./compile.sh /bin/compile.sh COPY ./run.sh /bin/run.sh From fc21e0bb2d367a538da3134d4edeab0e8f3930f7 Mon Sep 17 00:00:00 2001 From: Arnav Gupta Date: Fri, 6 Jul 2018 18:09:46 +0530 Subject: [PATCH 5/5] bash to test --- test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.sh b/test.sh index d9eb218..3f1d73d 100755 --- a/test.sh +++ b/test.sh @@ -29,6 +29,6 @@ } @test "test ruby" { - sh tests/ruby/test_worker.sh + bash tests/ruby/test_worker.sh }