面向流行paas提供者的django部署工具
django-deployer的Python项目详细描述
django deployer是django的一个部署工具,它当前将任何django应用程序部署到以下paas提供程序: Dotcloud、Stackato和谷歌应用引擎。
django deployer的目标是尽可能减少将django应用程序部署到任何流行paas提供者的工作量。它会询问有关django项目的一系列问题,然后生成一个通用的deploy.yml文件,该文件捕获项目的所有需求。然后django deployer使用这个deploy.yml文件将这些需求转换为每个paa的特定配置。
请参阅下面的路线图以添加对更多提供者的支持:heroku、openshift、elastic beanstalk和gondor。
开始
要安装django部署程序,请使用pip从pypi获取包:
$ pip install django-deployer
现在从项目的根目录运行deployer-init命令一次,然后运行fab setup。
在这个例子中(使用paasbakeoff),我们将告诉djangoDeployer准备将项目部署到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项目导入tasks模块。
fromdjango_deployer.tasksimport*
这意味着您可以更新django部署程序包,而不需要重新生成fabfile。
$ pip install -U django-deployer
贡献
如果您想开发django deployer,可以将其克隆并安装到项目的virtualenv:
$ 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 repo克隆到项目virtualenv的src目录中。
路线图
- 添加对Heroku、Openshift、Amazon Elastic Beanstalk和Gondor的支持
- 执行一些智能代码分析以更好地猜测设置(请参见djangolint项目-https://github.com/yumike/djangolint)
- 写测试!
- 缓存(redis,memcache)
- 芹菜
- 电子邮件
- SSL
更改日志
0.1.6(2013-04-10)
- 使用更好地处理超时的createdb.py
- 删除DJ数据库URL,因为它不适用于点云
- 提示输入manage.py的位置(对于django 1.3与1.4中的项目布局差异)
- dotcloud.yml文件需要django_settings_模块,否则manage.py将无法工作
- dotcloud.yml文件需要utf-8,否则浏览夹层库将不起作用
- 让用户选择他们的管理密码,而不是硬编码它
- 确保在settings\u dotcloud.py中定义了静态根和媒体根
- 如果project已经有了顶级requirements.txt,请不要执行任何操作
- 添加验证器以确保需求文件存在,
- 验证管理员密码并确认用户选择了有效的提供商
- 确保用户不将字段留空
0.1.5(2013-04-08)
- 需要清单。才能找到.txt和.rst文件(@natea)
- 修正了错误命名changes.txt的错误->;changes.rst(@natea)
- 修复了缺少readme.rst(@natea)的错误
0.1.1(2013-03-26)
- 增加了对谷歌应用引擎的支持(@natea,@littleq0903)
0.1.0(2012-09-07)
- stackato和dotcloud的初始版本(@natea,@johnthedebs)