1
0
mirror of https://github.com/golang/go synced 2024-09-30 16:18:35 -06:00

cmd/tip: make tip.golang.org also serve & redirect beta.golang.org to tip

We're turning down the old (and neglected) beta.golang.org godoc VM.
It's not different enough from tip.golang.org, which is more reliable
than it used to be.

Now beta.golang.org will just redirect to tip.

Updates golang/go#25978
Fixes golang/go#21073

Change-Id: Iae7fe4c82c14cec7381e75a2e214210d38b6e623
Reviewed-on: https://go-review.googlesource.com/c/120056
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
This commit is contained in:
Brad Fitzpatrick 2018-06-20 16:33:51 +00:00
parent 654e6e76cd
commit 4cdd33fd98
5 changed files with 47 additions and 20 deletions

View File

@ -135,7 +135,8 @@ RUN go install cloud.google.com/go/compute/metadata \
# golang sets GOPATH=/go
ADD . /go/src/tip
RUN go install --tags=autocert tip
WORKDIR /go/src/tip
RUN go install --tags=autocert
ENTRYPOINT ["/go/bin/tip"]
# We listen on 8080 (for historical reasons). The service.yaml maps public port 80 to 8080.

View File

@ -2,7 +2,11 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
VERSION=v2
VERSION ?= $(shell git rev-parse --short HEAD)
MUTABLE_VERSION ?= latest
IMAGE_STAGING := gcr.io/go-dashboard-dev/tip
IMAGE_PROD := gcr.io/symbolic-datum-552/tip
.PHONY: usage
@ -14,12 +18,23 @@ update-deps:
go install golang.org/x/build/cmd/gitlock
gitlock --update=Dockerfile --ignore=NONE --tags=autocert golang.org/x/tools/cmd/tip
docker-prod: Dockerfile
docker build -f Dockerfile --tag=gcr.io/symbolic-datum-552/tip:$(VERSION) .
docker-dev: Dockerfile
docker build -f Dockerfile --tag=gcr.io/go-dashboard-dev/tip:$(VERSION) .
docker-image: Dockerfile *.go
docker build --force-rm -f Dockerfile --tag=$(IMAGE_PROD):$(VERSION) .
docker tag $(IMAGE_PROD):$(VERSION) $(IMAGE_PROD):$(MUTABLE_VERSION)
docker tag $(IMAGE_PROD):$(VERSION) $(IMAGE_STAGING):$(VERSION)
docker tag $(IMAGE_PROD):$(VERSION) $(IMAGE_STAGING):$(MUTABLE_VERSION)
push-prod: docker-image
docker push $(IMAGE_PROD):$(MUTABLE_VERSION)
docker push $(IMAGE_PROD):$(VERSION)
push-staging: docker-image
docker push $(IMAGE_STAGING):$(MUTABLE_VERSION)
docker push $(IMAGE_STAGING):$(VERSION)
deploy-prod: push-prod
go install golang.org/x/build/cmd/xb
xb --prod kubectl set image deployment/tip-deployment tip=$(IMAGE_PROD):$(VERSION)
deploy-staging: push-staging
go install golang.org/x/build/cmd/xb
xb --staging kubectl set image deployment/tip-deployment tip=$(IMAGE_STAGING):$(VERSION)
push-prod: docker-prod
gcloud docker -- push gcr.io/symbolic-datum-552/tip:$(VERSION)
push-dev: docker-dev
gcloud docker -- push gcr.io/go-dashboard-dev/tip:$(VERSION)

View File

@ -17,6 +17,7 @@ import (
"crypto/tls"
"log"
"net/http"
"strings"
"cloud.google.com/go/storage"
"golang.org/x/build/autocertcache"
@ -42,7 +43,7 @@ func certInitAutocert() {
}
autocertManager = &autocert.Manager{
Prompt: autocert.AcceptTOS,
HostPolicy: autocert.HostWhitelist(*autoCertDomain),
HostPolicy: autocert.HostWhitelist(strings.Split(*autoCertDomain, ",")...),
Cache: cache,
}
}

View File

@ -1,11 +1,9 @@
apiVersion: v1
kind: ReplicationController
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: tipgodoc
name: tipgodoc-deployment
spec:
replicas: 1
selector:
app: tipgodoc
template:
metadata:
name: tipgodoc
@ -16,10 +14,10 @@ spec:
- name: cache-volume
emptyDir: {}
containers:
- name: gitmirror
image: gcr.io/symbolic-datum-552/tip:v2
- name: tipgodoc
image: gcr.io/symbolic-datum-552/tip:latest
imagePullPolicy: Always
command: ["/go/bin/tip", "--autocert=tip.golang.org", "--autocert-bucket=golang-tip-autocert"]
command: ["/go/bin/tip", "--autocert=tip.golang.org,beta.golang.org", "--autocert-bucket=golang-tip-autocert"]
env:
- name: TMPDIR
value: /build

View File

@ -34,7 +34,7 @@ const (
var startTime = time.Now()
var (
autoCertDomain = flag.String("autocert", "", "if non-empty, listen on port 443 and serve a LetsEncrypt cert for this hostname")
autoCertDomain = flag.String("autocert", "", "if non-empty, listen on port 443 and serve a LetsEncrypt cert for this hostname or hostnames (comma-separated)")
autoCertCacheBucket = flag.String("autocert-bucket", "", "if non-empty, the Google Cloud Storage bucket in which to store the LetsEncrypt cache")
)
@ -120,6 +120,18 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
p.serveStatus(w, r)
return
}
// Redirect the old beta.golang.org URL to tip.golang.org,
// just in case there are old links out there to
// beta.golang.org. (We used to run a "temporary" beta.golang.org
// GCE VM running godoc where "temporary" lasted two years.
// So it lasted so long, there are probably links to it out there.)
if r.Host == "beta.golang.org" {
u := *r.URL
u.Scheme = "https"
u.Host = "tip.golang.org"
http.Redirect(w, r, u.String(), http.StatusFound)
return
}
p.mu.Lock()
proxy := p.proxy
err := p.err