#環境
- Ruby 2.6.5
- Rails 6.0.2
- macOS Mojave→PCを変えてCatalinaに
- Docker desktop 2.1.0.4 → 2.2.2.4
#状況
- githubからアプリをclone
- database.replica.ymlを元に
database.yml
を作成 $ docker-compose build
$ docker-compose up -d
$ docker-compose exec web rails db:create
$ docker-compose exec web rails db:migrate
←ここまで目立ったエラーは無し0.0.0.0;3000
にアクセスすると、以下のエラーが出力される
Webpacker::Manifest::MissingEntryError in Mcs#index Showing /app_name/app/views/layouts/application.html.erb where line #11 raised: Webpacker can't find application in /app_name/public/packs/manifest.json. Possible causes: 1. You want to set webpacker.yml value of compile to true for your environment unless you are using the `webpack -w` or the webpack-dev-server. 2. webpack has not yet re-run to reflect updates. 3. You have misconfigured Webpacker's config/webpacker.yml file. 4. Your webpack configuration is not creating a manifest. Your manifest contains: { }
down --volumes -rmi all
→build
→up -d
をしても状況は変わらず
#調べてわかったこと
エラーメッセージ内にいくつかの可能性が示されていますが、yarnが正常にインストールされていないことが原因の場合が多いようで、今回もyarnのそれが原因ではないかと感じています。
#お聞きしたいこと
- 解決法やヒントとなる情報がありましたら教えていただけますと幸いです
- これまでの私の理解では、
Dockerを使うと、環境を端末やOSに依存しない開発環境を作ることができる。 →ソース(docker関連ファイル含む)さえ揃えることができれば、端末のことは無視できる
と考えていたのですが、実際にはOSの影響を受けることも少なくない、というのが実情なのでしょうか。
#関連するソース
config/webpacker.yml
1# Note: You must restart bin/webpack-dev-server for changes to take effect 2 3default: &default 4 source_path: app/javascript 5 source_entry_path: packs 6 public_root_path: public 7 public_output_path: packs 8 cache_path: tmp/cache/webpacker 9 check_yarn_integrity: false 10 webpack_compile_output: true 11 12 # Additional paths webpack should lookup modules 13 # ['app/assets', 'engine/foo/app/assets'] 14 resolved_paths: [] 15 16 # Reload manifest.json on all requests so we reload latest compiled packs 17 cache_manifest: false 18 19 # Extract and emit a css file 20 extract_css: false 21 22 static_assets_extensions: 23 - .jpg 24 - .jpeg 25 - .png 26 - .gif 27 - .tiff 28 - .ico 29 - .svg 30 - .eot 31 - .otf 32 - .ttf 33 - .woff 34 - .woff2 35 36 extensions: 37 - .mjs 38 - .js 39 - .sass 40 - .scss 41 - .css 42 - .module.sass 43 - .module.scss 44 - .module.css 45 - .png 46 - .svg 47 - .gif 48 - .jpeg 49 - .jpg 50 51development: 52 <<: *default 53 compile: true 54 55 # Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules 56 check_yarn_integrity: false 57 58 # Reference: https://webpack.js.org/configuration/dev-server/ 59 dev_server: 60 https: false 61 host: localhost 62 port: 3035 63 public: localhost:3035 64 hmr: false 65 # Inline should be set to true if using HMR 66 inline: true 67 overlay: true 68 compress: true 69 disable_host_check: true 70 use_local_ip: false 71 quiet: false 72 pretty: false 73 headers: 74 'Access-Control-Allow-Origin': '*' 75 watch_options: 76 ignored: '**/node_modules/**' 77 78 79test: 80 <<: *default 81 compile: true 82 83 # Compile test packs to a separate directory 84 public_output_path: packs-test 85 86production: 87 <<: *default 88 89 # Production depends on precompilation of packs prior to booting for performance. 90 compile: false 91 92 # Extract and emit a css file 93 extract_css: true 94 95 # Cache manifest.json for performance 96 cache_manifest: true 97
Dockerfile
1FROM ruby:2.6.5 2 3RUN apt-get update -qq && apt-get install -y nodejs postgresql-client vim zsh 4 5RUN apt-get update && apt-get install -y curl apt-transport-https wget && \ 6curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ 7echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ 8apt-get update && apt-get install -y yarn 9 10RUN mkdir /app_name 11ENV APP_ROOT /app_name 12WORKDIR $APP_ROOT 13 14ADD ./Gemfile $APP_ROOT/Gemfile 15ADD ./Gemfile.lock $APP_ROOT/Gemfile.lock 16 17RUN gem install bundler 18RUN bundle install 19ADD . $APP_ROOT
yml
1 #docker-compose.yml 2version: '3' 3services: 4 db: 5 image: postgres 6 volumes: 7 - psgl_data:/var/lib/postgresql/data 8 environment: 9 POSTGRES_USER: root 10 POSTGRES_PASSWORD: password 11 ports: 12 - 5434:5432 13 web: 14 build: 15 context: . 16 dockerfile: Dockerfile 17 command: /bin/sh -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" 18 tty: true 19 stdin_open: true 20 depends_on: 21 - db 22 ports: 23 - "3000:3000" 24 volumes: 25 - .:/app_name 26volumes: 27 psgl_data:
yml
1# config/database.yml 2default: &default 3 adapter: postgresql 4 encoding: unicode 5 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 6 host: db 7 username: root 8 password: password 9 10development: 11 <<: *default 12 database: mbc_rails_development 13 14test: 15 <<: *default 16 database: mbc_rails_test 17 18production: 19 <<: *default 20 database: mbc_rails_production 21 username: mbc_rails 22 password: <%= ENV['MBC_RAILS_DATABASE_PASSWORD'] %>
その他必要な情報がございましたらご指摘ください。
どうぞよろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。