Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

20150101勉強会 dokku alt

1,131 views

Published on

Published in: Internet
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

20150101勉強会 dokku alt

  1. 1. Dokku-altで heroku(風)を作る 2015/1/1 @shugonumano
  2. 2. Dockerとは? • 最近流行りのコンテナ
 https://www.docker.com/ • 2014年6月にver1.0.0 • 周辺も盛り上がっている
 コンテナ管理(Kubernetes)、ネットワーク (weave)、OS(CoreOS) など
  3. 3. Dokkuとは? • dotcloud知ってますか? • docker使って、PaaSできるの? • 「mini-Heroku」が作れる
 https://github.com/progrium/dokku
  4. 4. Dokku-altとは? • DokkuパワーアップしたDokku Alternative
 https://github.com/dokku-alt/dokku-alt • 今回はこれで、Heroku(風)環境を構築します。 • 最終的に、Railsのscaffoldで作成した Rails+PostgreSQLのwebアプリをDokku-alt上 のコンテナに実装します。
  5. 5. Dokku-alt構成 Mac VirtualBox Ubuntu Docker Dokku-alt コンテナ コンテナ コンテナ
  6. 6. Dokku-alt手順 • 下記を参照に簡単に構築できた。
 http://knowledge.sakura.ad.jp/tech/2545/
 http://kray.jp/blog/dokku-alternative/
 https://github.com/dokku-alt/dokku-alt

  7. 7. 終わり
  8. 8. やっぱり、 もう少し続けます
  9. 9. Dokku-altで heroku(風)を Docker in Dockerで作って Rails+Postgresqlアプリを構築する
  10. 10. Dokku-alt Docker in Docker構成 • Docker in Docker
 http://kray.jp/blog/docker-in-docker-per- project-or-permission/ • 要は、Dokku-alt環境も、Dockerコンテナで構 築したい。
  11. 11. 構成 Mac VirtualBox Ubuntu Docker コンテナ コンテナ コンテナ Dockerdokku-alt コンテナ 172.17.0.x/16 testproject.my-domain.com 192.168.33.10/24 192.168.33.1/24 172.17.42.1/16 192.168.33.10 172.17.0.x testproject testproject.my-domain.com hosts iptables nat dokku-alt ① ②③ ④ ⑤⑦ ⑥
  12. 12. 手順① • VirtualBoxに、vagrantを使ってubuntuをinstall
 $ vagrant init ubuntu/trusty64
 $ vi Vagrantfile
 config.vm.network "private_network", ip: 192.168.33.10 
 config.vm.provider "virtualbox" do ¦vb¦
 vb.customize ["modifyvm", :id, "--memory", 2048"] # defalt:512Mだとエラーになった ため
 end
 $ vagrant up
 $ vagrant ssh

  13. 13. 手順② • ubuntuにdockerをinstall
 $ sudo apt-get update
 $ sudo apt-get install docker.io
 $ source /etc/bash_completion.d/docker.io • https://docs.docker.com/installation/ ubuntulinux/
 

  14. 14. 手順③ • virtual box内のubuntuで、dokku-altの存在するコンテナをprivileged modeでinstall
 $ docker run --volume=/home/dokku --volume=/var/lib/docker --name=dokku-alt-data busybox:latest
 $docker run -d --name=dokku-alt --hostname=my-domain.com --volumes-from=dokku-alt-data -- publish=10022:22 --publish=80:80 --publish=443:443 --privileged ayufan/dokku-alt:latest • IPとPWを確認
 $ docker logs dokku-alt
 dokku.1 ¦ SSH Login:
 dokku.1 ¦ user: root
 dokku.1 ¦ password: lfMUjxYEvqpRRLY6 # 環境によって異なります
 dokku.1 ¦ ip: 10.0.42.1 172.17.0.x # 環境によって異なります
 dokku.1 ¦ Starting dokku daemon... • コンテナにssh接続
 $ ssh root@172.17.0.x • コンテナ上のdokku-altに公開 を登録
 $ cat .ssh/id_rsa.pub ¦ssh root@172.17.0.x dokku access:add

  15. 15. 手順④ • ubuntuのiptablesのforwardにて、ubuntu向けの通信をdokku-altが 動いているdockerコンテナにforwardする。
 $ sudo iptables -t nat -A PREROUTING -m tcp -p tcp --dst 192.168.33.10 --dport 80 -j DNAT --to-destination 172.17.0.x:8
 $ sudo iptables -t nat -A PREROUTING -m tcp -p tcp --dst 192.168.33.10 --dport 22222 -j DNAT --to-destination 172.17.0.x:22
 $ sudo iptables -L -vt nat • 参考
 http://mo.kerosoft.com/0203
 http://blog.rutti.net/item_747.html#.VJmeSAgMA
 http://ubuntuforums.org/showthread.php?t=1111454
  16. 16. 手順⑤ • dokku-alt上で、app(testproject)を作成し、curl_time値 を120秒に設定(git push時のtimeoutエラー回避)
 root@my-domain: # dokku create testproject
 root@my-domain: # dokku config:set testproject CURL_TIMEOUT=120 • DB(postgresql)を作成し、appと関連付け
 root@my-domain: # dokku postgresql:create sample- db
 root@my-domain: # dokku postgresql:link testproject sample-db
  17. 17. 手順⑥ • Railsアプリを作成
 $ rails new testproject -d postgresql
 $ cd testproject
 $ vi Gemfile # rails_12factor,unicornを追加。これがないと、dokku-alt上で rails+postgresqlが起動しない
 gem 'rails_12factor', group: :production
 gem 'unicorn'
 $ bundle install ̶path vendor/bundle
 $ rails g scaffold post name:string title:string content:text
 $ vi config/routes.rb
 root posts#index 
 $ rake assets:precompile • 下記を参考に、Procfile,config/unicorn.rbを追加。全く同じでok
 https://github.com/heroku/ruby-rails-sample
  18. 18. 手順⑥続き • local PCでhosts編集
 $ sudo vi /etc/hosts
 192.168.33.10 my-domain.com testproject.my-domain.com • local PCで /.ssh/configにgit push用設定を追加
 $ sudo vi /.ssh/config
 Host my-domain.com
 Port 22222 • local PCでgit push実施
 $ git init
 $ git add .
 $ git commit -m 'init'
 $ git remote add dokku dokku@my-domain.com:testproject
 $ git remote -v
 $ git push dokku master
  19. 19. 手順⑦ • dokku-altからコンテナに対して、rake db:migrateを実施
 root@my-domain: # dokku run testproject rake db:migrate
  20. 20. 動作確認 • local PCのブラウザで下記をopen
 http://testproject.my-domain.com • railsアプリが表示されればok
  21. 21. まとめ • heroku(風)にRails+postgresqlのアプリをdokku-alt上に構築で きた。 • ⑤⑦はdokku-alt(PaaS)側の手順のなので、ここは省略したい。
 =>ssh -t dokku@my-domain.com <cmd>で対応できそう。
 http://progrium.viewdocs.io/dokku/remote-commands • default以外のruntime、DB、その他機能追加は可能か? • 他のPaaS OSS環境(CloudFoundry,OpenShift)だと手順はどう だろう。
  22. 22. 参考 https://github.com/dokku-alt/dokku-alt https://dokku-alt.github.io/how-it-works.html https://docs.docker.com/installation/ubuntulinux/ https://docs.docker.com/reference/commandline/cli/ http://qiita.com/algas/items/b9a3e7347b5945697587 http://stackoverflow.com/questions/24586573/docker-error-client-and-server-dont-have-same-version https://stnly.com/dokku/ http://dev.classmethod.jp/tool/docker/getting-started-docker-on-osx/ http://kray.jp/blog/docker-in-docker-per-project-or-permission/ http://kray.jp/blog/dokku-alternative/ http://knowledge.sakura.ad.jp/tech/2545/ http://blog.bma.rocks/2014/10/23/easy-application-deployments-with-dokku/ http://deeeet.com/writing/2014/05/11/docker-host-networking/ http://deeeet.com/writing/2014/12/01/docker-link-pattern/ https://gist.github.com/linjunpop/6247236 https://github.com/romaninsh/dokku-alt-manager http://progrium.viewdocs.io/dokku/installation

×