From 3c5a86f3ccbfce875ef460444bb4ab3c22b7783e Mon Sep 17 00:00:00 2001 From: Alexander Apalikov Date: Wed, 8 Apr 2020 16:34:39 +0300 Subject: [PATCH 1/2] Use go modules for a website and update go version `make site-deploy` target is working properly. --- build/includes/website.mk | 4 ++-- cloudbuild.yaml | 3 ++- site/app.yaml | 2 +- site/cloudbuild.yaml | 3 ++- site/go.mod | 5 +++++ site/go.sum | 4 ++++ 6 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 site/go.mod create mode 100644 site/go.sum diff --git a/build/includes/website.mk b/build/includes/website.mk index 9037dc8db0..cdb075c46c 100644 --- a/build/includes/website.mk +++ b/build/includes/website.mk @@ -49,8 +49,8 @@ site-gen-app-yaml: site-deploy: site-gen-app-yaml site-static docker run -t --rm $(common_mounts) --workdir=$(mount_path) $(DOCKER_RUN_ARGS) \ - -e GOPATH=/tmp/go -e GO111MODULE=off -e SHORT_SHA=$(shell git rev-parse --short=7 HEAD) $(build_tag) bash -c \ - 'printenv && mkdir -p $$GOPATH/src && cp -r ./site $$GOPATH/src && cp -r ./vendor/gopkg.in $$GOPATH/src && \ + -e GOPATH=/tmp/go -e GO111MODULE=on -e SHORT_SHA=$(shell git rev-parse --short=7 HEAD) $(build_tag) bash -c \ + 'printenv && mkdir -p $$GOPATH/src && cp -r ./site $$GOPATH/src && \ cd $$GOPATH/src/site && gcloud app deploy .app.yaml --no-promote --quiet --version=$$SHORT_SHA' site-static-preview: diff --git a/cloudbuild.yaml b/cloudbuild.yaml index f8f021aa6b..78d3d2e7f7 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -220,7 +220,7 @@ steps: id: site-gopath waitFor: - site-static - args: ["bash", "-c", "mkdir -p ./go/src && mv ./site ./go/src && cp -r ./vendor/gopkg.in ./go/src && ls -a ./go/src/site"] + args: ["bash", "-c", "mkdir -p ./go/src && mv ./site ./go/src && ls -a ./go/src/site"] - name: "gcr.io/cloud-builders/gcloud" # deploy the preview of the website id: "deploy-site-static" waitFor: @@ -229,6 +229,7 @@ steps: args: ["app", "deploy", ".app.yaml", "--no-promote", "--version=$SHORT_SHA"] env: - GOPATH=/workspace/go + - GO111MODULE=on # # Run the e2e tests diff --git a/site/app.yaml b/site/app.yaml index 32613c2418..a2933aa06f 100644 --- a/site/app.yaml +++ b/site/app.yaml @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -runtime: go111 +runtime: go113 service: ${SERVICE} handlers: diff --git a/site/cloudbuild.yaml b/site/cloudbuild.yaml index 26cce66fc3..6aaa47dcb7 100644 --- a/site/cloudbuild.yaml +++ b/site/cloudbuild.yaml @@ -50,11 +50,12 @@ steps: # Build development site and deploy # + - name: "make-docker" # build a preview of the website dir: "build" args: ["site-static-preview", "site-gen-app-yaml", "SERVICE=development"] - name: "ubuntu" # fake a new gopath - args: ["bash", "-c", "rm -r ./go/src && mkdir -p ./go/src && cp -r ./site ./go/src && cp -r ./vendor/gopkg.in ./go/src && ls -a ./go/src/site"] + args: ["bash", "-c", "rm -r ./go/src && mkdir -p ./go/src && cp -r ./site ./go/src && ls -a ./go/src/site"] - name: "gcr.io/cloud-builders/gcloud" # deploy the preview of the website dir: "go/src/site" args: ["app", "deploy", ".app.yaml", "--promote", "--version=$SHORT_SHA"] diff --git a/site/go.mod b/site/go.mod new file mode 100644 index 0000000000..8dffe285e4 --- /dev/null +++ b/site/go.mod @@ -0,0 +1,5 @@ +module github.com/agones/agones/site + +go 1.13 + +require gopkg.in/yaml.v2 v2.2.8 diff --git a/site/go.sum b/site/go.sum new file mode 100644 index 0000000000..74b18acbef --- /dev/null +++ b/site/go.sum @@ -0,0 +1,4 @@ +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 99767857279c681a183e7e73b86be50bd77bfcbc Mon Sep 17 00:00:00 2001 From: Alexander Apalikov Date: Wed, 8 Apr 2020 18:17:18 +0300 Subject: [PATCH 2/2] Remove faking the GOPATH step in cloudbuild yaml --- build/includes/website.mk | 6 +++--- cloudbuild.yaml | 9 ++------- site/cloudbuild.yaml | 10 ++++------ 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/build/includes/website.mk b/build/includes/website.mk index cdb075c46c..257d3a3ec1 100644 --- a/build/includes/website.mk +++ b/build/includes/website.mk @@ -49,9 +49,9 @@ site-gen-app-yaml: site-deploy: site-gen-app-yaml site-static docker run -t --rm $(common_mounts) --workdir=$(mount_path) $(DOCKER_RUN_ARGS) \ - -e GOPATH=/tmp/go -e GO111MODULE=on -e SHORT_SHA=$(shell git rev-parse --short=7 HEAD) $(build_tag) bash -c \ - 'printenv && mkdir -p $$GOPATH/src && cp -r ./site $$GOPATH/src && \ - cd $$GOPATH/src/site && gcloud app deploy .app.yaml --no-promote --quiet --version=$$SHORT_SHA' + -e GO111MODULE=on -e SHORT_SHA=$(shell git rev-parse --short=7 HEAD) $(build_tag) bash -c \ + 'printenv && cd ./site && \ + gcloud app deploy .app.yaml --no-promote --quiet --version=$$SHORT_SHA' site-static-preview: $(MAKE) site-static ARGS="-F" ENV="RELEASE_VERSION=$(base_version) RELEASE_BRANCH=master" diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 78d3d2e7f7..48e11fc4c1 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -216,16 +216,11 @@ steps: - tests dir: "build" args: ["site-static-preview", "site-gen-app-yaml", "SERVICE=preview"] -- name: "ubuntu" # fake a new gopath - id: site-gopath - waitFor: - - site-static - args: ["bash", "-c", "mkdir -p ./go/src && mv ./site ./go/src && ls -a ./go/src/site"] - name: "gcr.io/cloud-builders/gcloud" # deploy the preview of the website id: "deploy-site-static" waitFor: - - site-gopath - dir: "go/src/site" + - site-static + dir: "site" args: ["app", "deploy", ".app.yaml", "--no-promote", "--version=$SHORT_SHA"] env: - GOPATH=/workspace/go diff --git a/site/cloudbuild.yaml b/site/cloudbuild.yaml index 6aaa47dcb7..89ca2d0c7f 100644 --- a/site/cloudbuild.yaml +++ b/site/cloudbuild.yaml @@ -38,13 +38,12 @@ steps: - name: "make-docker" # build production version of the site dir: "build" args: ["site-static", "site-gen-app-yaml", "ENV=HUGO_ENV=production"] -- name: "ubuntu" # fake a new gopath - args: ["bash", "-c", "mkdir -p ./go/src && cp -r ./site ./go/src && cp -r ./vendor/gopkg.in ./go/src && ls -a ./go/src/site"] - name: "gcr.io/cloud-builders/gcloud" # deploy the website - dir: "go/src/site" + dir: "site" args: ["app", "deploy", ".app.yaml", "--promote", "--version=$SHORT_SHA"] env: - GOPATH=/workspace/go + - GO111MODULE=on # # Build development site and deploy @@ -54,12 +53,11 @@ steps: - name: "make-docker" # build a preview of the website dir: "build" args: ["site-static-preview", "site-gen-app-yaml", "SERVICE=development"] -- name: "ubuntu" # fake a new gopath - args: ["bash", "-c", "rm -r ./go/src && mkdir -p ./go/src && cp -r ./site ./go/src && ls -a ./go/src/site"] - name: "gcr.io/cloud-builders/gcloud" # deploy the preview of the website - dir: "go/src/site" + dir: "site" args: ["app", "deploy", ".app.yaml", "--promote", "--version=$SHORT_SHA"] env: - GOPATH=/workspace/go + - GO111MODULE=on tags: ["site"] \ No newline at end of file