Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate hellonode, add hello-app sample #24

Merged
merged 1 commit into from Aug 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions hello-app/Dockerfile
@@ -0,0 +1,8 @@
FROM golang:1.8-alpine
ADD . /go/src/hello-app
RUN go install hello-app

FROM alpine:latest
COPY --from=0 /go/bin/hello-app .
ENV PORT 8080
CMD ["./hello-app"]
14 changes: 14 additions & 0 deletions hello-app/README.md
@@ -0,0 +1,14 @@
# Hello Application example

This example shows how to build and deploy a containerized Go web server
application using [Kubernetes](https://kubernetes.io).

Visit https://cloud.google.com/container-engine/docs/tutorials/hello-app
to follow the tutorial and deploy this application on [Google Container
Engine](https://cloud.google.com/container-engine).

This directory contains:

- `main.go` contains the HTTP server implementation. It responds to all HTTP
requests with a "Hello, world!" response.
- `Dockerfile` is used to build the Docker image for the application.
42 changes: 42 additions & 0 deletions hello-app/main.go
@@ -0,0 +1,42 @@
/**
* Copyright 2017 Google Inc.
*
* 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.
*/
package main

import (
"fmt"
"log"
"net/http"
"os"
)

func main() {
port := "8080"
if fromEnv := os.Getenv("PORT"); fromEnv != "" {
port = fromEnv
}

server := http.NewServeMux()
server.HandleFunc("/", hello)
log.Printf("Server listening on port %s", port)
log.Fatal(http.ListenAndServe(":"+port, server))
}

func hello(w http.ResponseWriter, r *http.Request) {
log.Printf("Serving request: %s", r.URL.Path)
host, _ := os.Hostname()
fmt.Fprintf(w, "Hello, world!\n")
fmt.Fprintf(w, "Hostname: %s\n", host)
}
7 changes: 2 additions & 5 deletions hellonode/README.md
@@ -1,7 +1,4 @@
# Hello Node example

This example shows how to build a containerized Node.js application using
Kubernetes and Docker.

Visit https://cloud.google.com/container-engine/docs/tutorials/hello-node
to follow the tutorial to deploy this application on Google Container Engine.
**This example has been replaced with `hello-app`. See [here](../hello-app) to
follow the tutorial with the new sample application.**