playground/go: Add `start` target to Makefile
This allows a quick way to run a local dev server without Docker.
Change-Id: I568c3715bd8e9a2275a564aba8e861d225b73ad4
diff --git a/go/src/playground/.gitignore b/go/src/playground/.gitignore
index 682e93a..0f6f9f6 100644
--- a/go/src/playground/.gitignore
+++ b/go/src/playground/.gitignore
@@ -1,2 +1,4 @@
deploy/netrc
deploy/hgrc
+config/*.json
+!config/db-*-example.json
diff --git a/go/src/playground/Makefile b/go/src/playground/Makefile
index 377092b..76f0aa7 100644
--- a/go/src/playground/Makefile
+++ b/go/src/playground/Makefile
@@ -1,15 +1,33 @@
PATH := bin:node_modules/.bin:$(PATH)
PATH := $(PATH):$(VANADIUM_ROOT)/environment/cout/node/bin
+PATH := $(PATH):$(VANADIUM_ROOT)/release/projects/playground/go/bin
SHELL := /bin/bash -euo pipefail
-export GOPATH := $(realpath $(shell pwd)/../..):$(GOPATH)
+export GOPATH := $(VANADIUM_ROOT)/release/projects/playground/go:$(GOPATH)
export VDLPATH := $(GOPATH)
+host ?= 127.0.0.1
+port ?= 8181
+
.DELETE_ON_ERROR:
.PHONY: all
all:
v23 go install playground/...
+.PHONY: all
+start: config/db.json
+ compilerd \
+ --sqlconf=$< \
+ --setupdb=true \
+ --listenTimeout=0 \
+ --address=$(host):$(port) \
+ --use-docker=false
+
+config/db.json:
+ @echo "You are missing config/db.json, create this file based"
+ @echo "on the appropriate examples in the config directory."
+ @exit 1;
+
.PHONY: test
test:
v23 run ./test.sh
diff --git a/go/src/playground/config/db-cloud-example.json b/go/src/playground/config/db-cloud-example.json
new file mode 100644
index 0000000..62f2cfc
--- /dev/null
+++ b/go/src/playground/config/db-cloud-example.json
@@ -0,0 +1,7 @@
+{
+ "dataSourceName": "<username>:<password>@tcp(<ip_address>:3306)/<database>",
+ "tlsServerName": "<gce-project>:<instance>",
+ "rootCertPath": "path/server-ca.pem",
+ "clientCertPath": "path/client-cert.pem",
+ "clientKeyPath": "path/client-key.pem"
+}
diff --git a/go/src/playground/config/db-local-example.json b/go/src/playground/config/db-local-example.json
new file mode 100644
index 0000000..b59e8db
--- /dev/null
+++ b/go/src/playground/config/db-local-example.json
@@ -0,0 +1,4 @@
+{
+ "dataSourceName": "<username>:<password>@tcp(localhost:3306)/<database>",
+ "tlsDisable": true
+}