$30 off During Our Annual Pro Sale. View Details »

DockerでNodeの開発は厳しいのか? #gotandajs

DockerでNodeの開発は厳しいのか? #gotandajs

mizuki_r

May 10, 2019
Tweet

More Decks by mizuki_r

Other Decks in Technology

Transcript

  1. DockerでNodeの開発は厳しいのか?
    2019/05/10 Gotanda.js #11
    @mizuki_r

    View Slide

  2. @mizuki_r
    弁護士ドットコム株式会社
    税理士ドットコム事業部/開発チーム
    チームマネージャー
    2
    自己紹介
    JavaScript, Vue, Nuxt,

    Perl, PHP, Docker, AWS, etc…

    View Slide

  3. 免責事項
    • VS Code使いの意見です
    • intelijも試したかったけど時間が…
    • 所属する組織・団体の主張ではなく、個人
    の意見です
    • 鵜呑みにせず、参考にとどめましょう

    View Slide

  4. Node環境もDockerにしたい

    View Slide

  5. Node on Dockerしたい
    • 複数プロジェクトを並列で開発している
    • グローバルインストールしたくない
    • ndenv, nvm, etc, メンテしたくない
    • docker-composeに集約したい

    View Slide

  6. Docker for Macは
    mounted volumeの
    IOが非常に遅い

    View Slide

  7. IOが非常に遅い
    • mounted volumeの更新系が遅い
    • Nodeを用いた開発はファイルのW/Rが非常
    に多くなる
    • npm install, build処理など
    • これが遅いのは致命的

    View Slide

  8. rm -rf node_modules/* && npm install
    環境 実行時間
    ホストマシン 14.93s
    Docker with mounted volumes 86.83s

    View Slide

  9. Dockerにmountしたvolume
    への更新は遅い

    View Slide

  10. mountしなければいいのでは?

    View Slide

  11. mounted volumeでの
    大幅なIO更新をやめる

    View Slide

  12. mounted volumeをやめる
    node_modulesを上書きして、ホストにマウントしなくする

    View Slide

  13. rm -rf node_modules/* && npm install
    環境 実行時間
    ホストマシン 14.93s
    Docker with mounted volumes 86.83s
    Docker without mounted
    volumes
    20.22s

    View Slide

  14. だいぶマシになった。

    View Slide

  15. mounted volumeしないと
    困るか?

    View Slide

  16. VS Code使いあるある
    • eslint, typescriptのVS Code Serverがホ
    ストに必要
    • node_modulesを直接参照(見る・書換る)
    したい

    View Slide

  17. コンテナの中で
    VS Code Serverを動かせればぁ…

    View Slide

  18. VS Code Insiders

    View Slide

  19. VS Code Insiders
    • vscodeの新機能を確認したり、テストした
    りするためのInsiders Programの後継
    • 通常版のvscodeと同居でき、設定も別のエ
    ディタとして利用する
    https://code.visualstudio.com/insiders/

    View Slide

  20. Developing inside a Container
    • Remote Developmentの拡張を追加するこ
    とでSSH, Containers, WSLとの通信が可能
    • リモートでVS Code Serverを実行し、リ
    モートの環境で行われたあれこれをホスト
    側のVS Codeに反映してくれる
    https://code.visualstudio.com/docs/remote/containers

    View Slide

  21. View Slide

  22. まとめ

    View Slide

  23. まとめ
    • NodeJS on DockerはIOのマウントを外せ
    ば軽減する
    • VS CodeのInsiders buildを使うことでホ
    ストにマウントせず開発ができる

    View Slide

  24. 実行環境

    View Slide

  25. 実行環境
    • MBP 2018 Core i7 16GB
    • Docker version 18.09.2, build 6247962
    • docker-compose version 1.23.2, build
    1110ad01
    • node v11.15.0

    View Slide

  26. 実験コード
    https://github.com/rymizuki/example-node-on-docker

    View Slide