Coderunner inside a docker compose system

Coderunner inside a docker compose system

by Alexander D -
Number of replies: 5

Hi,

created a moodle system based on a docker compose file (compare this one) and added the "jobeinabox" image as an addtional service:

    docker_moodle-coderunner:
      container_name: docker_moodle-coderunner
      image: trampgeek/jobeinabox
      restart: always
      networks:
        - docker_moodlefault
 
 
Now, I run the whole docker-compose file in order to start all the different containers. Then I am able to do something like
 # curl http://docker_moodle-coderunner/jobe/index.php/restapi/languages                                       
[["c","11.4.0"],["cpp","11.4.0"],["java","11.0.20.1"],["nodejs","12.22.9"],["octave","6.4.0"],["pascal","3.2.2"],["php","8.1.2"],["python3","3.10.12"]]# 
 
inside some container which is not the coderunner container (e.g. PHP-App)
I.e. The PHP-Container is able to communicate to the Jobe-Server.

Though, I've added the name of the jobe server inside the plugins configuration i.e.

docker_moodle-coderunner 

I am not able to run a simple coderunner-question:




Notice: Undefined index: http_code in /var/www/html/question/type/coderunner/classes/jobesandbox.php on line 375

and

An error occurred while processing your responses (Error from the sandbox [jobesandbox]: Unexpected error while executing your code. The sandbox server may be down or overloaded. Perhaps try again shortly?). Click continue to return to the page you were on and try again.

Does anybody know how to setup coderunner in this special environment?
I want to use an INTERNAL docker network for the communication in order to restrict access to the jobe server to the single moodle system which is defined inside the docker compose file.

Thank you very much in advance!

Best,
Alex


In reply to Alexander D

Re: Coderunner inside a docker compose system

by Richard Lobb -
The undefined index error shouldn't be occurring nowadays - I'm guessing you have a version of CodeRunner that's at least a year old? With more recent versions, you should get a slightly more helpful error message.

Given that the PHP-container seems able to access Jobe at http://docker_moodle-coderunner, and you've set the jobe URL in the coderunner settings to docker_moodle-coderunner, I'm guessing that the error message you're not seeing is "URL is blocked". Go to Site administration > General > HTTP security and empty both the fields cURL blocked hosts list and cURL allowed ports list. Post back if that doesn't work. Also, if you can find which hosts don't need to be blocked and which ports you need to allow, please let us know. I had to clear both those fields to get it working, which seems odd.
In reply to Richard Lobb

Re: Coderunner inside a docker compose system

by Richard Lobb -
I have since found that the reason you have to clear out all the blocked hosts is because if there are any entries there at all, Moodle inspects the Jobe server URL and immediately blocks it because it has an underscore in it (which isn't a valid domain name)!

So an improved way to avoid the Blocked URL problem is to change the moodle-compose service name so it doesn't contain an underscore. However, you still need to remove the following entries from the cURL blocked host list:
 
    * 127.0.0.1
    * 192.168.0.0/16
    * localhost
 
I've cloned the github project you linked to and updated its docker-compose.yml file, plus the README, to give a working moodle + coderunner.  See here.
In reply to Richard Lobb

Re: Coderunner inside a docker compose system

by Alexander D -
Hi Richard,

thank you very much for you response!
Now, it is working!
Best,
Alex
In reply to Alexander D

Re: Coderunner inside a docker compose system

by Alexander D -
Hi Richard,
one last thing I've recognised in this context:

When I'm running coderunner questions in this setting above I have to increase manually the Memomy limit under Advanced Customisation->Memory Limit (e.g. to 10000).
I think using "some more memory" is OK, due to this special docker setting.
But when I leave the field Memory Limit empty I get an memory error, too:
  
Syntax Error(s)
rosetta error: mmap_anonymous_rw mmap failed, size=1000
/var/www/html/jobe/application/libraries/../../runguard/runguard: warning: command terminated with signal 5
In my opinion the should be no memory limit, when the respective field is left empty.
Any idea here?

Thank you very much in advance!
Best,
Alex

PS: In my docker configuration I reserved 16GB of memory to docker. The corresponding stats of the container saying that the jobe-server is using just 164MB of all this memory.
PS2: I'm using a Apple M2 machine and I have read something about this error in this special situation. So maybe this could be the reason...
In reply to Alexander D

Re: Coderunner inside a docker compose system

by Alexander D -
Hey,
finally I found the file LanguageTask.php, which seems to be define all the limits, when the corresponding fields are left empty.
I have adapted the corresponding parts in this file and now everything is running properly.

Best,
Alex