Files
codeocean/docs/LOCAL_SETUP.md

6.1 KiB

Local Setup

If available, we prefer a native setup for best performance and less technical issues. Please see below for some details.

Vagrant

Install prerequisites

Clone repositories

The following two repositories have to be cloned in the same directory:

Vagrant assumes that these repositories are completely clean. For example, Vagrant will setup all configuration files in config (in both repositories) based on the examples provided in the same directory. Therefore it is important that these configuration files do not exist before running vagrant up. It is recommended to have a freshly cloned repository but you can also try to remove untracked files by running git clean -xf in both repositories.

Create and start VM

  • Switch to the codeocean directory
  • Run vagrant up
  • If this command fails please try the following:
    • Run vagrant destroy -f to remove the broken VM
    • Make sure that both repositories are freshly cloned, for example by deleting and cloning them again
    • Retry to execute vagrant up
  • The VM pulls only one docker image: openhpi/co_execenv_python:3.8

Start server

You can configure vagrant as remote interpreter in RubyMine and start the rails server via RubyMine or you can start it manually from the command line:

vagrant ssh
cd /home/vagrant/dockercontainerpool
rails s -p 3100

# using another ssh session
cd /home/vagrant/codeocean
rails s -p 3000 -b 0.0.0.0

The default credentials for the administrator are:

  • email: admin@example.org
  • password: admin

Execution Environments

Every exercise is executed in an execution environment which is based on a docker image. In order to install a new image, have a look at the container of the openHPI team on DockerHub. For example you can add an image for ruby by executing docker pull openhpi/co_execenv_ruby:latest.
After that make sure to configure the corresponding execution environment for the docker images you want to use in your CodeOcean instance. Therefore sign in on your running CodeOcean server as an administrator and select Execution Environments from the Administration dropdown. The Docker Container Pool Size should be greater than 0 for every execution environment you want to use.

Webpack

This project uses webpacker to integrate Webpack with Rails to deliver Frontend assets. During development, the webpack-dev-server automatically launches together with the Rails server if not specified otherwise. In case of missing JavaScript or stylesheets or for hot reloading in the browser, you might want to start the webpack-dev-server manually before starting Rails:

./bin/webpack-dev-server

This will launch a dedicated server on port 3035 (default setting) and allow incoming WebSocket connections from your browser.

Native setup (for macOS)

  • Clone this repository:
    git clone git@github.com:openHPI/codeocean.git
    
  • Install PostgreSQL, start it and create a generic postgres user:
    brew install postgresql
    brew services start postgresql
    createuser -s -r postgres
    
  • Install NVM and node:
    brew install nvm
    mkdir ~/.nvm
    nvm install --lts
    
  • Add the following lines to your profile. (e.g., ~/.zshrc):
    # NVM
    export NVM_DIR=~/.nvm
    source $(brew --prefix nvm)/nvm.sh
    
  • Install yarn:
    brew install yarn --ignore-dependencies
    
  • Install docker:
    brew install docker
    open /Applications/Docker.app/
    
  • Install nginx and adopt its config to forward requests to the RAW docker UNIX socket (see this issue for more details). Only required for macOS!
    brew install nginx
    
    Edit /usr/local/etc/nginx/nginx.conf:
    1. Change the default port 8080 to 2376 (around line 36).
    2. Replace the location / with the following and (!) replace <yourname> with the output of whoami:
    location / {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header Host $host;
      proxy_set_header X-NginX-Proxy true;
    
      proxy_pass http://unix:/Users/<yourname>/Library/Containers/com.docker.docker/Data/docker.raw.sock;
      proxy_redirect off;
    
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
    }
    
    Now, start nginx:
    brew services start nginx
    
  • Install RVM and bundler:
    gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
    curl -sSL https://get.rvm.io | bash -s stable --rails
    gem install bundler
    
  • Install geckodriver and Firefox for Selenium:
    brew install geckodriver
    brew cask install firefox
    
  • Get a local copy of the config files and verify the settings:
    for f in action_mailer.yml database.yml secrets.yml code_ocean.yml docker.yml.erb mnemosyne.yml
    do
      if [ ! -f config/$f ]
      then
        cp config/$f.example config/$f
      fi
    done
    
  • Install gems and yarn files:
    bundle install
    yarn install
    
  • Setup your database:
    rake db:create
    rake db:schema:load
    rake db:migrate
    rake db:seed
    
  • Start the server:
    rails s