Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Mini-Heroku "Dokku"

morizyun
October 14, 2016

Mini-Heroku "Dokku"

It is about private PaaS "Dokku"!

morizyun

October 14, 2016
Tweet

More Decks by morizyun

Other Decks in Programming

Transcript

  1. Mini-Heroku "Dokku"
    Japanese: @zyunnosuke
    English: @morizyune

    View full-size slide

  2. By the way...
    • ᪁ޱίϤϷ΅ίϤϷͶͧ΁ᵞӾͭ͵͚
    • Heroku ΅ git πϫЀϖͽϔϤϺα͢ͽͣͼ䮭

    View full-size slide

  3. Heroku ΄僻ාᇇ΄ϔϮϷϐϕ
    • US/UK΁ͭ͡ςЄϝ͢僻͚ => ॡଘ၇ཞෙ΁200-300ms
    ֖ϹφϪЀφ͢͡͡Ρ
    • 30ړզӤίμψφͭ΀͚;φϷЄϤᇫ䙪΁΀Ρ (ࢧ᭿ᒽ
    ͘Π)
    • 僻ාͶ; PostgreSQL ΁1ӡϹπЄϖզӤጭ梍ͽͣ΀͚
    (ࢧ᭿ᒽ͘Π)
    • cronጱ΀㳌ቘΨͯΡ͵Η΁΅㳨΄ workerϤϺψφ Ψ㵕
    ͯ͡஠ᥝ͘͢Ρ

    View full-size slide

  4. About "Dokku"
    • πЀψϤϕ΅̿Docker powered mini-Heroku in
    around 100 lines of Bash̀
    • Heroku;֒͵build΄՛奲Εͽ̵Ruby̵Java̵
    Scala̵Go̵DockerᒵϔϤϺαͽͣΡ
    • ubuntu 14.04 ΁ 2πϫЀϖͽαЀφϕЄϸͽͣΔͯ
    $ wget https://raw.githubusercontent.com/dokku/
    dokku/v0.7.2/bootstrap.sh
    $ sudo DOKKU_TAG=v0.7.2 bash bootstrap.sh

    View full-size slide

  5. Dokku Architecture
    • nginx
    • Docker
    • git (docker image repository)
    • buildstep(buildpack emulates Heroku build)
    • bash script
    git push => buildpack => ίϤϷ΄containerΨ
    build => nginx 奺ኧͽweb΁ل樄

    View full-size slide

  6. Deploy Flow (1)
    • on your Dokku host:
    # Create the app
    dokku apps:create ruby-rails-sample
    # Plugin installation requires root, hence the user change
    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
    # Linking backing services to applications
    dokku postgres:link rails-database ruby-rails-sample

    View full-size slide

  7. Deploy Flow (2)
    • From your local machine:
    # get command line tool(like herokutoolbelt)
    gem install dokku-cli
    # get Heroku Ruby on Rails example app
    git clone [email protected]:heroku/ruby-rails-sample.git
    # Add remote repository to git
    git remote add dokku [email protected]:ruby-rails-sample
    # Set secret key
    bundle exec rake secret
    dokku config:set SECRET_KEY_BASE=xxx
    # Deploy the app (Zero downtime)
    git push dokku master

    View full-size slide

  8. Sample application
    • https://workshop.morizyun.com
    • ܎ଙͥΟ͚晁አͭͼय़ͣ΀ϕ϶ϣϸ僻ͭ

    View full-size slide

  9. Many Plugins
    • Elasticsearch̵PostgreSQL̵https䌏䖕̵ϦЄτϐμ扯戣;͡

    View full-size slide

  10. Digital Ocean
    • $25 Coupon - http://www.newcoupons.info/
    digitalocean-free-25usd-credit/

    View full-size slide

  11. Dokku ϔϮϷϐϕ
    • μ϶φό䯤౮΅ͽͣ΀͚(๜ኾςЄϠφ΁΅㷗ͭͳ͜)
    • ςЄϝ͢஠ᥝ(͠ᰂ͢͡͡Ρ)
    • Heroku΄Ξ͜΁ϮЀϓπφϕ͢ωϺ;΅͚͡΀͚
    • ͵Δ΁ Ruby ΄ DLͽε϶Є͢ڊΡ(厏ह䄜හ
    CURL_TIMEOUT, CURL_CONNECT_TIMEOUT Ψ晒ଶ΁槱ͥ)
    'curl -L --fail --retry 3 --retry-delay 1 --connect-timeout 3 --max-
    time 30 https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/
    cedar-14/ruby-2.3.1.tgz -s -o - | tar zxf -

    View full-size slide

  12. ͚ͩ͜͜ίϤϷ͢ݻ͚ͼ͚Ρ
    • cron;͡ΨϥϠЄ΁ֵ͚͵̶͚ϔЄόᰁ͘͢Ρ
    ᑕଶग़͚
    • Ϥ϶αϦЄϕϚϐϕϼЄμٖ΄PaaS;ͭͼֵ͚
    ͵͚
    • 樄咲Ӿ΄ branch ΄嘦扯አ;ͭͼֵ͚͵͚

    View full-size slide

  13. Let's try!!
    • Ubuntu ΄厏ह䯤塈ಋ殼
    • http://blog.morizyun.com/posts/dokku-isntall-vultr-pass-mini-heroku
    • Digital Ocean Ύ΄ϔϤϺα
    • http://morizyun.github.io/blog/dokku-postgresql-rails-digital-ocean/
    • Cron ΄ֵ͚ො
    • https://blog.morizyun.com/posts/dokku-cron-etire-exist-containt-
    docker-schedule

    View full-size slide