interactive programming tutorials, powered by Github and Docker
HTML Python Shell CSS
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
app.wsgi.sample.dev_prod is an early stage prototype for turning code repositories into interactive tutorials and books, with code snippets that can be edited and run on the web.

Test your locally

  • git clone
  • cd
  • git submodule init; git submodule update
  • cd pub/templates/local
  • git clone<user>/<repo>.git
  • cd ../.. (back to pub directory)
  • python (powered by flask and requests)
  • visit http://localhost:5000/learn/<user>/<repo>
  • if you make code changes, refresh the server installation by visiting<user>/<repo>?refresh=1

Development server-side installation steps

These steps have been tested on an Ubuntu derivative.

  • Install dependencies

    • Install docker.
    • sudo apt-get install redis-server python-pip git
    • sudo pip install flask redis docker-py
  • Set up local repository in a directory of your choice

    • git clone --recursive
    • export LIVECODE_DIR=``pwd``/
  • Install the docker image

    • Get the official image
      • docker pull namin/
      • export LIVECODE_CONFIG="dev"
    • Or build your own from the source repo
      • cd $LIVECODE_DIR; docker build -t=namin/ .
      • export LIVECODE_CONFIG="dev_docker"
  • Run local development server

    • cd $LIVECODE_DIR
    • python

Production server-side installation steps

These steps have been tested on a DigitalOcean (referral link) docker application droplet, and work regardless of the actual (sub)domain name of your server (i.e. no need to change occurrences of in config files).

  • Create a new droplet in the DigitalOcean UI:

    • for the image, select the Applications tab, then Docker ... on Ubuntu: screenshot of selecting docker application image
    • for the other options, select as you please. My options:
      • for the size, I use the second smallest droplet, though any other including the smallest should work too.
      • for the last settings, I keep the default VirtIO enabled (I have not tested it disabled). I also like to enable Backups, though it's not essential.
  • Initial setup of the server

    • $ME refers to your preferred username (e.g. namin for me)
    • $DKR refers to a docker-enabled user (e.g. dkr, which I use for scheduling docker cleanups)
    • as root:
      • be sure to set $ME and $DKR as you like. I do:
        • export ME=namin
        • export DKR=dkr
      • apt-get update
      • apt-get upgrade
      • apt-get install lxc-docker
      • adduser $ME
      • usermod -a -G www-data,docker,sudo $ME
      • usermod -a -G docker www-data
      • adduser $DKR
      • usermod -a -G docker $DKR
    • as $ME:
      • set up your favorite editor (and other tools) as you please. I do:
        • set up emacs
          • sudo apt-get install emacs24

          • git clone -b server

            (in $HOME directory)

          • run emacs to ensure customization works

        • configure git
          • git config --global "Nada Amin"
          • git config --global ""
          • git config --global core.editor emacs
      • pull official docker image
        • docker pull namin/
      • set up NGINX
        • sudo apt-get install nginx

        • sudo rm /etc/nginx/sites-enabled/default

          (rationale: the default kicks in too easily)

        • (when adding another domain (e.g., I had to comment out this line in /etc/nginx/nginx.conf: server_names_hash_bucket_size 64;)

      • set up dependencies
        • sudo apt-get install uwsgi uwsgi-plugin-python
        • sudo apt-get install redis-server
        • sudo apt-get install python-pip python-dev
        • sudo pip install flask redis docker-py
      • set up website
        • cd /var
        • sudo mkdir www
        • sudo chown www-data:www-data www
        • sudo chmod g+w www
        • cd www
        • git clone
        • cd
        • git submodule init; git submodule update
        • cp app.wsgi.sample app.wsgi
        • cd cfg
        • sudo cp nginx-site.sample /etc/nginx/sites-available/
        • sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/
        • sudo cp uwsgi-app.ini.sample /etc/uwsgi/apps-available/
        • sudo ln -s /etc/uwsgi/apps-available/ /etc/uwsgi/apps-enabled/
    • as $DKR:
      • mkdir log
      • touch log/clean.log
      • contrab -e
      • add line
        • */10 * * * * (/var/www/ >>log/clean.log

Docker cheat sheet

  • docker run -i -t -u runner -e HOME=/home/runner namin/ /bin/bash --login

    (shell access)