diff options
| author | Jamal Carvalho <jamal@golang.org> | 2020-12-28 17:25:10 -0500 |
|---|---|---|
| committer | Jamal Carvalho <jamal@golang.org> | 2020-12-29 16:45:16 +0000 |
| commit | ff7eb78b76c19395bb66b38002946f97e892b593 (patch) | |
| tree | 4dd7491813276b11176ba09458cf0bdd8f1d6961 /devtools | |
| parent | 3a672f0fbbb55005302c2a12dae591646b7a776b (diff) | |
| download | go-x-pkgsite-ff7eb78b76c19395bb66b38002946f97e892b593.tar.xz | |
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>
Diffstat (limited to 'devtools')
| -rw-r--r-- | devtools/config/Dockerfile.npm | 10 | ||||
| -rw-r--r-- | devtools/config/docker-compose.yaml | 11 | ||||
| -rwxr-xr-x | devtools/npm.sh | 17 |
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 |
