Last active
August 29, 2015 14:23
-
-
Save pokstad/f3da4ac958066486470d to your computer and use it in GitHub Desktop.
Sample App for Google's Managed VM service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# make sure to replace "projectid" below with the project ID configured in the Google Developer Console | |
application: projectid | |
runtime: go | |
api_version: go1 | |
# The vm setting is what determines if we are using a sandbox or MVM | |
vm: true | |
module: module1 | |
manual_scaling: | |
# For the sake of this demo, we are going to use manual scaling to keep costs under control. | |
instances: 1 | |
handlers: | |
- url: /.* | |
script: _go_app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dockerfile extending the generic Go image with application files for a | |
# single application. | |
FROM gcr.io/google_appengine/golang | |
COPY . /go/src/app | |
RUN go-wrapper download | |
RUN go-wrapper install -tags appenginevm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2014 Google Inc. All rights reserved. | |
// Use of this source code is governed by the Apache 2.0 | |
// license that can be found in the LICENSE file. | |
package main | |
import ( | |
"html/template" | |
"net/http" | |
"time" | |
"google.golang.org/appengine" | |
"google.golang.org/appengine/log" | |
) | |
var initTime = time.Now() | |
func main() { | |
http.HandleFunc("/", handle) | |
appengine.Main() | |
} | |
func handle(w http.ResponseWriter, r *http.Request) { | |
c := appengine.NewContext(r) | |
log.Infof(c, "Serving the front page.") | |
tmpl.Execute(w, time.Since(initTime)) | |
} | |
var tmpl = template.Must(template.New("front").Parse(` | |
<html><body> | |
<p> | |
Hello, this is Module 1! | |
</p> | |
<p> | |
This instance has been running for <em>{{.}}</em>. | |
</p> | |
</body></html> | |
`)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment