Coder Social home page Coder Social logo

Comments (10)

prasmussen avatar prasmussen commented on May 19, 2024 2

You can pass the environment variables to docker run.
Here is a slightliy modified bash script i have used in the past to start the container:

docker run \
  -p 8090:8090 \
  --detach \
  --restart always \
  --env API_ENVIRONMENT="production" \
  --env API_HTTP_LISTEN_IP="0.0.0.0" \
  --env API_HTTP_LISTEN_PORT="8090" \
  --env DATA_PATH="/home/app/data/" \
  --env LOG_PATH="/home/app/log/" \
  --env BASE_URL="https://run.glot.io" \
  --env ADMIN_TOKEN="secret" \
  --env DOCKER_API_URL="http://10.0.0.127" \
  --env DOCKER_RUN_TIMEOUT="15" \
  --env MAX_OUTPUT_SIZE="100000" \
  --volume /containers/glot-run/data:/home/app/data \
  --volume /containers/glot-run/log:/home/app/log \
  glotrun

from glot-run.

arxenix avatar arxenix commented on May 19, 2024 2

@prasmussen Thanks, but I'm still not able to get it working. When I make a POST to /languages/python/latest with data {"files": [{"name": "main.py", "content": "print(42)"}]}, and the Authorization: Token usertoken. I no longer get the auth failed error, but I get a HTTP 500 error after aboutt 8 seconds.

This is the stack trace in the docker logs.

19:00:57.952 [error] Ranch listener http had connection process started with cowboy_protocol:start_link/4 at <0.663.0> exit with reason: {[{reason,{badmatch,{error,connect_timeout}}},{mfa,{language_run_resource,accept_post,2}},{stacktrace,[{docker,container_create,1,[{file,"/glot-run/_build/default/lib/glot/src/docker/docker.erl"},{line,13}]},{language_run,run,3,[{file,"/glot-run/_build/default/lib/glot/src/models/language_run.erl"},{line,11}]},{language_run_resource,run_code,3,[{file,"/glot-run/_build/default/lib/glot/src/resources/language_run_resource.erl"},{line,97}]},{cowboy_rest,call,3,[{file,"/glot-run/_build/default/lib/cowboy/src/cowboy_rest.erl"},{line,976}]},{cowboy_rest,process_content_type,3,[{file,"/glot-run/_build/default/lib/cowboy/src/cowboy_rest.erl"},{line,777}]},{cowboy_protocol,execute,4,[{file,"/glot-run/_build/default/lib/cowboy/src/cowboy_protocol.erl"},{line,442}]}]},{req,[{socket,#Port<0.997>},{transport,ranch_tcp},{connection,keepalive},{pid,<0.663.0>},{method,<<"POST">>},{version,'HTTP/1.1'},{peer,{{172,17,42,1},56216}},{host,<<"localhost">>},{host_info,undefined},{port,80},{path,<<"/languages/python/latest">>},{path_info,undefined},{qs,<<>>},{qs_vals,undefined},{bindings,[{version,<<"latest">>},{name,<<"python">>}]},{headers,[{<<"user-agent">>,<<"curl/7.35.0">>},{<<"host">>,<<"localhost">>},{<<"accept">>,<<"*/*">>},{<<"authorization">>,<<"Token usertoken">>},{<<"content-type">>,<<"application/json">>},{<<"content-length">>,<<"56">>}]},{p_headers,[{<<"content-type">>,{<<"application">>,<<"json">>,[]}},{<<"if-modified-since">>,undefined},{<<"if-none-match">>,undefined},{<<"if-unmodified-since">>,undefined},{<<"if-match">>,undefined},{<<"accept">>,[{{<<"*">>,<<"*">>,[]},1000,[]}]}]},{cookies,undefined},{meta,[{media_type,{<<"application">>,<<"json">>,[]}},{charset,undefined}]},{body_state,waiting},{buffer,<<"{\"files\": [{\"name\": \"main.py\", \"content\": \"print(42)\"}]}">>},{multipart,undefined},{resp_compress,false},{resp_state,waiting},{resp_headers,[{<<"content-type">>,[<<"application">>,<<"/">>,<<"json">>,<<>>]}]},{resp_body,<<>>},{onresponse,#Fun<http_util.log_response.4>}]},{state,{state,<<"python">>,<<"latest">>}}],[{cowboy_rest,process_content_type,3,[{file,"/glot-run/_build/default/lib/cowboy/src/cowboy_rest.erl"},{line,777}]},{cowboy_protocol,execute,4,[{file,"/glot-run/_build/default/lib/cowboy/src/cowboy_protocol.erl"},{line,442}]}]}

it seems to be some sort of problem in spawning the docker container to run the program?

from glot-run.

prasmussen avatar prasmussen commented on May 19, 2024 1

Yes, it seems like container_create process times out. Make sure that that the glotrun container is able to access the docker api. Try doing curl $DOCKER_API_URL/version from inside the container. This should return the docker version. (Probably need to install curl first)

from glot-run.

arxenix avatar arxenix commented on May 19, 2024 1

I got it working. I did have the languages registered. The problem was that I was using the incorrect docker API URL (I just copied the example one)

from glot-run.

prasmussen avatar prasmussen commented on May 19, 2024

Seems like the API_HTTP_LISTEN_PORT variable is not set correctly.

from glot-run.

arxenix avatar arxenix commented on May 19, 2024

Yeah, I just realized that. I'm not sure how to set it correctly though. I know its not an issue with your project but could you help me out?

from glot-run.

arxenix avatar arxenix commented on May 19, 2024

Thank you so much for the help! It seems to be working now. Thanks for open sourcing this great project

from glot-run.

arxenix avatar arxenix commented on May 19, 2024

@prasmussen sorry, 1 last question! I tried sending a curl POST request to it, but I get an invalid token error even though I have the header Authorization: Token secret, and I set the env variable ADMIN_TOKEN to secret. Do I need to hash it or something?

from glot-run.

prasmussen avatar prasmussen commented on May 19, 2024

Note the admin token only works for the the /admin endpoints, to create a normal user you can use the following query:

curl -sv -H "Authorization: Token secret" -H 'Content-type: application/json' -X POST -d '{"token": "af4c0a23-7b42-4207-b61c-1430c9637056"}' http://localhost:8090/admin/users

from glot-run.

javierprovecho avatar javierprovecho commented on May 19, 2024

@bobacadodl did you register the language in glot-run? Did you download the python container in your docker daemon?

Check #9 for some scripts to download and register all languages 😉

from glot-run.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.