1
0
mirror of https://github.com/golang/go synced 2024-11-05 11:46:12 -07: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 # golang sets GOPATH=/go
ADD . /go/src/tip ADD . /go/src/tip
RUN go install --tags=autocert tip WORKDIR /go/src/tip
RUN go install --tags=autocert
ENTRYPOINT ["/go/bin/tip"] ENTRYPOINT ["/go/bin/tip"]
# We listen on 8080 (for historical reasons). The service.yaml maps public port 80 to 8080. # 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 # Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file. # 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 .PHONY: usage
@ -14,12 +18,23 @@ update-deps:
go install golang.org/x/build/cmd/gitlock go install golang.org/x/build/cmd/gitlock
gitlock --update=Dockerfile --ignore=NONE --tags=autocert golang.org/x/tools/cmd/tip gitlock --update=Dockerfile --ignore=NONE --tags=autocert golang.org/x/tools/cmd/tip
docker-prod: Dockerfile docker-image: Dockerfile *.go
docker build -f Dockerfile --tag=gcr.io/symbolic-datum-552/tip:$(VERSION) . docker build --force-rm -f Dockerfile --tag=$(IMAGE_PROD):$(VERSION) .
docker-dev: Dockerfile docker tag $(IMAGE_PROD):$(VERSION) $(IMAGE_PROD):$(MUTABLE_VERSION)
docker build -f Dockerfile --tag=gcr.io/go-dashboard-dev/tip:$(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" "crypto/tls"
"log" "log"
"net/http" "net/http"
"strings"
"cloud.google.com/go/storage" "cloud.google.com/go/storage"
"golang.org/x/build/autocertcache" "golang.org/x/build/autocertcache"
@ -42,7 +43,7 @@ func certInitAutocert() {
} }
autocertManager = &autocert.Manager{ autocertManager = &autocert.Manager{
Prompt: autocert.AcceptTOS, Prompt: autocert.AcceptTOS,
HostPolicy: autocert.HostWhitelist(*autoCertDomain), HostPolicy: autocert.HostWhitelist(strings.Split(*autoCertDomain, ",")...),
Cache: cache, Cache: cache,
} }
} }

View File

@ -1,11 +1,9 @@
apiVersion: v1 apiVersion: extensions/v1beta1
kind: ReplicationController kind: Deployment
metadata: metadata:
name: tipgodoc name: tipgodoc-deployment
spec: spec:
replicas: 1 replicas: 1
selector:
app: tipgodoc
template: template:
metadata: metadata:
name: tipgodoc name: tipgodoc
@ -16,10 +14,10 @@ spec:
- name: cache-volume - name: cache-volume
emptyDir: {} emptyDir: {}
containers: containers:
- name: gitmirror - name: tipgodoc
image: gcr.io/symbolic-datum-552/tip:v2 image: gcr.io/symbolic-datum-552/tip:latest
imagePullPolicy: Always 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: env:
- name: TMPDIR - name: TMPDIR
value: /build value: /build

View File

@ -34,7 +34,7 @@ const (
var startTime = time.Now() var startTime = time.Now()
var ( 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") 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) p.serveStatus(w, r)
return 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() p.mu.Lock()
proxy := p.proxy proxy := p.proxy
err := p.err err := p.err