-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a sample for extending the compat runtime.
- Loading branch information
Jon Wayne Parrott
committed
Feb 26, 2016
1 parent
b094eae
commit 209173a
Showing
9 changed files
with
105 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.dockerignore | ||
Dockerfile | ||
.git | ||
.hg | ||
.svn |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# [START dockerfile] | ||
FROM gcr.io/google_appengine/python-compat-multicore | ||
|
||
# Install the fortunes binary from the debian repositories. | ||
RUN apt-get update && apt-get install -y fortunes | ||
|
||
ADD . /app/ | ||
|
||
RUN if [ -s requirements.txt ]; then pip install -r requirements.txt; fi | ||
# [END dockerfile] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
## Google App Engine Managed VMs extending runtime python-compat | ||
|
||
This sample demonstrates how to extend the [python-compat](https://cloud.google.com/appengine/docs/managed-vms/python/migrating-an-existing-app) runtime on [Google App Engine Managed VMs](https://cloud.google.com/appengine/docs/python/managed-vms/hello-world) | ||
|
||
### Running & deploying the sample | ||
|
||
1. `requirements.txt` is automatically installed by the runtime when deploying, however, to run the sample locally you will need to install dependencies: | ||
|
||
$ pip install -r requirements.txt | ||
|
||
2. Run the sample on your development server: | ||
|
||
$ dev_appserver.py --runtime python-compat . | ||
|
||
3. Deploy the sample: | ||
|
||
$ gcloud preview app deploy |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
runtime: custom | ||
vm: true | ||
threadsafe: true | ||
api_version: 1 | ||
|
||
handlers: | ||
- url: .* # This regex directs all routes to main.app | ||
script: main.app |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright 2015 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. | ||
|
||
# [START app] | ||
import subprocess | ||
|
||
from flask import Flask | ||
|
||
|
||
app = Flask(__name__) | ||
|
||
|
||
# [START example] | ||
@app.route('/') | ||
def fortune(): | ||
output = subprocess.check_output('/usr/games/fortune') | ||
return output, 200, {'Content-Type': 'text/plain; charset=utf-8'} | ||
# [END example] | ||
# [END app] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright 2015 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. | ||
|
||
import os | ||
|
||
import main | ||
import pytest | ||
|
||
|
||
@pytest.mark.skipif( | ||
not os.path.exists('/usr/games/fortune'), | ||
reason='Fortune executable is not installed.') | ||
def test_index(): | ||
main.app.testing = True | ||
client = main.app.test_client() | ||
|
||
r = client.get('/') | ||
assert r.status_code == 200 | ||
assert len(r.data) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Flask==0.10.1 |
This file contains 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
This file contains 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