io.livecode.ch is a prototype for turning code repositories into interactive tutorials and books, with code snippets that can be edited and run on the web.
git clone https://github.com/namin/io.livecode.chcd io.livecode.chgit submodule init; git submodule updatecd pub/templates/localgit clone https://github.com/<user>/<repo>.gitcd ../..(back topubdirectory)python local.py(powered by flask and requests)- visit
http://localhost:5000/learn/<user>/<repo> - if you make code changes, refresh the server installation by visiting
http://io.livecode.ch/learn/<user>/<repo>?refresh=1
These steps have been tested on an Ubuntu derivative and Mac OS X.
-
Install dependencies
-
Set up local
io.livecode.chrepository in a directory of your choicegit clone --recursive https://github.com/namin/io.livecode.chexport LIVECODE_DIR=``pwd``/io.livecode.ch
-
Install the
io.livecode.chdocker image- Get the official image
docker pull namin/io.livecode.chexport LIVECODE_CONFIG="dev"
- Or build your own from the source repo
cd $LIVECODE_DIR; docker build -t=namin/io.livecode.ch-dev .export LIVECODE_CONFIG="dev_docker"
- Get the official image
-
export GITHUB_BOT_TOKEN="your_access_token" -
Run local development server
export APP_SETTINGS=$LIVECODE_DIR/cfg/$LIVECODE_CONFIG.cfgcd $LIVECODE_DIR/pubpython __init__.py
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 io.livecode.ch in config files).
For the latest steps, follow this article.
-
Create a new droplet in the DigitalOcean UI:
- for the image, select the default Ubuntu 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).
-
Initial setup of the server
- Instructions to install Docker
$MErefers to your preferred username (e.g.naminfor me)$DKRrefers to a docker-enabled user (e.g.dkr, which I use for scheduling docker cleanups)- as
root:- be sure to set
$MEand$DKRas you like. I do:export ME=naminexport DKR=dkr
apt-get updateapt-get upgrade- Install docker.
adduser $MEusermod -a -G www-data,docker,sudo $MEusermod -a -G docker www-dataadduser $DKRusermod -a -G docker $DKR
- be sure to set
- as
$ME:- set up your favorite editor (and other tools) as you please. I do:
- set up emacs
-
sudo apt-get install emacs -
git clone -b server https://github.com/namin/.emacs.d.git(in
$HOMEdirectory) -
run
emacsto ensure customization works
-
- configure git
git config --global user.name "Nada Amin"git config --global user.email "namin@alum.mit.edu"git config --global core.editor emacs
- set up emacs
- pull official
io.livecode.chdocker imagedocker pull namin/io.livecode.ch
- 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.
dev.livecode.ch), 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-pythonsudo apt-get install redis-serversudo apt-get install python-pip python-devsudo pip install flask redis docker-py
- set up website
cd /varsudo mkdir -p wwwsudo chown www-data:www-data wwwsudo chmod g+w wwwcd wwwgit clone https://github.com/namin/io.livecode.ch.gitcd io.livecode.chgit submodule init; git submodule updatecp app.wsgi.sample app.wsgi- edit the app.wsgi to include the environment variable
GITHUB_BOT_TOKEN cd cfgsudo cp nginx-site.sample /etc/nginx/sites-available/io.livecode.chsudo ln -s /etc/nginx/sites-available/io.livecode.ch /etc/nginx/sites-enabled/io.livecode.chsudo cp uwsgi-app.ini.sample /etc/uwsgi/apps-available/io.livecode.ch.inisudo ln -s /etc/uwsgi/apps-available/io.livecode.ch.ini /etc/uwsgi/apps-enabled/io.livecode.ch.ini
- set up your favorite editor (and other tools) as you please. I do:
- as
$DKR:mkdir logtouch log/clean.logcontrab -e- add line
*/10 * * * * (/var/www/io.livecode.ch/bin/clean) >>log/clean.log
-
docker run -i -t -u runner -e HOME=/home/runner namin/io.livecode.ch /bin/bash --login(shell access)