Skip to content

Commit

Permalink
[update] docker and README
Browse files Browse the repository at this point in the history
  • Loading branch information
tancheng committed Nov 13, 2023
1 parent 8dc76df commit 1b3deea
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions run_mac_docker.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1b3deea

Please sign in to comment.