Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Currently we have following images -
- [java8](containers/java8)
- [nodejs6](containers/nodejs6)
- [nodejs](containers/nodejs8)
- [php7](containers/php7)
- [py2](containers/py2)
- [py3](containers/py3)
- [ruby](containers/ruby)
9 changes: 9 additions & 0 deletions containers/php7/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM alpine:3.6

RUN apk add --no-cache musl-dev php7="7.1.17-r0" bash

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/php7/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/php7/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

php script.php < run.stdin 1> run.stdout 2> run.stderr
10 changes: 7 additions & 3 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
bash tests/c/test_worker.sh
}

#@test "test cpp" {
# bash tests/cpp/test_worker.sh
#}
@test "test cpp" {
bash tests/cpp/test_worker.sh
}

@test "test csharp" {
bash tests/csharp/test_worker.sh
Expand All @@ -28,6 +28,10 @@
bash tests/nodejs8/test_worker.sh
}

@test "test php7" {
bash tests/php7/test_worker.sh
}

@test "test py2" {
bash tests/py2/test_worker.sh
}
Expand Down
1 change: 1 addition & 0 deletions tests/php7/run.stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
World
Copy link
Contributor

Choose a reason for hiding this comment

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

how does this work without W ?

Copy link
Contributor Author

@vibhorgupta-gh vibhorgupta-gh Jul 27, 2018

Choose a reason for hiding this comment

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

@championswimmer Did not get you, could you elaborate?

Copy link
Contributor Author

@vibhorgupta-gh vibhorgupta-gh Jul 28, 2018

Choose a reason for hiding this comment

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

It's failing without the W

screen shot 2018-07-28 at 5 54 08 am

6 changes: 6 additions & 0 deletions tests/php7/script.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

$line = readline();
echo 'Hello ' . $line;

?>
41 changes: 41 additions & 0 deletions tests/php7/test_worker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/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 -fv $DIR/script.php $RUNBOX/script.php
cp -fv $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 \
-v "$RUNBOX":/tmp \
-w /usr/src/runbox codingblocks/judge-worker-php7 \
bash -c "/bin/compile.sh && /bin/run.sh"

ls -lh ${RUNBOX}

expected="Hello World"
actual="$(cat ${RUNBOX}/run.stdout)"
if [ "$expected" == "$actual" ] ;then
:
else
echo "MISMATCH: Expected = $expected; Actual = $actual"
exit 1
fi

# Delete runbox
rm -rf $RUNBOX