175 文字
1 分
chromedriverのインストールをarmとintelのDockerfileで共通化
概要
E2Eテストをするためのchromedriverは、Linuxのディストリビューションごとにパッケージで提供されていないので、おそらく直接ダウンロードしているケースがほとんどかと思います。
Dockerfile上で、アーキテクチャごとにダウンロードするファイルを振り分けるのが理想ですが、Dockerfileではそのようなことはできず、shellscriptを書いて判定する必要があります。
Dockerfileにif文を書くとエスケープ文字や改行で見づらくなるので別途スクリプトを用意してアーキテクチャごとにダウンロードするファイルを変更するのが良いです。
スクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| RUN bin/download-chromedriver.sh && mv chromedriver /usr/local/bin/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| version=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` | |
| architecture=`uname -m` | |
| if [ $architecture == 'aarch64' ]; then | |
| file='chromedriver_mac_arm64.zip' | |
| else | |
| file='chromedriver_linux64.zip' | |
| fi | |
| url="http://chromedriver.storage.googleapis.com/${version}/${file}" | |
| wget -c -N ${url} && unzip ${file} |
追記
む。後日確認したら、chromedriver_mac64_m1.zipが動かなそうだ。。。
関連記事
この記事が役に立ったら
GitHub Sponsorsで応援できます



