If you haven't already, make sure you are familiar with Custom Runtimes in the App Engine Managed VM documentation.
You must have the Google Cloud SDK, with the
Managed VM component installed. We will assume that the SDK is available on
your command line as $ gcloud
.
You must also install Docker on your workstation, as the SDK uses it to build, test and deploy your application.
This is a minimal Managed VM runtime that runs the nginx server. It
implements the two required handlers (/_ah/start
and /_ah/health
) as
static pages and illustrates the files necessary to run a custom runtime.
app.yaml
- Configuration file for App Engine.Dockerfile
- Defines your docker image.www/index.html
- Root page to be served by nginx.nginx.conf
- nginx configuration file.ok
- File content served by start and health handlers.
First, make sure Docker has been started on your workstation. Refer to the Managed VM documentation for more information on how to do this for your environment.
Then, to run locally:
$ gcloud preview app run /path/to/appengine-nginx-hello
This will build the nginx docker image and run it locally. You can access it at http://localhost:8080.
To deploy to App Engine:
$ gcloud preview app deploy /path/to/appengine-nginx-hello
This will build the nginx docker image and deploy it to App Engine.
You can use this demo to serve static files from a managed vm. Just add files
to the www directory and they'll be added to the /usr/share/nginx/www
directory and served from your app.
This is intended to provide a minimal example of a Managed VM runtime. Obviously, serving static files isn't something you would need a VM for. If you actually do want to use nginx as a front-end for an application, you should take a look at the nginx docs for information on how to use FastCGI.
Copyright 2014 Google Inc.