##実現したいこと
現在Docker-machineを使って、仮想環境のvirtualbox上に
React+Rails+MySqlの環境構築を行いたいと思ってます。
##解決したいこと
こちらの記事を参考に環境構築を行なっているのですが、
Docker-compose up 時にyarnのエラーになってしまいます
ssh
1 2$ docker-compose up 3省略 4yarn run v1.22.15 5error Couldn't find a package.json file in "/myapp" 6info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. 7
front側のコンテナだけうまくいかず、railsやMySQLのコンテナはきちんと動作しております。
frontのコンテナが動かないので、create-react-appもできない状態(行なっても、同じ様にpackege.jsonが見つからないと怒られる)
以下Dockerfileなどです
###構成
myapp |-api |-front docker-compose.yml
docker@try1:~/myapp$ ls api/ Dockerfile Rakefile config.ru log vendor Gemfile app db public Gemfile.lock bin entrypoint.sh storage README.md config lib tmp #rails.newをした後なので、Docker-file以外のディレクトリができています docker@try1:~/myapp$ ls front/ Dockerfile
front側のDockerfile
Dockerfile
1 2FROM node:17-alpine 3#ここは何度か別verを試したりしています。 4RUN mkdir /myapp 5WORKDIR /myapp
docker
1docker@try1:~/myapp$ cat docker-compose.yml 2version: '3' 3services: 4 db: 5 image: mysql:8.0 6 environment: 7 MYSQL_ROOT_PASSWORD: password 8 ports: 9 - '3306:3306' 10 command: --default-authentication-plugin=mysql_native_password 11 volumes: 12 - mysql-data:/var/lib/mysql 13 api: 14 build: ./api 15 command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" 16 volumes: 17 - ./api:/myapp 18 - gem_data:/usr/local/bundle 19 ports: 20 - "3000:3000" 21 depends_on: 22 - db 23 stdin_open: true 24 tty: true 25 front: 26 build: ./front 27 command: yarn start 28 ports: 29 - '8000:3000' 30 volumes: 31 - ./front:/myapp 32 depends_on: 33 - api 34 tty: true 35volumes: 36 mysql-data: 37 gem_data: 38 driver: local
##試したこと
1 yarnの公式を見て、
DockerfileにRUN yarn init -2
やRUN yarn install
を記述したりしましたが、変わりませんでした。
(Dockerfileを記述後に、再度docker-compose build
でイメージの作り直しは当然行なっております。)
2 Dockerfileのnodeのverを変えることも実施
3 docker-composeを書き換え
コマンドを実行するディレクトリが悪いのかと思い、docker-composeのfrontサービスのコマンドを以下の様に書き換えても
ssh
1 command: sh -c "cd front && yarn start"
ssh
1ocker@try1:~/myapp$ docker-compose up 2省略 3front_1 | sh: cd: line 1: can't cd to front: No such file or directory 4db_1 | 2021-12-19T00:43:22.204506Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead. 5db_1 | 2021-12-19T00:43:22.204528Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.27) starting as process 1 6db_1 | 2021-12-19T00:43:22.244707Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 7myapp_front_1 exited with code 2 8 9cdのそんなディレクトリ見つからないよと怒られる
わかる方いらっしゃれば、お知恵をいただけるとありがたいです。
よろしくお願いします。
##環境
docker@try1:~/myapp$ docker --version Docker version 19.03.12, build 48a66213fe docker@try1:~/myapp$ docker-compose --version docker-compose version 1.16.1, build 6d1ac21
virtualboxの環境
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/12/21 01:00
2021/12/23 14:25