Dokku部署腾讯云ubuntu 16.04简介

Deploying to Dokku

部署到Dokku

Deploy tutorial

部署教程

Once Dokku has been configured with at least one user, applications can be deployed via a git push command. To quickly see Dokku deployment in action, you can use the Heroku Ruby on Rails example app.

只要给Dokku配置了一个用户(以上),就可用git push命令来部署应用。下面用实例来介绍一下Dokku开发,你可以使用Heroku的Ruby on Rails例子app。

以下代码:

shell

#from your local machine

#SSH access to github must be enabled on this host

git clone git@github.com:heroku/ruby-rails-sample.git

Create the app

Create the application on the Dokku host. You will need to ssh onto the host to run this command.

在Dokku主机上创建应用。你需要ssh登录主机运行以下命令。

shell

#on the Dokku host

dokku apps:create ruby-rails-sample

Create the backing services

创建后台服务

When you create a new app, Dokku by default does not provide any datastores such as MySQL or PostgreSQL. You will need to install plugins to handle that, but fortunately Dokku has official plugins for common datastores. Our sample app requires a PostgreSQL service:

当你新建一个app时候,Dokku默认不提供任何数据存储,如Mysql和Postgres。你需要安装插件来解决数据库。幸运的是Dokku官方插件可以应付普通的数据存储。我们的例子app需要一个Postgres的服务。

shell

#on the Dokku host在Dokku主机上

#install the postgres plugin安装postgres插件

#plugin installation requires root, hence the user change需要root权限

sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git

#create a postgres service with the name rails-database创建服务并命名

dokku postgres:create rails-database

Each service may take a few moments to create.

每个服务需要一点时间来创建。

Linking backing services to applications

将服务链接到应用上

Once the service creation is complete, set the POSTGRES_URL environment variable by linking the service.

一旦服务创建完成,通过链接服务来设置POSTGRES_URL环境变量

shell

#on the Dokku host

#each official datastore offers a `link` method to link a service to any application

dokku postgres:link rails-database ruby-rails-sample

You can link a single service to multiple applications or use one service per application.

你可以链接一个服务到多个应用上,或者使用每个应用都使用一个服务。

Deploy the app

部署app

Now you can deploy the ruby-rails-sample app to your Dokku server. All you have to do is add a remote to name the app. Applications are created on-the-fly on the Dokku server.

现在你可以部署ruby-rails-sample应用到你的Dokku服务器。你所做的只是为app指定一个remote名。应用将在Dokku服务器上自动创建。

shell

#from your local machine

#the remote username *must* be dokku or pushes will fail

cd ruby-rails-sample

git remote add dokku dokku@dokku.me:ruby-rails-sample

git push dokku master

Note: Some tools may not support the short-upstream syntax referenced above, and you may need to prefix the upstream with the scheme ssh:// like so: ssh://dokku@dokku.me:ruby-rails-sample Please see the Git documentation for more details.

注意:一些工具可能不支持short-upstream语法如上所示。你需要为upstream加ssh://前缀诸如,ssh://dokku@dokku.me:ruby-rails-sample。更多细节请查看Git文档。

Counting objects: 231, done.

Delta compression using up to 8 threads.

Compressing objects: 100% (162/162), done.

Writing objects: 100% (231/231), 36.96 KiB | 0 bytes/s, done.

Total 231 (delta 93), reused 147 (delta 53)

-----> Cleaning up...

-----> Building ruby-rails-sample from herokuish...

-----> Adding BUILD_ENV to build environment...

-----> Ruby app detected

-----> Compiling Ruby/Rails

-----> Using Ruby version: ruby-2.2.1

-----> Installing dependencies using 1.9.7

      Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment

      Fetching gem metadata from https://rubygems.org/...........

      Fetching version metadata from https://rubygems.org/...

      Fetching dependency metadata from https://rubygems.org/..

      Using rake 10.4.2

...

=====> Application deployed:

      http://ruby-rails-sample.dokku.me

When the deploy finishes, the application's URL will be shown as seen above.

当部署完毕,以上应用的URL的会显示出来

Dokku supports deploying applications via Heroku buildpacks with Herokuish or using a project's dockerfile.

Dokku通过Heroku buildpacks与Herokuish或者使用一个项目dockerfile来部署应用。

Skipping deployment

If you only want to rebuild and tag a container, you can skip the deployment phase by setting $DOKKU_SKIP_DEPLOY to true by running:

如果你仅仅想重建和tag一个容器,你可以通过设置$DOKKU_SKIP_DEPLOY=true来跳过部署阶段。

shell

#on the Dokku host

dokku config:set ruby-rails-sample DOKKU_SKIP_DEPLOY=true

Re-Deploying / restarting

If you need to re-deploy (or restart) your app:

如果你需要重新部署或者重启app:

shell

#on the Dokku host

dokku ps:rebuild ruby-rails-sample

See the process scaling documentation for more information.

更多信息请看process scaling documentation

Deploying with private git submodules

Dokku uses git locally (i.e. not a docker image) to build its own copy of your app repo, including submodules. This is done as the dokku user. Therefore, in order to deploy private git submodules, you'll need to drop your deploy key in /home/dokku/.ssh/ and potentially add github.com (or your VCS host key) into /home/dokku/.ssh/known_hosts. The following test should help confirm you've done it correctly.

shell

#on the Dokku host

su - dokkussh-keyscan -t rsa github.com>>~/.ssh/known_hostsssh -T git@github.com

Note that if the buildpack or dockerfile build process require ssh key access for other reasons, the above may not always apply.

Deploying to subdomains

The name of remote repository is used as the name of application to be deployed, as for example above:

shell

#from your local machine

#the remote username *must* be dokku or pushes will fail

git remote add dokku dokku@dokku.me:ruby-rails-sample

git push dokku master

output

remote: -----> Application deployed:

remote:        http://ruby-rails-sample.dokku.me

You can also specify fully qualified names, say app.dokku.me, as

shell

#from your local machine#the remote username *must* be dokku or pushes will failgit remote add dokku dokku@dokku.me:app.dokku.megit push dokku master

output

remote: -----> Application deployed:

remote:        http://app.dokku.me

This is in particular useful, then you want to deploy to root domain, as

shell

#from your local machine

#the remote username *must* be dokku or pushes will fail

git remote add dokku dokku@dokku.me:dokku.me

git push dokku master

output

... deployment ...

remote: -----> Application deployed:

remote:        http://dokku.me

#from your local machine

#SSH access to github must be enabled on this host

git clone git@github.com:heroku/ruby-rails-sample.git

安装好dokku后,会自动打开一个dokku-installer.py的程序

开启在80端口上,绑定一个ssh-key,但是这个页面的jquery是在google的cdn上,貌似被墙了。

需要去/usr/share/dokku/contrib/dokku-installer.py修改一下script

改成https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js即可

也可以手动关闭服务sudo service dokku-installer stop

然后手动更新ssh-key。

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 195,898评论 5 462
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 82,401评论 2 373
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 143,058评论 0 325
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,539评论 1 267
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,382评论 5 358
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,319评论 1 273
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,706评论 3 386
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,370评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,664评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,715评论 2 312
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,476评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,326评论 3 313
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,730评论 3 299
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,003评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,275评论 1 251
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,683评论 2 342
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,877评论 2 335

推荐阅读更多精彩内容