Django部署工具,适用于流行的PaaS提供商
项目描述
django-deployer 是一个用于Django的部署工具,目前可以将任何Django应用部署到以下PaaS提供商:Dotcloud、Stackato和Google App Engine。
django-deployer 的目标是最大限度地减少将Django应用部署到任何流行的PaaS提供商所需的努力。它将询问一系列关于您的Django项目的问题,然后生成一个通用的 deploy.yml 文件,该文件捕获了您的项目所需的所有要求。然后,django-deployer 使用此 deploy.yml 文件将这些要求转换为每个PaaS的具体配置。
请参见以下路线图,了解如何添加对更多提供商的支持:Heroku、OpenShift、Elastic Beanstalk和Gondor。
入门
要安装 django-deployer,请使用 pip 从 PyPi 获取包
$ pip install django-deployer
现在从您的项目根目录运行 deployer-init 命令一次,然后运行 fab setup。
在此示例中(使用 paasbakeoff),我们将告诉 django-deployer 准备我们的项目以部署到Google App Engine。
$ deployer-init
$ fab setup
We need to ask a few questions before we can deploy your Django app
* What is your Django project directory name?
(This usually contains your settings.py and a urls.py) mywebsite
* What is your Django settings module? [mywebsite.settings]
* Where is your requirements.txt file? [requirements.txt] mywebsite/requirements/project.txt
* What version of Python does your app need? [Python2.7]
* What is your STATIC_URL? [/static/]
* What is your MEDIA_URL? [/media/]
* Which provider would you like to deploy to (dotcloud, openshift, appengine)? appengine
* What's your Google App Engine application ID (see https://appengine.google.com/)? djangodeployermezz
* What's the full instance ID of your Cloud SQL instance (should be in format "projectid:instanceid" found at https://code.google.com/apis/console/)? djangomezzanine:djangomezzdb
* What's your database name? appenginedemo
* Where is your Google App Engine SDK location? [/usr/local/google_appengine]
Creating a deploy.yml with your app's deploy info...
Created /Users/nateaune/Dropbox/code/paasbakeoff/deploy.yml
Just a few more steps before you're ready to deploy your app!
1. Run this command to create the virtualenv with all the packages and deploy:
$ fab deploy
2. Create and sync the db on the Cloud SQL:
$ sh manage.sh cloudcreatedb
$ sh manage.sh cloudsyncdb
3. Everything is set up now, you can run other commands that will execute on your remotely deployed app, such as:
$ sh manage.sh dbshell
Done.
现在检查您的项目目录,您将看到已创建文件 deploy.yml 和各种配置文件。
注意:如果您要尝试不同的PaaS提供商,建议为每个提供商创建一个单独的git分支,因为当您重新运行 fab setup 时,可能会意外地覆盖第一次运行中的配置文件。
升级
您会注意到当我们运行 pip install django-deployer 时,它创建了一个脚本 deployer-init。当您运行此脚本时,它会在您当前目录中创建一个 fabfile.py 文件,该文件从 django-deployer 项目中导入任务模块。
from django_deployer.tasks import *
这意味着您可以更新 django-deployer 包而无需重新生成 fabfile。
$ pip install -U django-deployer
贡献
如果您想开发 django-deployer,可以克隆它并将其安装到项目的虚拟环境中
$ source bin/activate
(venv)$ git clone git://github.com/natea/django-deployer.git
(venv)$ cd django-deployer
(venv)$ python setup.py develop
或者您也可以使用 pip 安装它的可编辑源版本
$ source bin/activate
(venv)$ pip install -e git+git://github.com/natea/django-deployer.git#django-deployer
这将把 git 仓库克隆到您项目虚拟环境的 src 目录中。
路线图
添加对 Heroku、OpenShift、Amazon Elastic Beanstalk 和 Gondor 的支持
执行一些智能代码分析,以更好地猜测设置(参见 djangolint 项目 - https://github.com/yumike/djangolint)
编写测试!
缓存(Redis、Memcache)
Celery
电子邮件
SSL
更改日志
0.1.6 (2013-04-10)
使用一个更好的处理超时的 createdb.py
删除 dj-database-url,因为它与 Dotcloud 不兼容
提示 manage.py 的位置(因为 Django 1.3 与 1.4 中的项目布局存在差异)
dotcloud.yml 文件需要 DJANGO_SETTINGS_MODULE,否则 manage.py 将无法工作
dotcloud.yml 文件需要 UTF-8,否则浏览 Mezzanine 画廊将无法工作
让用户选择他们的管理员密码,而不是将其硬编码
确保在 settings_dotcloud.py 中定义了 STATIC_ROOT 和 MEDIA_ROOT
如果项目已经有一个顶级 requirements.txt 文件,则不需要做任何事情
添加验证器以确保 requirements 文件存在
验证管理员密码以及用户是否选择了有效的提供者
确保用户没有留下空白字段
0.1.5 (2013-04-08)
需要一个 MANIFEST.in 来找到 .txt 和 .rst 文件(@natea)
修复了将 CHANGES.txt 重命名为 CHANGES.rst 的错误(@natea)
修复了缺失 README.rst 的错误(@natea)
0.1.1 (2013-03-26)
添加了对 Google App Engine 的支持(@natea, @littleq0903)
0.1.0 (2012-09-07)
Stackato 和 Dotcloud 的初始版本(@natea, @johnthedebs)
项目详情
django-deployer-0.1.6.tar.gz 的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 550c8b4757eed92710c38e114ee060a2c6a3c140ba6f82da853e4e3ce0ee35e8 |
|
MD5 | c564eea6a2fbe2fe3afcec2493444d57 |
|
BLAKE2b-256 | fa7af0d90efc74f473edc431d717a99923f36f8485ee08e08089d7bd2b94f21e |