Dokku部署騰訊云ubuntu 16.04簡(jiǎn)介

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配置了一個(gè)用戶(以上)佣蓉,就可用git push命令來(lái)部署應(yīng)用。下面用實(shí)例來(lái)介紹一下Dokku開發(fā),你可以使用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主機(jī)上創(chuàng)建應(yīng)用春叫。你需要ssh登錄主機(jī)運(yùn)行以下命令噪矛。

shell

#on the Dokku host

dokku apps:create ruby-rails-sample

Create the backing services

創(chuàng)建后臺(tái)服務(wù)

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:

當(dāng)你新建一個(gè)app時(shí)候小渊,Dokku默認(rèn)不提供任何數(shù)據(jù)存儲(chǔ)放可,如Mysql和Postgres谒臼。你需要安裝插件來(lái)解決數(shù)據(jù)庫(kù)。幸運(yùn)的是Dokku官方插件可以應(yīng)付普通的數(shù)據(jù)存儲(chǔ)耀里。我們的例子app需要一個(gè)Postgres的服務(wù)蜈缤。

shell

#on the Dokku host在Dokku主機(jī)上

#install the postgres plugin安裝postgres插件

#plugin installation requires root, hence the user change需要root權(quán)限

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

#create a postgres service with the name rails-database創(chuàng)建服務(wù)并命名

dokku postgres:create rails-database

Each service may take a few moments to create.

每個(gè)服務(wù)需要一點(diǎn)時(shí)間來(lái)創(chuàng)建。

Linking backing services to applications

將服務(wù)鏈接到應(yīng)用上

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

一旦服務(wù)創(chuàng)建完成冯挎,通過(guò)鏈接服務(wù)來(lái)設(shè)置POSTGRES_URL環(huán)境變量

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.

你可以鏈接一個(gè)服務(wù)到多個(gè)應(yīng)用上底哥,或者使用每個(gè)應(yīng)用都使用一個(gè)服務(wù)。

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.

現(xiàn)在你可以部署ruby-rails-sample應(yīng)用到你的Dokku服務(wù)器房官。你所做的只是為app指定一個(gè)remote名趾徽。應(yīng)用將在Dokku服務(wù)器上自動(dòng)創(chuàng)建。

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語(yǔ)法如上所示翰守。你需要為upstream加ssh://前綴諸如,ssh://dokku@dokku.me:ruby-rails-sample孵奶。更多細(xì)節(jié)請(qǐng)查看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.

當(dāng)部署完畢潦俺,以上應(yīng)用的URL的會(huì)顯示出來(lái)

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

Dokku通過(guò)Heroku buildpacks與Herokuish或者使用一個(gè)項(xiàng)目dockerfile來(lái)部署應(yīng)用。

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一個(gè)容器,你可以通過(guò)設(shè)置$DOKKU_SKIP_DEPLOY=true來(lái)跳過(guò)部署階段事示。

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.

更多信息請(qǐng)看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后早像,會(huì)自動(dòng)打開一個(gè)dokku-installer.py的程序

開啟在80端口上,綁定一個(gè)ssh-key肖爵,但是這個(gè)頁(yè)面的jquery是在google的cdn上卢鹦,貌似被墻了。

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

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

也可以手動(dòng)關(guān)閉服務(wù)sudo service dokku-installer stop

然后手動(dòng)更新ssh-key劝堪。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末冀自,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子秒啦,更是在濱河造成了極大的恐慌熬粗,老刑警劉巖,帶你破解...
    沈念sama閱讀 219,427評(píng)論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件余境,死亡現(xiàn)場(chǎng)離奇詭異驻呐,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)芳来,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,551評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門含末,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人即舌,你說(shuō)我怎么就攤上這事佣盒。” “怎么了顽聂?”我有些...
    開封第一講書人閱讀 165,747評(píng)論 0 356
  • 文/不壞的土叔 我叫張陵肥惭,是天一觀的道長(zhǎng)。 經(jīng)常有香客問我芜飘,道長(zhǎng)务豺,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,939評(píng)論 1 295
  • 正文 為了忘掉前任嗦明,我火速辦了婚禮笼沥,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘娶牌。我一直安慰自己奔浅,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,955評(píng)論 6 392
  • 文/花漫 我一把揭開白布诗良。 她就那樣靜靜地躺著汹桦,像睡著了一般。 火紅的嫁衣襯著肌膚如雪鉴裹。 梳的紋絲不亂的頭發(fā)上舞骆,一...
    開封第一講書人閱讀 51,737評(píng)論 1 305
  • 那天钥弯,我揣著相機(jī)與錄音,去河邊找鬼督禽。 笑死脆霎,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的狈惫。 我是一名探鬼主播睛蛛,決...
    沈念sama閱讀 40,448評(píng)論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼胧谈!你這毒婦竟也來(lái)了忆肾?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,352評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤菱肖,失蹤者是張志新(化名)和其女友劉穎客冈,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體蔑滓,經(jīng)...
    沈念sama閱讀 45,834評(píng)論 1 317
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡郊酒,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,992評(píng)論 3 338
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了键袱。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片燎窘。...
    茶點(diǎn)故事閱讀 40,133評(píng)論 1 351
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖蹄咖,靈堂內(nèi)的尸體忽然破棺而出褐健,到底是詐尸還是另有隱情,我是刑警寧澤澜汤,帶...
    沈念sama閱讀 35,815評(píng)論 5 346
  • 正文 年R本政府宣布蚜迅,位于F島的核電站,受9級(jí)特大地震影響俊抵,放射性物質(zhì)發(fā)生泄漏谁不。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,477評(píng)論 3 331
  • 文/蒙蒙 一徽诲、第九天 我趴在偏房一處隱蔽的房頂上張望刹帕。 院中可真熱鬧,春花似錦谎替、人聲如沸偷溺。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,022評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)挫掏。三九已至,卻和暖如春秩命,著一層夾襖步出監(jiān)牢的瞬間尉共,已是汗流浹背褒傅。 一陣腳步聲響...
    開封第一講書人閱讀 33,147評(píng)論 1 272
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留袄友,地道東北人樊卓。 一個(gè)月前我還...
    沈念sama閱讀 48,398評(píng)論 3 373
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像杠河,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子浇辜,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,077評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容