diff --git a/README.md b/README.md index 207c10e..7f2811c 100644 --- a/README.md +++ b/README.md @@ -23,16 +23,21 @@ A demo at repl.it (https://repl.it/@ChengTan/cgra-flow) shows some features of C Docker -------------------------------------------------------- -The docker image is available [here](https://hub.docker.com/layers/cgra/cgra-flow/demo/images/sha256-7ca327d24f555376d91cba6fa30e3fbaa4a4c0d4053a82ac9059c374a3dee5bd?context=repo). +The docker image is available +[here](https://hub.docker.com/r/cgra/cgra-flow/tags). As CGRA-Flow requires GUI, a script is provided for setting up the display: ```sh docker pull cgra/cgra-flow:demo - # if this is your first time establishing a container for CGRA-Flow: - sh ./run_docker.sh - # else, use the following command to reopen the same container: - sh ./start_docker.sh + # For Mac users like me: + sh ./run_mac_docker.sh + + # Otherwise, if this is your first time establishing a container for CGRA-Flow: + # sh ./run_docker.sh + # Else, use the following command to reopen the same container: + # sh ./start_docker.sh + # Or try to setup GUI (X-11) by yourself. # Don't forget to activate the python virtual environment once you are in the container: source /WORK_REPO/venv/bin/activate diff --git a/run_mac_docker.sh b/run_mac_docker.sh new file mode 100644 index 0000000..476e16a --- /dev/null +++ b/run_mac_docker.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +CONTAINER=cgra/cgra-flow:demo +COMMAND=/bin/bash +NIC=en0 + +# Grab the ip address of this box +IPADDR=$(ifconfig $NIC | grep "inet " | awk '{print $2}') + +DISP_NUM=$(jot -r 1 100 200) # random display number between 100 and 200 + +PORT_NUM=$((6000 + DISP_NUM)) # so multiple instances of the container won't interfer with eachother + +socat TCP-LISTEN:${PORT_NUM},reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\" 2>&1 > /dev/null & + +XSOCK=/tmp/.X11-unix +XAUTH=/tmp/.docker.xauth.$USER.$$ +touch $XAUTH +xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge - + +docker run \ + -it \ + --rm \ + -v $XSOCK:$XSOCK:rw \ + -v $XAUTH:$XAUTH:rw \ + -e DISPLAY=$IPADDR:$DISP_NUM \ + -e XAUTHORITY=$XAUTH \ + $CONTAINER