devtools: update frontend development environment config

- Updates docker config to obfuscate git directories.
- Adds a devtools script to run npm commands.
- Node modules are installed on the host machine to enable
autocomplete and intellisense IDEs.

Change-Id: I8d739afdaa5982a433505f510dc731aa147c5ab6
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/280598
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
diff --git a/devtools/config/Dockerfile.npm b/devtools/config/Dockerfile.npm
index 0beec25..b796403 100644
--- a/devtools/config/Dockerfile.npm
+++ b/devtools/config/Dockerfile.npm
@@ -1,9 +1,9 @@
+# Copyright 2020 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
 FROM node:14.15.1
 
 WORKDIR /pkgsite
 
-COPY package.json package-lock.json ./
-
-RUN npm ci
-
-ENTRYPOINT [ "npm", "run" ]
+ENTRYPOINT [ "npm" ]
diff --git a/devtools/config/docker-compose.yaml b/devtools/config/docker-compose.yaml
index 6372fe4..ce7ac5d 100644
--- a/devtools/config/docker-compose.yaml
+++ b/devtools/config/docker-compose.yaml
@@ -1,3 +1,7 @@
+# Copyright 2020 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
 version: '3'
 services:
   npm:
@@ -6,8 +10,9 @@
       dockerfile: devtools/config/Dockerfile.npm
     image: pkgsite_npm
     init: true
-    ports:
-      - '5000:5000'
     volumes:
       - ../..:/pkgsite
-      - /pkgsite/node_modules
+      # Mounts empty volumes in place of git directories so they can't
+      # be written to during npm package installs. 
+      - /pkgsite/.git
+      - /pkgsite/private/.git
diff --git a/devtools/npm.sh b/devtools/npm.sh
new file mode 100755
index 0000000..9dda16a
--- /dev/null
+++ b/devtools/npm.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env -S bash -e
+
+# Copyright 2020 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+source devtools/lib.sh || { echo "Are you at repo root?"; exit 1; }
+
+# Run an npm command and capture the exit code.
+runcmd docker-compose -f devtools/config/docker-compose.yaml run --rm npm $@
+code=$EXIT_CODE
+
+# Perform docker cleanup.
+runcmd docker-compose -f devtools/config/docker-compose.yaml down --remove-orphans
+
+# Exit with the code from the npm command.
+exit $code