Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Ruby added #8

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ Currently we have following images -
- [nodejs6](containers/nodejs6)
- [nodejs](containers/nodejs8)
- [py2](containers/py2)

- [ruby](containers/ruby)
7 changes: 7 additions & 0 deletions containers/ruby/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM alpine:3.6

RUN apk add --no-cache ruby bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should install a particular version of ruby. otherwise the image won't stay consistent over time

COPY ./compile.sh /bin/compile.sh
COPY ./run.sh /bin/run.sh
RUN chmod 777 /bin/compile.sh; \
chmod 777 /bin/run.sh
1 change: 1 addition & 0 deletions containers/ruby/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/usr/bin/env bash
3 changes: 3 additions & 0 deletions containers/ruby/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

ruby script.rb < run.stdin 1> run.stdout 2> run.stderr
1 change: 1 addition & 0 deletions tests/ruby/run.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
World
Empty file added tests/ruby/runbox/run.stderr
Empty file.
1 change: 1 addition & 0 deletions tests/ruby/runbox/run.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
World
1 change: 1 addition & 0 deletions tests/ruby/runbox/run.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello World
1 change: 1 addition & 0 deletions tests/ruby/runbox/script.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
puts "Hello " + gets.to_s
1 change: 1 addition & 0 deletions tests/ruby/script.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
puts "Hello " + gets.to_s
30 changes: 30 additions & 0 deletions tests/ruby/test_worker.sh
Original file line number Diff line number Diff line change
@@ -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