diff options
| author | Julie Qiu <julie@golang.org> | 2021-07-17 10:09:28 -0400 |
|---|---|---|
| committer | Julie Qiu <julie@golang.org> | 2021-07-20 16:01:32 +0000 |
| commit | fb6ccbb005bc9a48c7cf27985468da4b41ce3b9b (patch) | |
| tree | 89ea251ccae586e6c133d9fe2d90cedaa39ea7db /devtools | |
| parent | b6fa0ca1ea9909d429c811135ef4dbf901d2d494 (diff) | |
| download | go-x-pkgsite-fb6ccbb005bc9a48c7cf27985468da4b41ce3b9b.tar.xz | |
devtools: add go docker container
A docker container is added for running Go code.
Change-Id: I1349d28a9fc54f770dda01dcaa6c314674b1e5aa
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/335249
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
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 $@ + |
