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

開発環境をどっかんどっかん立てる

Konboi
March 07, 2015

 開発環境をどっかんどっかん立てる

若手Webエンジニア交流会 #9 の発表資料です

Konboi

March 07, 2015
Tweet

More Decks by Konboi

Other Decks in Programming

Transcript

  1. ։ൃ؀ڥΛ
    Ͳ͔ͬΜͲ͔ͬΜཱͯΔ
    @Konboi / एखWebษڧձ #9

    View full-size slide

  2. ͦ͏ͩμδϟϨͩʂ͓ͬ͞Μͩʂʂ

    View full-size slide

  3. ͸΍͘ ! ͍ͨ͠
    ·͖ΊͰ͕Μ͹Γ·͢

    View full-size slide

  4. ࣗݾ঺հ
    • @Konboi
    • ໘ന๏ਓKAYAC
    • ೖࣾ 3೥໨
    • ࣗࣾαʔϏε → डୗνʔϜ → ήʔϜ։ൃ/ӡ༻
    • ޷͖ͳ΋ͷ: ! "
    • ೰Έ: ݁ࠗࣜͷ2࣍ձͷग़͠෺ͱ͔ͰἤΒΕΔ

    View full-size slide

  5. ࠓ೔࿩͢͜ͱ

    View full-size slide

  6. docker ! × mirage
    Λ࢖ͬͨςετ؀ڥߏஙͷ࿩

    View full-size slide

  7. docker × Non
    Productionͷ࿩Ͱ͢

    View full-size slide

  8. ͦ͏Ͱ͢ʂ ·ͨͰ͢ʂʂ

    View full-size slide

  9. ͓෇͖߹͍Լ͍͞ !

    View full-size slide

  10. ήʔϜͷӡ༻͍ͯ͠Δͱ
    • stg؀ڥ͕ඞཁ
    • Ϛελʔσʔλௐ੔༻ͷ؀ڥ͕ඞཁ
    • ৽ػೳ։ൃ༻ͷ؀ڥ͕ඞཁ
    • ΠϕϯτQA༻ʹαʔόʔͷ࣌ؒΛਐΊͨ؀ڥ͕ඞཁ
    • ਃ੥લͷ݁߹QA؀ڥ͕ඞཁ
    • ͳͲͳͲ༷ʑͳ؀ڥ͕ඞཁʹͳΔ

    View full-size slide

  11. ࠓ·ͰͲ͏͔ͯͨ͠?
    • stg + dev01͔ΒdevXX·Ͱ༻ҙ͢Δ
    • IRCͷBotܦ༝Ͱ೚ҙͷbranchΛdeploy
    • ۭ͍͍ͯΔ؀ڥΛࣗ༝ʹ࢖͏

    View full-size slide

  12. ΄΅ίϐϖͷconfϑΝΠϧ͕ྔ࢈

    View full-size slide

  13. • A͞Μ < devAA ࢖ͬͯ·͔͢ʁ
    • B͞Μ < ͋Ŋࠓ࢖ͬͯΔ͔Β devBB ࢖ͬͯ΋Β͑Δʁ
    • C͞Μ < ࠓ devBB ࣗ෼͕࢖ͬͯΔʂ
    • A͞Μ < ɾɾɾ (´ɾωɾʆ)

    View full-size slide

  14. ͜ͷ··Ͱ͸...

    View full-size slide

  15. ςετ؀ڥͷୣ͍߹͍ʁʂ
    νʔϜͷงғؾ͕ѱ͘ͳΔʁʂ

    View full-size slide

  16. ςετ؀ڥϚωʔδϟʔ͕ඞཁʹʁʂ

    View full-size slide

  17. ͪΌΜͱ֬ೝͤͣʹϦϦʔεʁʂ
    ෆ۩߹͕ग़ͯେมͳ͜ͱʹʁʂ

    View full-size slide

  18. ͜Ε͸΍͹͍ʂʂʂ

    View full-size slide

  19. ΍͹͗͢Δʂ

    View full-size slide

  20. Ͳ͏΍ͬͯղܾ͔ͨ͠ʁ

    View full-size slide

  21. docker × mirage
    Λ࢖༻ͯ͠ղܾ΁

    View full-size slide

  22. mirageͬͯʁ

    View full-size slide

  23. mirageͱ͸
    • written by golang acidlemon/mirage
    • REST/WebͷΠϯλϑΣʔεͰDockerίϯςφΛىಈ/ఀࢭ
    • αϒυϝΠϯΛࢦఆͯ͠ίϯςφ΁ͷϦόʔεϓϩΩγ
    • gitͷಛఆͷϒϥϯνͰαʔϏεΛߏ੒Մೳ
    • GIT_BRANCͰࢦఆͨ͠ϒϥϯν໊औಘՄೳͳͨΊ

    View full-size slide

  24. ͪΐͬͱҙຯ͕...(^_^;)

    View full-size slide

  25. ͱ͍͏͜ͱͰ

    View full-size slide

  26. ࢖༻ํ๏

    View full-size slide

  27. go get github.com/acidlemon/mirage

    View full-size slide

  28. mirage --conf config.yml

    View full-size slide

  29. # config.yml
    host:
    webapi: docker.wakateweb.konboi.com
    reverse_proxy_suffix: .wakateweb.konboi.com
    listen:
    foreign_address: 127.0.0.1
    http:
    - listen: 5580
    target: 4567
    docker:
    endpoint: unix:///var/run/docker.sock
    default_image: "wakateweb:latest"

    View full-size slide

  30. nginx.conf
    upstream backend_docker {
    server 127.0.0.1:5580;
    }
    server {
    listen 80;
    server_name *.wakateweb.konboi.com;
    access_log /var/log/nginx/access.docker.log ltsv;
    error_log /var/log/nginx/error.docker.log error;
    location / {
    proxy_pass http://backend_docker;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    }

    View full-size slide

  31. ͲΜͳdocker image ??

    View full-size slide

  32. αϯϓϧ͸ͪ͜Β
    Konboi/docker-practice
    ؀ڥߏங͸itamaeΛ࢖ͬͯΈ·ͨ͠

    View full-size slide

  33. ϙΠϯτ
    • go get ͰΠϯετʔϧ͕Φεεϝ
    • ϦϦʔεύοέʔδΛ࢖͏৔߹͸leveldͷΠϯετʔϧ
    • dockerίϯςφ΋͋Γ·͢
    • DB͸ผίϯςφ͔RDS౳Λར༻͢Δͷ͕Φεεϝ
    • ίϯςφ಺ʹ࡞Δͱ࡟আͷࡍʹDBσʔλ΋໪࿦࡟আ
    • rackup͸listen port ͕ localhostͳͷͰϋϚΓ·͢

    View full-size slide

  34. ·ͱΊ
    • docker × mirageΛ࢖ͬͯշదͳ؀ڥߏஙΛ
    • ίϐϖͷΑ͏ͳ.confϑΝΠϧ͕ྔ࢈͞Εͳ͍
    • Rest/Webܦ༝ͰߏஙͰ͖ΔͷͰ୭Ͱ΋؀ڥߏஙՄೳʹ
    • ؀ڥΛୣ͍߹ΘͣʹࡁΈνʔϜͷงғؾ͕ྑ͘ͳΓ·ͨ͠ʂ
    • ͪΌΜͱνΣοΫͰ͖ΔͷͰόά̌ʂ ࠷ߴͩʂʂ

    View full-size slide

  35. KAYACͰ͸৭ʑ
    Ͳ͔ͬΜͲ͔ͬΜ͍ͨ͠
    ΤϯδχΞΛืूதͰ͢

    View full-size slide

  36. ͝੩ௌ͋Γ͕ͱ͏͍͟͝·͢ !

    View full-size slide