-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix docker working dir #107
Conversation
tamakiii
commented
Apr 18, 2020
- Fix docker entrypoint #85 で crawler コンテナ内で動いている nginx が動かなくなってしまったのを修正
- 手もとで確認しやすいよう http://localhost:8080/ でも動くように
🧸 sarabi-mastiff.lan:covid19-surveyor
$ docker-compose exec crawler make publish
./crawler/publish.sh > ./www-data/index.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
気づいたことをコメントしました。動作は問題なかったです。
WORKDIR /app | ||
COPY . /app | ||
WORKDIR /home/ubuntu/vscovid-crawler | ||
COPY . /home/ubuntu/vscovid-crawler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ディスクデバイスの様子を見ると現実的じゃない。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
すみません。
wget しなければへいきですね。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
いや。
make wget した後でも使えるようになっていないと困ります。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そもそもentrypointを指定していたのはこれが原因なんだけど、そもそもdocker buildしたタイミングでcurrent directoryを全部参照するっぽいので今の構造自体をdockerのためにリファクタリングしないといけないのでは....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
僕のPRでentrypointをわざとDockerfileに書かなかった理由ですね。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
わかりにくい文になってしまいましたが、「 .dockerignore で /tmp を指定しているので、build 時に /tmp は COPY されない」はずです
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make wget
したときに www-data/ に数十GB のファイルができるので、そちらを懸念しているのだと思います。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そもそもですが、 docker-compose.yml
でマウントしているように見えるんですがプロジェクト全ファイルの COPY は必要なんでしょうか?
少なくともビルド時に必要なファイルは、明示的に COPY しているように見えるのですが。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make wget
の成果物 /result.txt
と /www-data/
以下のサイトを認識したので .dockerignore に追加しました。
www-data
以下の成果物は出力先の構造的に適切にignoreできなそうだったので www-data
そのものを ignore してしまっています。
他にもあれば追加します
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そもそもですが、 docker-compose.yml でマウントしているように見えるんですがプロジェクト全ファイルの COPY は必要なんでしょうか?
Docker Image 単体で動くのが好ましいという観点からアプリケーションに当たるこのリポジトリ全体を COPY しています。
「docker-compose で volume マウントする開発環境」と割り切るなら、混乱されてそうですし COPY しない方に倒すでもいいかなーと思ってます
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
いつ make wget するのか、を明確にしないとですね。
docker-compose up のたびに走るのは現実的に使い物にならない。
make wget した後のディレクトリをコピーするのはディスク容量に問題がある。
🧸 sarabi-mastiff.lan:covid19-surveyor
$ docker history --no-trunc covid19-surveyor_crawler:latest
IMAGE CREATED CREATED BY SIZE COMMENT
sha256:5fa53fc8e2588d088f62e4dee8c0a77a8302e075e03a071be88b69d09a073ac5 About a minute ago /bin/sh -c #(nop) EXPOSE 80 0B
sha256:3e56d66520139c4545cc8beacf02a3c76baf3b908cd7f4df32bdc533ce599aff About a minute ago /bin/sh -c #(nop) COPY file:cce6012199ce0d694045839f3ed131dbfeda32990f8f2b3f0bd5396decf9244c in /usr/local/sbin/redis-cli 52B
sha256:04531ee1cea65163a7af4b34d6f3e075e00ab5f734db7ecccd60329f7e74173f About a minute ago /bin/sh -c #(nop) ENTRYPOINT ["docker-entrypoint.sh"] 0B
sha256:f9d8e89a3f0b4c3748cb707a07c0fb7cc69d3ddf63334992829df6967ba3916f About a minute ago /bin/sh -c #(nop) COPY file:11b7ed291b297f01f85bc325136f35230e3476f7eee398b295f7396778a0639a in /usr/local/sbin/docker-entrypoint.sh 309B
sha256:fb31848a1d352a785cd4521d2309d9e4f3b26f5c05e588e2ed85935067dfb4ad About a minute ago /bin/sh -c #(nop) COPY dir:004a36f2786ec1d6fddfc9a5f120f138957d5ee49d0ef7275925ac8b07851076 in /home/ubuntu/vscovid-crawler 410kB
sha256:677004730a146b0098f42d9d85fdc6331d12298f4be54b620d88e2380e730cb8 19 hours ago /bin/sh -c #(nop) WORKDIR /home/ubuntu/vscovid-crawler 0B
sha256:1798afbf84a7a3adba65127837f80cbf89e37f4be8a66ad4ae00f95afe83158c 19 hours ago /bin/sh -c #(nop) COPY file:da09fe60620f1012a4ffbc803ea83161433b023b7921ec971a6118c87843fa70 in /etc/squid/squid.conf 291kB
sha256:6377a2947a873098ee7b89a4ce974d0147ed71fd753bc86e9fdee40358d5a3cb 19 hours ago /bin/sh -c ln -s /etc/nginx/sites-available/vscovid-crawler.conf /etc/nginx/sites-enabled/vscovid-crawler.conf 47B
sha256:73d759875903e3f543af027a15acc94bdb18b0dfd90b76804a4b0ce576dba959 19 hours ago /bin/sh -c #(nop) COPY file:9e31cabc65c3fa05a0238b4967b7f4d9ba068f28484bac923db638021c0bf582 in /etc/nginx/sites-available/vscovid-crawler.conf 714B
sha256:a6f3d072d94e0b5a9ac9f2fd669fa4442fd710df13ce5880c012b52b9aa14109 19 hours ago /bin/sh -c apt-get update && apt-get install -y make wget jq nginx fcgiwrap squid redis-tools poppler-utils && apt-get clean && rm -rf /var/lib/apt/lists/* 147MB
sha256:17d9de846f007b658f5ebcadbc8c77ea441624d1db42f77844989f329b53dece 27 hours ago /bin/sh -c #(nop) MAINTAINER TAKANO Mitsuhiro 0B
sha256:4e5021d210f65ebe915670c7089120120bc0a303b90208592851708c1b8c04bd 4 weeks ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B
<missing> 4 weeks ago /bin/sh -c mkdir -p /run/systemd && echo 'docker' > /run/systemd/container 7B
<missing> 4 weeks ago /bin/sh -c set -xe && echo '#!/bin/sh' > /usr/sbin/policy-rc.d && echo 'exit 101' >> /usr/sbin/policy-rc.d && chmod +x /usr/sbin/policy-rc.d && dpkg-divert --local --rename --add /sbin/initctl && cp -a /usr/sbin/policy-rc.d /sbin/initctl && sed -i 's/^exit.*/exit 0/' /sbin/initctl && echo 'force-unsafe-io' > /etc/dpkg/dpkg.cfg.d/docker-apt-speedup && echo 'DPkg::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' > /etc/apt/apt.conf.d/docker-clean && echo 'APT::Update::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' >> /etc/apt/apt.conf.d/docker-clean && echo 'Dir::Cache::pkgcache ""; Dir::Cache::srcpkgcache "";' >> /etc/apt/apt.conf.d/docker-clean && echo 'Acquire::Languages "none";' > /etc/apt/apt.conf.d/docker-no-languages && echo 'Acquire::GzipIndexes "true"; Acquire::CompressionTypes::Order:: "gz";' > /etc/apt/apt.conf.d/docker-gzip-indexes && echo 'Apt::AutoRemove::SuggestsImportant "false";' > /etc/apt/apt.conf.d/docker-autoremove-suggests 745B
<missing> 4 weeks ago /bin/sh -c [ -z "$(apt-get indextargets)" ] 987kB
<missing> 4 weeks ago /bin/sh -c #(nop) ADD file:594fa35cf803361e69d817fc867b6a4069c064ffd20ed50caf42ad9bb11ca999 in / 63.2MB |
- root /home/ubuntu/vscovid-crawler/www-data/$domain;
+ root /home/ubuntu/vscovid-crawler/www-data/generated-sites/$domain;
- /www-data/
+ /www-data/generated-sites/ |
|
「
そうですねー
.dockerignore に設定していれば問題にはなりませんが、このへん混乱を生みそうであれば COPY しないのも手かなーと思います |
make wgetは非現実的なくらい容量消費するうえに全自治体のサイトに負荷がかかるから各自のDocker環境でやってほしくないです。
|
ですよねー。わかります。 readme に make wget は悪手なので消すとして(どなたか既に対応してくださってましたが)、nginx が正常に動かないのを直すところまでは進めたいんですが、どうしましょうか… |
@yuiseki さんの提示したサンプルコードを踏襲すれば else のところの |
SQS障害にやられておりました…。
すでに 464c06d でしてくださっているのを確認しました。ありがとうございます。
よさそうでした〜 |
現状あまり使っている人がいなそうで優先度は低そうな気がしているんですが、中途半端な状態で残すのは後に混乱を生みそうなので、nginxが動く所までマージしたいと思っています〜 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 本番環境では Docker は使わない
make wget
は本番環境以外では法外な容量にはならない
という前提ができたのでいいと思います。既に reduce.csv がリポジトリにあるので、make publish
でローカルNGINXの動作確認はできました。
see also. #26 |