rubydockerdocker-composeedxopenedx

Correct pulling edxops/forums way


I'm making my own devstack for works with OpenEdx.

I pulled the official devstack repository from edx and I'm modifying it.

I'm trying add forums to my stack but I can't run in since docker compose.

I added this to composer file:

forums:
    command: bash -c 'source /edx/app/forum/cs_comments_service_env && ruby app.rb -p 18080'
    container_name: edx.devstack.forums
    depends_on:
      #   - xqueue:xqueue
      - mongo
      - elasticsearch
      # - rabbitmq:rabbitmq
      - mysql
      - memcached
    environment:
      CACHE_LOCATION: edx.devstack.memcached:12211
      DB_HOST: edx.devstack.mysql
      TEST_ELASTICSEARCH_URL: "http://edx.devstack.elasticsearch:9200"
    image: edxops/forums:latest
    ports:
      - 4567:4567

I'm confuse about which the correct command in run:

studio:
    command: bash -c 'source /edx/app/edxapp/edxapp_env && python /edx/app/edxapp/edx-platform/manage.py cms runserver 0.0.0.0:18010 --settings devstack_docker'

This is the command for studio.

forums:
    command: bash -c 'source /edx/app/forum/cs_comments_service_env && ruby app.rb -p 18080'

I tried with this but the folder doesn't exist.

So I tried with: command: bash -c 'ruby app.rb -p 18080' but I get this error:

edx.devstack.forums | bash: ruby: command not found
edx.devstack.forums exited with code 127

So, I'm confused about the forums image and about how can I provide it so that it works correctly.

Can anyone help me?

UPDATE:

I have a new configuration:

forums:
    command: bash -c 'cd /edx/app/forum/cs_comments_service && exec /edx/app/forum/cs_comments_service/bin/unicorn -c config/unicorn_tcp.rb'
    container_name: edx.devstack.forums
    depends_on:
      # - xqueue:xqueue
      - mongo
      - elasticsearch
      # - rabbitmq:rabbitmq
      - mysql
      - memcached
    environment:
      CACHE_LOCATION: edx.devstack.memcached:12211
      DB_HOST: edx.devstack.mysql
      SEARCH_SERVER: "http://edx.devstack.elasticsearch:9200"
      TEST_ELASTICSEARCH_URL: "http://edx.devstack.elasticsearch:9200"
      MONGOHQ_URL: "mongodb://cs_comments_service:password@mongo.edx:27017/cs_comments_service"
      GEM_PATH: "/edx/app/forum/.gem"
      GEM_HOME: "/edx/app/forum/.gem"
      RBENV_ROOT: "/edx/app/forum/.rbenv"
    image: edxops/forum:latest
    ports:
      - 4567:4567

But I still have this issue:

docker-compose logs -f --tail=500 | grep edx.devstack.forums
Attaching to edx.devstack.forums, edx.devstack.chrome, edx.devstack.firefox, edx.devstack.credentials, edx.devstack.discovery, edx.devstack.elasticsearch, edx.devstack.ecommerce, edx.devstack.studio, edx.devstack.lms, edx.devstack.memcached, edx.devstack.mysql, edx.devstack.mongo
edx.devstack.forums | /usr/bin/env: ‘ruby’: No such file or directory

But, why?


Solution

  • I inspected the image and figured out the details that will be helpful in running the container. I will list down my findings as below:

    Also, ruby is installed at a custom path as follow:

        root@8a5de1d489c5:/edx/app# which ruby 
        /edx/app/forum/.rbenv/shims/ruby
    

    So environment variables need to loaded to use it. The environment variables loaded as part of startup include:

    export LISTEN_HOST="0.0.0.0"
    export NEW_RELIC_APP_NAME="default_env-default_deployment-forum"
    export DATA_DIR="/edx/var/forum"
    export LISTEN_PORT="4567"
    export MONGOHQ_URL="mongodb://cs_comments_service:password@mongo.edx:27017/cs_comments_service"
    export GEM_PATH="/edx/app/forum/.gem"
    export RACK_ENV="staging"
    export WORKER_PROCESSES="4"
    export NEW_RELIC_ENABLE="False"
    export SINATRA_ENV="staging"
    export SEARCH_SERVER="http://es.edx:9200"
    export PATH="/edx/app/forum/cs_comments_service/bin:/edx/app/forum/.rbenv/bin:/edx/app/forum/.rbenv/shims:/edx/app/forum/.gem/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
    export API_KEY="password"
    export HOME="/edx/app/forum"
    export GEM_HOME="/edx/app/forum/.gem"
    export RBENV_ROOT="/edx/app/forum/.rbenv"
    

    With this information you can run the image with required configuration.

    For example set the list of variables accordingly to your configuration in the environment section. You will need to set all of these variables in yml file. Once done the command should be

    bash -c 'cd /edx/app/forum/cs_comments_service && exec /edx/app/forum/cs_comments_service/bin/unicorn -c config/unicorn_tcp.rb'
    

    else if you want to avoid writing all these variables just write a custom script to do it for you or launch with default command which will be married to these config.