mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-09 13:12:20 +00:00
Merge pull request #2320 from davidopp/master
Change update example to use a trivial webserver instead of nginx (issue...
This commit is contained in:
19
contrib/for-demos/test-webserver/Dockerfile
Normal file
19
contrib/for-demos/test-webserver/Dockerfile
Normal file
@@ -0,0 +1,19 @@
|
||||
# Copyright 2014 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FROM scratch
|
||||
MAINTAINER David Oppenheimer <davidopp@google.com>
|
||||
ADD test-webserver test-webserver
|
||||
EXPOSE 80
|
||||
ENTRYPOINT ["/test-webserver"]
|
13
contrib/for-demos/test-webserver/Makefile
Normal file
13
contrib/for-demos/test-webserver/Makefile
Normal file
@@ -0,0 +1,13 @@
|
||||
all: push
|
||||
|
||||
test-webserver: test-webserver.go
|
||||
CGO_ENABLED=0 GOOS=linux go build -a -tags netgo -ldflags '-w' ./test-webserver.go
|
||||
|
||||
container: test-webserver
|
||||
sudo docker build -t kubernetes/test-webserver .
|
||||
|
||||
push: container
|
||||
sudo docker push kubernetes/test-webserver
|
||||
|
||||
clean:
|
||||
rm -f test-webserver
|
48
contrib/for-demos/test-webserver/test-webserver.go
Normal file
48
contrib/for-demos/test-webserver/test-webserver.go
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
Copyright 2014 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// A tiny web server that serves a static file.
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var (
|
||||
port = flag.Int("port", 80, "Port number.")
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
fs := http.StripPrefix("/", http.FileServer(http.Dir("/")))
|
||||
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Cache-Control", "private")
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
w.Header().Set("Access-Control-Allow-Credentials", "true")
|
||||
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
|
||||
w.Header().Set("Access-Control-Allow-Headers", "DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type")
|
||||
fs.ServeHTTP(w, r)
|
||||
})
|
||||
|
||||
go log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil))
|
||||
|
||||
select {}
|
||||
}
|
Reference in New Issue
Block a user