diff options
Diffstat (limited to 'devtools')
| -rw-r--r-- | devtools/docker/compose.yaml | 11 | ||||
| -rwxr-xr-x | devtools/go.sh | 34 |
2 files changed, 45 insertions, 0 deletions
diff --git a/devtools/docker/compose.yaml b/devtools/docker/compose.yaml index 59f64eac..7b50b556 100644 --- a/devtools/docker/compose.yaml +++ b/devtools/docker/compose.yaml @@ -133,5 +133,16 @@ services: - 3000:3000 environment: - CONNECTION_TIMEOUT=120000 + go: + # This should match the version we are using on AppEngine. + image: golang:1.15.5 + entrypoint: go + environment: + <<: *database-variables + <<: *go-variables + volumes: + - ../../:/pkgsite + - gomodcache:/gomodcache + working_dir: /pkgsite volumes: gomodcache: diff --git a/devtools/go.sh b/devtools/go.sh new file mode 100755 index 00000000..d5285a08 --- /dev/null +++ b/devtools/go.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +# Copyright 2021 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/docker.sh || { echo "Are you at repo root?"; exit 1; } + +set -e + +# Script for running a Go docker image, when go1.15+ is not available locally. +# +# This is can used when Go is not installed on a machine (such as in CI by +# kokoro, which is on go version go1.12 linux/amd64). +#c +# It mounts the pwd into a volume in the container at /pkgsite, +# and sets the working directory in the container to /pkgsite. + +gocmd="dockercompose run go" +if type go > /dev/null; then + # pkgsite requires go1.15 or higher. If that's installed on the machine, just + # use the local go since it will be faster. + # kokoro run go1.12. + # + # This awk program splits the third whitespace-separated field + # (e.g. "go1.15.5") on the dot character and prints the second part. + v=`go version | awk '{split($3, parts, /\./); print parts[2]}'` + if (( v >= 15 )); then + gocmd=go + fi; +fi; + +$gocmd $@ + |
