aboutsummaryrefslogtreecommitdiff
path: root/devtools
diff options
context:
space:
mode:
Diffstat (limited to 'devtools')
-rw-r--r--devtools/config/Dockerfile.npm10
-rw-r--r--devtools/config/docker-compose.yaml11
-rwxr-xr-xdevtools/npm.sh17
3 files changed, 30 insertions, 8 deletions
diff --git a/devtools/config/Dockerfile.npm b/devtools/config/Dockerfile.npm
index 0beec25e..b7964032 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 6372fe4c..ce7ac5d2 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 @@ services:
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 00000000..9dda16a6
--- /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