playground: fix Dockerfile and improve documentation
Change-Id: I9724434863fed5a3325facacff55708b1290d2f7
diff --git a/tools/playground/README.md b/tools/playground/README.md
index aa0c6af..409cf75 100644
--- a/tools/playground/README.md
+++ b/tools/playground/README.md
@@ -1,29 +1,36 @@
# Running the playground compile server locally
-Install Docker on Goobuntu:
+Install Docker:
- * http://go/installdocker
+* Goobuntu: http://go/installdocker
+* OS X: https://github.com/boot2docker/osx-installer/releases
-Install Docker on OS X:
+On Goobuntu, we recommend overriding the default graph dir (`/var/lib/docker`)
+to avoid filling up the root filesystem partition, which is quite small. To do
+so, add the following line to your `/etc/default/docker`:
- * https://github.com/boot2docker/osx-installer/releases
+ DOCKER_OPTS="${DOCKER_OPTS} -g /usr/local/google/docker"
+
+Start (or restart) the Docker daemon:
+
+ $ sudo service docker restart
Build the playground Docker image (this will take a while...):
- $ cp ~/.netrc $VEYRON_ROOT/veyron/go/src/veyron/tools/playground/builder/netrc
-
- $ sudo docker build -t playground $VEYRON_ROOT/veyron/go/src/veyron/tools/playground/builder/.
+ $ cp ~/.netrc $VEYRON_ROOT/veyron/go/src/veyron.io/veyron/veyron/tools/playground/builder/netrc
+ $ sudo docker build -t playground $VEYRON_ROOT/veyron/go/src/veyron.io/veyron/veyron/tools/playground/builder/.
Note: If you want to ensure an up-to-date version of veyron is installed in the
Docker image, run the above command with the "--no-cache" flag.
Install the playground binaries:
- $ go install veyron/tools/playground/...
+ $ veyron go install veyron.io/veyron/veyron/tools/playground/...
Run the compiler binary as root:
- $ sudo go/bin/compilerd --shutdown=false --address=localhost:8181
+ $ sudo $VEYRON_ROOT/veyron/go/bin/compilerd --shutdown=false --address=localhost:8181
The server should now be running at http://localhost:8181 and responding to
-compile requests at http://localhost:8181/compile.
+compile requests at http://localhost:8181/compile. Add `?pgaddr=localhost:8181`
+to any veyron-www page to make its embedded playgrounds talk to your server.
diff --git a/tools/playground/builder/Dockerfile b/tools/playground/builder/Dockerfile
index e06d726..7fa5017 100644
--- a/tools/playground/builder/Dockerfile
+++ b/tools/playground/builder/Dockerfile
@@ -1,10 +1,19 @@
FROM ubuntu
RUN /usr/sbin/useradd -d /home/playground -m playground
+
+# Install various prereqs.
RUN apt-get update
-RUN apt-get install -y curl g++ git golang libc6-i386 make python
+RUN apt-get install -y curl g++ git libc6-i386 make python
+
+# Install Go. Note, the apt-get "golang" target is too old.
+RUN (cd /tmp; curl -O https://storage.googleapis.com/golang/go1.3.3.linux-amd64.tar.gz)
+RUN tar -C /usr/local -xzf /tmp/go1.3.3.linux-amd64.tar.gz
+ENV PATH /usr/local/go/bin:$PATH
+
ENV HOME /root
ENV VEYRON_ROOT /usr/local/veyron
ENV GOPATH /home/playground:$VEYRON_ROOT/veyron/go
+ENV VDLPATH /home/playground:$VEYRON_ROOT/veyron/go
# Setup veyron and veyron profiles.
# Note: This will be cached! If you want to re-build the docker image using
@@ -13,13 +22,14 @@
ADD netrc /root/.netrc
RUN curl -u veyron:D6HT]P,LrJ7e https://www.envyor.com/noproxy/veyron-setup.sh | bash
RUN rm /root/.netrc
-RUN /usr/local/veyron/bin/veyron profile setup core
-RUN /usr/local/veyron/bin/veyron profile setup web
+RUN $VEYRON_ROOT/bin/veyron profile setup web
# Install the veyron.js library.
-# TODO(nlacasse): Change to "npm install -g veyron" once it's publicly published
-# in NPM.
+# TODO(nlacasse): Switch to "npm install -g veyron" once veyron.js is publicly
+# visible in NPM.
WORKDIR /usr/local/veyron/veyron.js/
+# NOTE(sadovsky): NPM is flaky. If any of the NPM commands below fail, simply
+# retry them.
RUN $VEYRON_ROOT/environment/cout/node/bin/npm install --production
RUN $VEYRON_ROOT/environment/cout/node/bin/npm link
WORKDIR /home/playground
@@ -27,12 +37,12 @@
# Install Veyron Go dependencies.
WORKDIR /usr/local/veyron/veyron
-ENV PATH /usr/local/veyron/veyron/go/bin:/usr/local/bin:/usr/bin:/bin
+ENV PATH $VEYRON_ROOT/veyron/go/bin:$VEYRON_ROOT/bin:$PATH
RUN veyron go install veyron.io/veyron/...
# Uncomment the following lines to install a version of the builder tool using
-# the local copy of vbuild.go. This is useful when developing and testing
-# local changes to the builder tool.
+# the local copy of vbuild.go. This is useful when developing and testing local
+# changes to the builder tool.
# RUN rm $VEYRON_ROOT/veyron/go/bin/builder
# ADD vbuild.go /usr/local/veyron/veyron/go/src/veyron/tools/playground/builder/vbuild.go
# ADD identity.go /usr/local/veyron/veyron/go/src/veyron/tools/playground/builder/identity.go
diff --git a/tools/playground/builder/vbuild.go b/tools/playground/builder/vbuild.go
index 9eac10e..da168f2 100644
--- a/tools/playground/builder/vbuild.go
+++ b/tools/playground/builder/vbuild.go
@@ -282,6 +282,10 @@
return ioutil.WriteFile(filepath.Join("src", f.pkg, f.Name), []byte(f.Body), 0666)
}
+// TODO(sadovsky): "veyron go install" runs "vdl generate" before running the Go
+// compiler, so it shouldn't be necessary to run "vdl" separately. Also, why do
+// we compile files individually, rather than compiling everything in one go
+// (pun intended), something like "veyron go install ..."?
func (f *codeFile) compile() error {
debug("Compiling file ", f.Name)
var cmd *exec.Cmd
@@ -289,7 +293,7 @@
case "js":
return nil
case "vdl":
- cmd = makeCmdJsonEvent(f.Name, "vdl", "generate", "--lang=go", f.pkg)
+ cmd = makeCmdJsonEvent(f.Name, "veyron", "run", "vdl", "generate", "--lang=go", f.pkg)
case "go":
cmd = makeCmdJsonEvent(f.Name, "veyron", "go", "install", f.pkg)
default:
diff --git a/tools/playground/test.sh b/tools/playground/test.sh
index f17f8e0..e2d4462 100755
--- a/tools/playground/test.sh
+++ b/tools/playground/test.sh
@@ -27,20 +27,20 @@
}
test_with_files() {
- echo '{"Files":[' > request.json
- while [[ $# > 0 ]]; do
- echo '{"Name":"'"$(basename $1)"'","Body":' >>request.json
- grep -v OMIT $1 | ./escaper >>request.json
- shift
- if [[ $# > 0 ]]; then
- echo '},' >>request.json
- else
- echo '}' >>request.json
- fi
- done
- echo ']}' >>request.json
- rm -f builder.out
- ./builder <request.json 2>&1 | tee builder.out
+ echo '{"Files":[' > request.json
+ while [[ $# > 0 ]]; do
+ echo '{"Name":"'"$(basename $1)"'","Body":' >>request.json
+ grep -v OMIT $1 | ./escaper >>request.json
+ shift
+ if [[ $# > 0 ]]; then
+ echo '},' >>request.json
+ else
+ echo '}' >>request.json
+ fi
+ done
+ echo ']}' >>request.json
+ rm -f builder.out
+ ./builder <request.json 2>&1 | tee builder.out
}
main() {