Skip to content

Commit 8bf23a6

Browse files
KyleJuKyle Jujcscottiii
authored
Upgrade to Go 1.16 in webapp and searchcache (#2846)
* Bump Go to 1.16 * Revert changes in go.mod * revert go.sum * Use docker hub and correct distroless image Following the example from: https://github.com/GoogleContainerTools/distroless/blob/db2d69aa294c7ff414ae12c6ffe578254745a4ca/examples/go/Dockerfile * Add docs for upgrading go * ran mandatory go mod tidy * typo * docs edit Co-authored-by: Kyle Ju <kyleju@chromium.org> Co-authored-by: James Scott <jamescscott@google.com>
1 parent 39e07b6 commit 8bf23a6

File tree

7 files changed

+57
-9
lines changed

7 files changed

+57
-9
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# vim: set expandtab sw=4
2-
FROM golang:1.14-buster
2+
FROM golang:1.16-buster
33

44
# Create a non-priviledged user to run browsers as (Firefox and Chrome do not
55
# like to run as root).

api/query/cache/service/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Production deployment spec for query cache service.
22

3-
# Base golang 1.14 image.
4-
FROM gcr.io/gcp-runtimes/go1-builder:1.14 as builder
3+
# Base golang 1.16 image.
4+
FROM golang:1.16-buster as builder
55

66
RUN apt-get update
77
RUN apt-get install -qy --no-install-suggests git
88
WORKDIR /go/src/wpt.fyi
99

1010
COPY wpt.fyi .
11-
RUN /usr/local/go/bin/go build -o ../../bin/app ./api/query/cache/service
11+
RUN CGO_ENABLED=0 /usr/local/go/bin/go build -o ../../bin/app ./api/query/cache/service
1212

1313
# Application image.
14-
FROM gcr.io/distroless/base:latest
14+
FROM gcr.io/distroless/static-debian11
1515

1616
COPY --from=builder /go/bin/app /usr/local/bin/app
1717

docs/upgrading-go.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Maintenance: Upgrading Golang
2+
3+
This document details the files to change and the necessary steps when upgrading Golang. At the time of the writing, we only upgrade on minor version changes to Golang, not patch changes. If that changes, please update this document.
4+
5+
## Step 1 - Change the Runtime Version in webapp's app.staging.yaml and app.yaml files
6+
7+
Ensure that the desired version is available. Go to the [Golang standard runtime docs](https://cloud.google.com/appengine/docs/standard/go/runtime) to see the latest versions available.
8+
9+
Once you have confirmed that the desired version is available:
10+
- Open [app.yaml](../webapp/web/app.yaml) and [app.staging.yaml](../webapp/web/app.staging.yaml)
11+
- Change the `runtime` line to match the new version of Golang seen in the App Engine documentation.
12+
13+
14+
## Step 2 - Change the version in the Dockerfiles
15+
- tooling [Dockerfile](../Dockerfile) at the root of the repo
16+
- searchcache [Dockerfile](../api/query/cache/service/Dockerfile)
17+
18+
The tooling image and the first stage of searchcache use the same Golang image. Check out the Golang [page](https://hub.docker.com/_/golang?tab=tags) on Docker Hub for the latest tags. Currently, we are using the `buster` [release](https://wiki.debian.org/DebianReleases) of Debian. As a result pick the `golang:<latest stable version>-buster` tag. If buster is superseded by a new version, you should change that as well.
19+
20+
## Step 3 - Change the version in go.mod
21+
22+
There is a line with the Golang version in the [go.mod](../go.mod) file. Change it to the latest major and minor version.
23+
24+
## Step 4 - Run go mod tidy
25+
26+
*Expand section for directions*
27+
<!-- TODO add more instructions for setups like local and docker compose -->
28+
29+
<details>
30+
<summary>Running "go mod tidy" in webplatformtests/wpt.fyi Docker container</summary>
31+
32+
### Terminal 1
33+
34+
You need to run `go mod tidy` **but** `webplatformtests/wpt.fyi:latest` won't have the changes for the latest version of Golang from your changes to the tooling image in step 2. As a result, you will need to build the tooling image locally.
35+
36+
```sh
37+
# From the root of the repository
38+
docker build --tag webplatformtests/wpt.fyi:latest .
39+
```
40+
41+
Follow the steps in the main [README.md](../README.md) to start up the instance. It will use this locally built version of Dockerfile
42+
43+
### Terminal 2
44+
```sh
45+
docker exec wptd-dev-instance go mod tidy
46+
```
47+
This will update your go.mod and go.sum.
48+
49+
</details>

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/web-platform-tests/wpt.fyi
22

3-
go 1.14
3+
go 1.16
44

55
require (
66
cloud.google.com/go/cloudtasks v0.1.0

go.sum

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS
207207
github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM=
208208
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
209209
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
210-
github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA=
211210
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
212211
github.com/gomodule/redigo v1.8.9 h1:Sl3u+2BI/kk+VEatbj0scLdrFhjPmbxOc1myhDP41ws=
213212
github.com/gomodule/redigo v1.8.9/go.mod h1:7ArFNvsTjH8GMMzB4uy1snslv2BwmginuMs06a1uzZE=

webapp/web/app.staging.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

5-
runtime: go114
5+
runtime: go116
66
instance_class: F4_1G
77

88
inbound_services:

webapp/web/app.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

5-
runtime: go114
5+
runtime: go116
66
instance_class: F4_1G
77

88
inbound_services:

0 commit comments

Comments
 (0)