-
Notifications
You must be signed in to change notification settings - Fork 0
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
Web用のView基盤の作成 #3
Conversation
This pull request has been linked to Clubhouse Story #80: 開発者として、Web用のViewの基盤が欲しい. なぜなら今後の開発でUIの開発が円滑にできるからだ. |
@hrkmr-tech
これですかね、、https://qiita.com/Hibikine_Kage/items/e59cd59258d977a7e5f9 |
context: ./web | ||
stdin_open: true | ||
tty: true | ||
volumes: |
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.
ログ書き込み系のエラーが出まして、以下のtipsにのっとり8~9行目を削除して、解消しました。
ご参考まで。 🙇🏻
もしかしたらdockerのversionの関係もあるかも(?)
yokoteru@yokosemominoMBP ~ % docker-compose -v
docker-compose version 1.23.2, build 1110ad01
yokoteru@yokosemominoMBP ~ % docker version
Client: Docker Engine - Community
My best practice is to remove the VOLUME definition f
https://stackoverflow.com/questions/52815624/permission-denied-when-web-app-tries-to-write-log-file-to-docker-volume
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.
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.
Windowsユーザの場合は |
(ご参考)おっしゃる通りyarn関連の事象でありそうです |
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.
/web
にまとめてるの良いですね!ちょっと紹介し忘れてしまっていましたが(すみません、、)、このProjectは下記のstructureをbaseに作ってるので、それとも合っています!
docker-compose.yml
Outdated
volumes: | ||
- ./web:/home/app | ||
ports: | ||
- 3000:3000 |
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.
3000番がRails標準なので可能であればちょっとでか目の数字にして外していただけると助かります笑
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.
13000に変更します。
web/Dockerfile
Outdated
@@ -0,0 +1,14 @@ | |||
FROM node:14.16-alpine3.13 AS web |
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.
Dockerfileを web/Dockerfile
にも用意したのって何か理由ありますか??rootのDockerfileにnodeも追記する感じで、jsはcompileして配布って感じかなと思っていました。そうするとDockerfileで yarn start
するみたいなことをしなくて良いかと思います。
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.
開発中にコードの変更を検知して自動リロードを走らせるために yarn start
でプロセスを走らせておきたいという話です。docker-compose up
したときに起動に時間が掛かるのでcomposeからも外して、別起動させた方が良さそうと思いつつあります。
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.
dev: NODE_ENV=development yarn run webpack --watch --colors --progress --mode=development
webpack --watch
でhot reloadができます。なのでdev時はこれを呼ぶ感じにしておけば良いかなと思います。 buildは時間多少かかるかもですが、 docker-compose up
自体で時間がかかるのことは経験上あまりない印象ですがどうですかね(うちの会社も手伝ってる会社もcomposeに含めてます)。
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.
react-scripts
でやったことないのですが、それがhot reloadに対応してないんですかね
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.
Dockerfileは本番用ビルドに使用し、docker-compose.yml
はCMDを上書きして開発用に使用するという認識で合っていますか?私がどういう方針で行けば良いのか迷子になっています。
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.
あっています。(一時的にdeploy -> EC2で docker-compose up
でいく可能性はありますが)
なので、それ用のDockerfileで yarn start
しないでbuildしてcompile済みstatic fileを特定のdirectoryに配置の方が良いのではないかと思っています
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.
これは start
がhot reload対応です。
react-scripts でやったことないのですが、それがhot reloadに対応してないんですかね
web/README.md
Outdated
|
||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). | ||
|
||
To learn React, check out the [React documentation](https://reactjs.org/). |
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.
このREADMEは削除して必要であればrootのREADMEに追記するで良いかと思いました!
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.
こちら削除します。
FYI: 私の環境ではlocalhostでの立ち上げは問題なくできました |
@@ -22,3 +22,19 @@ USER app | |||
COPY --chown=app:app ./ $APP_DIR | |||
|
|||
CMD go run main.go | |||
|
|||
|
|||
FROM node:14.16-alpine3.13 AS web |
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.
別ファイルにしていたweb用のDockerfileを削除し、ルートにある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.
ありがとうございます、、追加のerrrorが発生したため調査中です 🙇🏻 (docker-versionの問題だと思いますが)
yokoteru@yokosemominoMBP paddle % docker-compose up
ERROR: The Compose file './docker-compose.yml' is invalid because:
services.go.build contains unsupported option: 'target'
services.web.build contains unsupported option: 'target'
yokoteru@yokosemominoMBP paddle % git log
commit b06d14e19a74d9120ae491dd8613b0e1a5a048e3 (HEAD -> 3820/ch80/web-view-ui, origin/3820/ch80/web-view-ui)
Author: Hiroki Mori <xxx.bvb.taylor@gmail.com>
Date: Sun Apr 11 23:32:48 2021 +0900
docker multi-stage buildに変更
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.
docker-compose -v
?
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.
これですな。。
yokoteru@yokosemominoMBP paddle % docker-compose -v docker-compose version 1.23.2, build 1110ad01
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.
yokoteru@yokosemominoMBP paddle % cd web
yokoteru@yokosemominoMBP web % ls -la
total 2184
drwxrwxrwx 12 yokoteru staff 384 4 12 01:01 .
drwxr-xr-x 17 yokoteru staff 544 4 12 01:00 ..
drwxr-xr-x 2 yokoteru staff 64 4 12 01:01 .cache
-rw-r--r-- 1 yokoteru staff 310 4 11 23:40 .gitignore
-rw-r--r-- 1 yokoteru staff 116 4 11 23:40 .yarnrc
drwxrwxrwx 22 yokoteru staff 704 4 12 01:03 node_modules
-rwxrwxrwx 1 yokoteru staff 976 4 11 23:40 package.json
drwxrwxrwx 8 yokoteru staff 256 4 11 23:40 public
drwxrwxrwx 11 yokoteru staff 352 4 11 23:40 src
-rwxrwxrwx 1 yokoteru staff 535 4 11 23:40 tsconfig.json
-rwxrwxrwx 1 yokoteru staff 533809 4 12 01:10 yarn-error.log
-rwxrwxrwx 1 yokoteru staff 509485 4 11 23:40 yarn.lock
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.
ゴリ押してweb配下の権限を変更していくとログも変化しているので、解決できそうな感じがします。
chomod -R 777 web/
実行後
error An unexpected error occurred: "EACCES: permission denied, mkdir '/home/app/node_modules/@pmmmwh/react-refresh-webpack-plugin/node_modules'".
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.
rm -r ./web/node_modules
rm ./web/yarn-error.log
docker-compose up
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.
node_modules配下削除したところ、別箇所で修正必要のようでそちら直します。
T```
requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "docker-compose", line 3, in
File "compose/cli/main.py", line 81, in main
File "compose/cli/main.py", line 199, in perform_command
File "compose/cli/command.py", line 60, in project_from_options
File "compose/cli/command.py", line 152, in get_project
File "compose/cli/docker_client.py", line 41, in get_client
File "compose/cli/docker_client.py", line 170, in docker_client
File "docker/api/client.py", line 197, in init
File "docker/api/client.py", line 221, in _retrieve_server_version
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
[7907] Failed to execute script docker-compose
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.
👍🏻
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.
LGTM!
これ私がstatus checkを入れたせいでmergeできない感じですよね、、一度オフにしてmergeしましょうか |
あ、adminなら強制mergeできるのでそれでしていただいて大丈夫ですね! |
mergeします 👍🏻 |
(と思いましたがMoriさんにmergeしていただくのが良いかもですね メンバーを全員adminに変更したかと) |
ストーリー
開発者として、Web用のViewの基盤が欲しい. なぜなら今後の開発でUIの開発が円滑にできるからだ
https://app.clubhouse.io/chubachipt21/story/80/web-view-ui
やったこと
補足事項
http://localhost:13000 にアクセスするとReact.jsの初期画面が表示される