8000 Merge pull request #161 from GoogleCloudPlatform/kinto · wlhee/python-docs-samples@03de397 · GitHub
[go: up one dir, main page]

Skip to content

Commit 03de397

Browse files
committed
Merge pull request GoogleCloudPlatform#161 from GoogleCloudPlatform/kinto
Basic Kinto Example
2 parents 493f850 + 9b97c28 commit 03de397

File tree

4 files changed

+95
-0
lines changed

4 files changed

+95
-0
lines changed

managed_vms/kinto/Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2015 Google Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License
14+
15+
# The Google App Engine python runtime is Debian Jessie with Python installed
16+
# and various os-level packages to allow installation of popular Python
17+
# libraries. The source is on github at:
18+
# https://github.com/GoogleCloudPlatform/python-docker
19+
FROM gcr.io/google_appengine/python
20+
21+
# Create a virtualenv for the application dependencies.
22+
# If you want to use Python 3, add the -p python3.4 flag.
23+
RUN virtualenv /env
24+
25+
# Set virtualenv environment variables. This is equivalent to running
26+
# source /env/bin/activate. This ensures the application is executed within
27+
# the context of the virtualenv and will have access to its dependencies.
28+
ENV VIRTUAL_ENV /env
29+
ENV PATH /env/bin:$PATH
30+
31+
# Kinto config file
32+
ENV KINTO_INI /etc/kinto/kinto.ini
33+
34+
# Install dependencies.
35+
ADD requirements.txt /app/requirements.txt
36+
RUN pip install -r /app/requirements.txt
37+
#Create Kinto config file and replace 8888 with 8080
38+
RUN kinto --ini $KINTO_INI --backend=memory init && sed -i 's/8888/8080/g' $KINTO_INI
39+
40+
# Run the Kinto kickoff command
41+
CMD kinto --ini $KINTO_INI migrate && kinto --ini $KINTO_INI start
42+

managed_vms/kinto/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Kinto Example
2+
3+
This is a basic example of running Mozillas [Kinto](https://github.com/Kinto/kinto/blob/master/docs/index.rst)
4+
on Managed VMs. Kinto provides a framework to sync JSON data across many devices and provide push notifications.
5+
Thius example uses a custom runtime to install Kinto and edit the config to run it on port 8080, which is the port that
6+
the base Docker image is expecting.
7+
8+
Since Kinto is being imported as a Python library and run as-is, no additional code is necessary.
9+
10+
Note that this is using Kinto's basic in-memory backend. As such, the instances are tied to 1. A production
11+
version of Kinto would use a PostgreSQL database and Redis cluster, which would allow scaling to many instances.
12+
13+
If you are interested in seeing this example expanded to use PostgreSQL, you can file an Issue on the Issue
14+
Tracker, or submit a Pull Request if you've accomplished it yourself.
15+
16+
17+
18+

managed_vms/kinto/app.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright 2015 Google Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# This file specifies your Python application's runtime configuration.
16+
# See https://cloud.google.com/appengine/docs/managed-vms/config for details.
17+
18+
runtime: custom
19+
vm: true
20+
21+
# Kinto does not respond 404 to /_ah/health (sends a redirect)
22+
vm_health_check:
23+
enable_health_check: False
24+
25+
# Using an in-memory backend so lock instances to 1
26+
manual_scaling:
27+
instances: 1
28+
29+
30+
# Temporary setting to keep gcloud from uploading the virtualenv
31+
skip_files:
32+
- ^v?env$

managed_vms/kinto/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
gunicorn==19.4.5
2+
oauth2client==1.5.2
3+
kinto==1.11.2

0 commit comments

Comments
 (0)
0