0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Docker for Mac上でのunittestを高速化した話

Last updated at Posted at 2021-01-09

概要

自作したdocker環境があまりにも遅かったので高速化しました

結論としては
ボリュームマウントに大量の読み書きを走らせない
のが最も効果がありました

前提

環境

  • MacOS Mojave バージョン 10.14.6
  • Docker version 20.10.2 build 2291f61
  • php:5.5-apache
  • mysql:5.6
  • redis:2.8.23
  • memcached:1.4.39

unittest内容

  1. gitで指定のブランチにチェックアウト
  2. pipでのパッケージインストール
  3. composerでのパッケージインストール
  4. sqlファイルをDBに投入してのフォーマットチェック
  5. テスト用データをDBに投入
  6. phpコードのフォーマットチェック
  7. phpのunittest(DB/Redis/Memcachedアクセスあり)

効果

ホストマシン上で実行した場合:20分
効率化前:1時間
効率化後:20分

対応策

ボリュームマウントにdelegated/cachedを付けた

docker for Macではボリュームマウントに設定されたファイルアクセスが非常に遅いらしく
ホストマシンとコンテナ内で整合性を担保しないかわりに高速化するオプションだそうです

これだけでは体感できるほど高速化できませんでした

ボリュームマウントに巨大なファイルを渡すのをやめた

git管理のプロジェクトコードが巨大なので
ボリュームマウントに設定するのではなくコンテナにCOPYした

これでunittestがかなり早くなり
ホストマシン上で動かすのと大差ない状態になりました

結論

ボリュームマウントに大量の読み書きを走らせない

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?