playground: Remove web profile setup from Dockerfile.
Changed builder to use Node.js from PATH.
Dockerfile installs Node.js from repository instead of setting
up profile, which makes build considerably faster.
Replaced npm link with npm install and cleaned up Makefiles.
Change-Id: Ie01be66f4aeda371f6a102114c912829002ab175
diff --git a/client/Makefile b/client/Makefile
index 967b6af..d86ce20 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -1,7 +1,7 @@
PATH := bin:node_modules/.bin:$(PATH)
PATH := $(PATH):$(VANADIUM_ROOT)/environment/cout/node/bin
SHELL := /bin/bash -euo pipefail
-export GOPATH := $(realpath $(shell pwd)/../go):$(GOPATH)
+export GOPATH := $(VANADIUM_ROOT)/release/projects/playground/go:$(GOPATH)
export VDLPATH := $(GOPATH)
js_files := $(shell find browser -name "*.js")
@@ -13,6 +13,7 @@
.DELETE_ON_ERROR:
+.PHONY: all
all: public/bundles public/bundle.js public/bundle.css
@true # silences `watch make`
@@ -41,7 +42,8 @@
# This task depends on example_profiles and example_files because we want
# to re-bundle if any of those change. However, the bundle tool works on
# directories, so we pass in example_code_bundle_dirs as the path argument.
-public/bundles: $(example_profiles) $(example_files) node_modules
+public/bundles: $(example_profiles) $(example_files) | node_modules
+ $(RM) -rf $@
mkdir -p $(dir $(bundle_temp_file))
@for profile in $(example_profiles); do \
echo "Bundling with profile \"$${profile}\""; \
@@ -50,13 +52,12 @@
mv -f $(bundle_temp_file) "$${folder}/bundle_$$(basename $${profile} .bundle).json"; \
done; \
done
- cp -r bundles/ $@
- touch $@
+ cp -r bundles $(@D)
node_modules: package.json
@npm prune
# Temporary workaround: install pgbundle directly from source.
- @npm install ../pgbundle
+ @npm install $(VANADIUM_ROOT)/release/projects/playground/pgbundle
@npm install
@touch $@
@@ -66,7 +67,6 @@
.PHONY: clean
clean:
- @$(RM) -rf public/bundles
@$(RM) -rf public/bundle.*
@$(RM) -rf node_modules
@$(RM) -rf npm-debug.log
@@ -74,6 +74,7 @@
.PHONY: distclean
distclean: clean
@npm cache clean
+ @$(RM) -rf public/bundles
@$(RM) -rf $(shell find bundles -name "bundle*.json")
.PHONY: lint
diff --git a/client/lib/shell/pg_test_util.sh b/client/lib/shell/pg_test_util.sh
index 73f5ac3..34c4a45 100755
--- a/client/lib/shell/pg_test_util.sh
+++ b/client/lib/shell/pg_test_util.sh
@@ -28,19 +28,12 @@
install_vanadium_js() {
# TODO(nlacasse): Once release/javascript/core is publicly available in npm, replace this
# with "npm install vanadium".
-
- pushd "${VANADIUM_ROOT}/release/javascript/core"
- npm link
- popd
- npm link vanadium
+ npm install --production "${VANADIUM_ROOT}/release/javascript/core"
}
# Installs the pgbundle tool.
install_pgbundle() {
- pushd "${PLAYGROUND_ROOT}/pgbundle"
- npm link
- popd
- npm link pgbundle
+ npm install --production "${PLAYGROUND_ROOT}/pgbundle"
}
# Installs various go binaries.
diff --git a/go/src/playground/.gitignore b/go/src/playground/.gitignore
index 0f6f9f6..2e1a024 100644
--- a/go/src/playground/.gitignore
+++ b/go/src/playground/.gitignore
@@ -1,4 +1,3 @@
deploy/netrc
-deploy/hgrc
config/*.json
!config/db-*-example.json
diff --git a/go/src/playground/Dockerfile b/go/src/playground/Dockerfile
index ddd9ee3..bb5ed19 100644
--- a/go/src/playground/Dockerfile
+++ b/go/src/playground/Dockerfile
@@ -3,7 +3,9 @@
# Install various prereqs.
RUN apt-get update
-RUN apt-get install -y curl g++ git libc6-i386 make mercurial python
+RUN apt-get install -y curl git nodejs npm
+# node -> nodejs needed for Ubuntu.
+RUN ln -s "$(which nodejs)" "$(dirname $(which nodejs))/node"
# Install Go. Note, the apt-get "golang" target is too old.
RUN (cd /tmp; curl -O https://storage.googleapis.com/golang/go1.4.linux-amd64.tar.gz)
@@ -12,34 +14,28 @@
ENV HOME /root
ENV VANADIUM_ROOT /usr/local/vanadium
-ENV GOPATH /home/playground:$VANADIUM_ROOT/release/go:$VANADIUM_ROOT/release/projects/playground/go
+ENV GOPATH $VANADIUM_ROOT/release/projects/playground/go
ENV VDLPATH $GOPATH
+ENV PATH $VANADIUM_ROOT/release/projects/playground/go/bin:$VANADIUM_ROOT/release/go/bin:$VANADIUM_ROOT/bin:$PATH
-# Setup Vanadium and Vanadium profiles.
+# Setup Vanadium.
# Note: This will be cached! If you want to re-build the docker image using
# fresh Vanadium code, you must pass "--no-cache" to the docker build command.
# See README.md.
ADD deploy/netrc /root/.netrc
RUN curl -u vanadium:D6HT]P,LrJ7e https://dev.v.io/noproxy/bootstrap-vanadium.sh | bash
RUN rm /root/.netrc
-ADD deploy/hgrc /root/.hgrc
-RUN $VANADIUM_ROOT/bin/v23 profile setup web
-RUN rm /root/.hgrc
# Install the release/javascript/core library.
# TODO(nlacasse): Switch to "npm install -g vanadium" once release/javascript/core
# is publicly visible in NPM.
# NOTE(sadovsky): NPM is flaky. If any of the NPM commands below fail, simply
# retry them.
-WORKDIR /usr/local/vanadium/release/javascript/core
-RUN $VANADIUM_ROOT/environment/cout/node/bin/npm install --production
-RUN $VANADIUM_ROOT/environment/cout/node/bin/npm link
WORKDIR /home/playground
-RUN $VANADIUM_ROOT/environment/cout/node/bin/npm link vanadium
+RUN npm install --production $VANADIUM_ROOT/release/javascript/core
# Install Vanadium Go dependencies.
-WORKDIR /usr/local/vanadium/release
-ENV PATH $VANADIUM_ROOT/release/go/bin:$VANADIUM_ROOT/release/projects/playground/go/bin:$VANADIUM_ROOT/bin:$PATH
+WORKDIR $VANADIUM_ROOT/release
RUN v23 go install v.io/x/ref/...
RUN v23 go install playground/...
@@ -63,4 +59,5 @@
USER playground
WORKDIR /home/playground
-ENTRYPOINT /usr/local/vanadium/release/projects/playground/go/bin/builder
+# exec form - passes through command-line arguments and signals.
+ENTRYPOINT ["builder"]
diff --git a/go/src/playground/Makefile b/go/src/playground/Makefile
index 76f0aa7..b4f2814 100644
--- a/go/src/playground/Makefile
+++ b/go/src/playground/Makefile
@@ -1,6 +1,6 @@
PATH := bin:node_modules/.bin:$(PATH)
PATH := $(PATH):$(VANADIUM_ROOT)/environment/cout/node/bin
-PATH := $(PATH):$(VANADIUM_ROOT)/release/projects/playground/go/bin
+PATH := $(VANADIUM_ROOT)/release/projects/playground/go/bin:$(PATH)
SHELL := /bin/bash -euo pipefail
export GOPATH := $(VANADIUM_ROOT)/release/projects/playground/go:$(GOPATH)
export VDLPATH := $(GOPATH)
@@ -14,8 +14,8 @@
all:
v23 go install playground/...
-.PHONY: all
-start: config/db.json
+.PHONY: start
+start: config/db.json all
compilerd \
--sqlconf=$< \
--setupdb=true \
diff --git a/go/src/playground/README.md b/go/src/playground/README.md
index 75348cc..a49e371 100644
--- a/go/src/playground/README.md
+++ b/go/src/playground/README.md
@@ -24,7 +24,6 @@
Build the playground Docker image (this will take a while...):
$ cp ~/.netrc $VANADIUM_ROOT/release/projects/playground/go/src/playground/deploy/netrc
- $ cp ~/.hgrc $VANADIUM_ROOT/release/projects/playground/go/src/playground/deploy/hgrc
$ docker build -t playground $VANADIUM_ROOT/release/projects/playground/go/src/playground/.
Note: If you want to ensure an up-to-date version of Vanadium is installed in
@@ -44,7 +43,7 @@
Test your image (without running compilerd):
$ cd $VANADIUM_ROOT/release/projects/playground/client && make src/example_bundles
- $ docker run -i playground < $VANADIUM_ROOT/release/projects/playground/client/bundles/fortune/ex0_go/bundle.json
+ $ docker run -i playground < $VANADIUM_ROOT/release/projects/playground/client/bundles/fortune/bundle_js_go.json
## Running the playground server (compilerd)
diff --git a/go/src/playground/builder/main.go b/go/src/playground/builder/main.go
index 1520f3a..1590cbd 100644
--- a/go/src/playground/builder/main.go
+++ b/go/src/playground/builder/main.go
@@ -326,8 +326,7 @@
}
f.subprocs = append(f.subprocs, wsprProc)
os.Setenv("WSPR", "http://localhost:"+strconv.Itoa(wsprPort))
- node := filepath.Join(os.Getenv("VANADIUM_ROOT"), "environment", "cout", "node", "bin", "node")
- f.cmd = makeCmd(f.Name, false, "", node, f.Name)
+ f.cmd = makeCmd(f.Name, false, "", "node", f.Name)
return f.cmd.Start()
}
diff --git a/go/src/playground/playground_v23_test.go b/go/src/playground/playground_v23_test.go
index 7b4057a..de0cfdc 100644
--- a/go/src/playground/playground_v23_test.go
+++ b/go/src/playground/playground_v23_test.go
@@ -14,7 +14,7 @@
//go:generate v23 test generate
var (
- vanadiumRoot, playgroundRoot string
+ vanadiumRoot, nodejsRoot, playgroundRoot string
)
func init() {
@@ -22,6 +22,7 @@
if len(vanadiumRoot) == 0 {
panic("VANADIUM_ROOT must be set")
}
+ nodejsRoot = filepath.Join(vanadiumRoot, "environment/cout/node/bin")
}
func golist(i *v23tests.T, pkg string) string {
@@ -29,12 +30,9 @@
return i.Run(v23, "go", "list", "-f", "{{.Dir}}", pkg)
}
-func npmLink(i *v23tests.T, dir, pkg string) {
- npmBin := i.BinaryFromPath(filepath.Join(vanadiumRoot, "environment/cout/node/bin/npm"))
- i.Pushd(dir)
- npmBin.Run("link")
- i.Popd()
- npmBin.Run("link", pkg)
+func npmInstall(i *v23tests.T, dir string) {
+ npmBin := i.BinaryFromPath(filepath.Join(nodejsRoot, "npm"))
+ npmBin.Run("install", "--production", dir)
}
// Bundles a playground example and tests it using builder.
@@ -56,7 +54,7 @@
// the binary is cached.
builderBin := i.BuildGoPkg("playground/builder")
- PATH := "PATH=" + i.BinDir()
+ PATH := "PATH=" + i.BinDir() + ":" + nodejsRoot
if path := os.Getenv("PATH"); len(path) > 0 {
PATH += ":" + path
}
@@ -75,6 +73,9 @@
}
func V23TestPlayground(i *v23tests.T) {
+ i.Pushd(i.NewTempDir())
+ defer i.Popd()
+
v23tests.RunRootMT(i, "--veyron.tcp.address=127.0.0.1:0")
i.BuildGoPkg("v.io/x/ref/cmd/principal")
@@ -89,8 +90,8 @@
playgroundRoot = filepath.Dir(playgroundRoot)
playgroundRoot = filepath.Dir(playgroundRoot)
- npmLink(i, filepath.Join(vanadiumRoot, "release/javascript/core"), "vanadium")
- npmLink(i, filepath.Join(playgroundRoot, "pgbundle"), "pgbundle")
+ npmInstall(i, filepath.Join(vanadiumRoot, "release/javascript/core"))
+ npmInstall(i, filepath.Join(playgroundRoot, "pgbundle"))
cases := []struct {
name string
diff --git a/pgbundle/Makefile b/pgbundle/Makefile
index f52e1d6..e0b5132 100644
--- a/pgbundle/Makefile
+++ b/pgbundle/Makefile
@@ -3,12 +3,13 @@
node_modules: package.json
@npm prune
- npm install
+ @npm install
@touch $@
.PHONY: clean
clean:
@$(RM) -rf node_modules
+ @$(RM) -rf npm-debug.log
.PHONY: lint
lint: