├── .gitignore ├── Procfile ├── runtime.txt ├── requirements.txt ├── bin ├── compile └── post_compile ├── .profile.d └── env.sh ├── runapp.py ├── LICENSE ├── app.json ├── kinto.ini └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: ./runapp.py 2 | -------------------------------------------------------------------------------- /runtime.txt: -------------------------------------------------------------------------------- 1 | python-3.11.2 2 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | kinto[postgresql] 2 | -------------------------------------------------------------------------------- /bin/compile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | kinto --ini=kinto.ini --backend=postgresql init 5 | -------------------------------------------------------------------------------- /bin/post_compile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eo pipefail 3 | 4 | source ./.profile.d/env.sh 5 | kinto migrate --ini=kinto.ini 6 | -------------------------------------------------------------------------------- /.profile.d/env.sh: -------------------------------------------------------------------------------- 1 | export KINTO_CACHE_URL="${DATABASE_URL//postgres:/postgresql:}" 2 | export KINTO_STORAGE_URL="${DATABASE_URL//postgres:/postgresql:}" 3 | export KINTO_PERMISSION_URL="${DATABASE_URL//postgres:/postgresql:}" 4 | -------------------------------------------------------------------------------- /runapp.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | 4 | from paste.deploy import loadapp 5 | from waitress import serve 6 | 7 | if __name__ == "__main__": 8 | port = int(os.environ.get("PORT", 5000)) 9 | 10 | database = os.getenv("DATABASE_URL") 11 | 12 | if not database: 13 | raise ValueError("DATABASE_URL is not correctly defined: %s" % 14 | database) 15 | 16 | os.environ["DATABASE_URL"] = database.replace("postgres://", "postgresql://") 17 | 18 | app = loadapp('config:kinto.ini', relative_to='.') 19 | 20 | serve(app, host='0.0.0.0', port=port) 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2015 - Mozilla Foundation 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 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Kinto", 3 | "description": "Store, Sync, and Share", 4 | "keywords": [ 5 | "kinto", 6 | "storage", 7 | "data", 8 | "self-hosted" 9 | ], 10 | "addons": [ 11 | "heroku-postgresql" 12 | ], 13 | "website": "https://github.com/kinto/kinto-heroku", 14 | "repository": "https://github.com/kinto/kinto-heroku", 15 | "logo": "https://avatars0.githubusercontent.com/u/13413813", 16 | "scripts": {}, 17 | "env": { 18 | "KINTO_USERID_HMAC_SECRET": { 19 | "description": "The secret used to create the user ID from a username:password pair", 20 | "generator": "secret" 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /kinto.ini: -------------------------------------------------------------------------------- 1 | [server:main] 2 | use = egg:waitress#main 3 | host = 0.0.0.0 4 | port = 8888 5 | 6 | [app:main] 7 | use = egg:kinto 8 | 9 | kinto.storage_backend = kinto.core.storage.postgresql 10 | kinto.cache_backend = kinto.core.cache.postgresql 11 | kinto.permission_backend = kinto.core.permission.postgresql 12 | 13 | # The hmac secret below gets overridden by the environment variable 14 | # KINTO_USERID_HMAC_SECRET which gets set on creation of the Heroku app 15 | # See the env section of app.json 16 | # kinto.userid_hmac_secret = Provided-by-app.json 17 | multiauth.policies = basicauth 18 | # multiauth.policies = fxa basicauth 19 | 20 | kinto.experimental_permissions_endpoint = true 21 | kinto.experimental_collection_schema_validation = true 22 | 23 | kinto.includes = kinto.plugins.default_bucket 24 | kinto.plugins.admin 25 | 26 | # FIND A WAY TO CONFIGURE IT VIA HEROKU. 27 | kinto.http_scheme = https 28 | # kinto.http_host = kinto.services.mozilla.com 29 | 30 | # [uwsgi] 31 | # wsgi-file = app.wsgi 32 | # enable-threads = true 33 | # socket = /var/run/uwsgi/kinto.sock 34 | # chmod-socket = 666 35 | # processes = 3 36 | # master = true 37 | # module = kinto 38 | # harakiri = 120 39 | # uid = kinto 40 | # gid = kinto 41 | # virtualenv = .venv 42 | # lazy = true 43 | # lazy-apps = true 44 | # single-interpreter = true 45 | # buffer-size = 65535 46 | # post-buffering = 65535 47 | 48 | 49 | # 50 | # Logging configuration 51 | # 52 | 53 | # kinto.logging_renderer = kinto.core.logs.ClassicLogRenderer 54 | 55 | [loggers] 56 | keys = root, kinto 57 | 58 | [handlers] 59 | keys = console 60 | 61 | [formatters] 62 | keys = generic 63 | 64 | [logger_root] 65 | level = INFO 66 | handlers = console 67 | 68 | [logger_kinto] 69 | level = DEBUG 70 | handlers = 71 | qualname = kinto 72 | 73 | [handler_console] 74 | class = StreamHandler 75 | args = (sys.stderr,) 76 | level = NOTSET 77 | formatter = generic 78 | 79 | [formatter_generic] 80 | format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s 81 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kinto for heroku 2 | 3 | `kinto-heroku` is an example on how to use [Kinto](http://kinto-storage.org) and [Heroku](https://heroku.com) together. 4 | Following the installation you should have a Kinto server available for you to use. 5 | 6 | ## Installation 7 | 8 | ``` 9 | $ git clone http://github.com/Kinto/kinto-heroku.git kinto-instance && cd kinto-instance 10 | $ heroku apps:create kinto-instance 11 | $ heroku addons:create heroku-postgresql --app kinto-instance 12 | $ git remote set-url heroku git@heroku.com:kinto-instance.git 13 | $ git push heroku master 14 | $ heroku open 15 | ``` 16 | 17 | _N.B: changing the url to ssh instead of https is required if you are facing a `HTTP 400 Bad Request` error on `git push heroku master`._ 18 | 19 | [![Deploy to Heroku](https://www.herokucdn.com/deploy/button.png)](https://dashboard.heroku.com/new?template=https://github.com/Kinto/kinto-heroku) 20 | 21 | ## How to upgrade / change configuration ? 22 | 23 | First of all use the [heroku command](https://toolbelt.heroku.com/) to login: 24 | 25 | ``` 26 | $ heroku login 27 | 28 | Enter your Heroku credentials. 29 | Email: you@mail.com 30 | Password (typing will be hidden): 31 | ``` 32 | 33 | Then clone this repository and link it to your heroku app (here named `myapp`): 34 | 35 | ``` 36 | $ git clone http://github.com/Kinto/kinto-heroku.git --depth=1 myapp 37 | $ cd myapp 38 | ``` 39 | 40 | (*optional*) Edit your configuration: 41 | 42 | ``` 43 | $ 44 | $ git commit -am "New setting" 45 | ``` 46 | 47 | > Note: You can also edit the `requirements.txt` to add new dependencies / plugins. 48 | 49 | Update the stack: 50 | 51 | ``` 52 | $ heroku git:remote -a myapp 53 | $ git push -u heroku master 54 | 55 | remote: Compressing source files... done. 56 | remote: Building source: 57 | remote: 58 | remote: -----> Using set buildpack heroku/python 59 | remote: -----> Python app detected 60 | remote: $ pip install -r requirements.txt 61 | remote: 62 | remote: -----> Running post-compile hook 63 | remote: /app/.heroku/python/lib/python2.7/site-packages/cliquet/storage/postgresql/client.py:87: UserWarning: Reuse existing PostgreSQL connection. Parameters permission_* will be ignored. 64 | remote: warnings.warn(msg) 65 | remote: /app/.heroku/python/lib/python2.7/site-packages/cliquet/storage/postgresql/client.py:87: UserWarning: Reuse existing PostgreSQL connection. Parameters cache_* will be ignored. 66 | remote: warnings.warn(msg) 67 | remote: 68 | remote: -----> Discovering process types 69 | remote: Procfile declares types -> web 70 | remote: 71 | remote: -----> Compressing... 72 | remote: Done: 42.3M 73 | remote: -----> Launching... 74 | remote: Released v7 75 | remote: https://myapp.herokuapp.com/ deployed to Heroku 76 | remote: 77 | remote: Verifying deploy... done. 78 | ``` 79 | 80 | Done! 81 | --------------------------------------------------------------------------------