Skip to content

Instantly share code, notes, and snippets.

@pokstad
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pokstad/f3da4ac958066486470d to your computer and use it in GitHub Desktop.
Save pokstad/f3da4ac958066486470d to your computer and use it in GitHub Desktop.
Sample App for Google's Managed VM service
# 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
# 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
// 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