質問編集履歴

7

修正

2022/08/25 01:26

投稿

senseIY
senseIY

スコア281

test CHANGED
File without changes
test CHANGED
@@ -40,7 +40,7 @@
40
40
  build:
41
41
  context: ./backend/
42
42
  dockerfile: Dockerfile
43
- command: bash -c "rm -f tmp/pids/server.pid && bundle exec puma -C config/puma.rb -e production"
43
+ command: bash -c "rm -f tmp/pids/server.pid && bundle exec puma -C ./backend/config/puma.rb -e production"
44
44
  volumes:
45
45
  - ./backend:/myapp
46
46
  - ./backend/vendor/bundle:/myapp/vendor/bundle

6

追記

2022/08/24 09:24

投稿

senseIY
senseIY

スコア281

test CHANGED
File without changes
test CHANGED
@@ -248,4 +248,4 @@
248
248
  ! Unable to load application: I18n::InvalidLocaleData: can not load translations from /usr/local/bundle/bundler/gems/devise_token_auth-1a0483fbd125/config/locales/ja.yml: #<Psych::SyntaxError: (<unknown>): did not find expected key while parsing a block mapping at line 20 column 7>
249
249
  api_1 | bundler: failed to load command: puma (/usr/local/bundle/bin/puma)
250
250
  ```
251
- このようなエラーになります。
251
+ このようなエラーになります。このエラーが出るのは本番環境のときだけです。

5

追記

2022/08/24 09:22

投稿

senseIY
senseIY

スコア281

test CHANGED
File without changes
test CHANGED
@@ -243,4 +243,9 @@
243
243
  api_1 | and restart your server
244
244
  api_1 |
245
245
  ```
246
- 以下のエラーが発生してしまいました。私の予想ですが、やはりrailsのAPIモードを使用する際には本番環境であってrails assets:precompile はいらないように思えます。
246
+ 以下のエラーが発生してしまいました。私の予想ですが、やはりrailsのAPIモードを使用する際には本番環境であってrails assets:precompile はいらないように思えます。ちなみにそのままupをすると、
247
+ ```
248
+ ! Unable to load application: I18n::InvalidLocaleData: can not load translations from /usr/local/bundle/bundler/gems/devise_token_auth-1a0483fbd125/config/locales/ja.yml: #<Psych::SyntaxError: (<unknown>): did not find expected key while parsing a block mapping at line 20 column 7>
249
+ api_1 | bundler: failed to load command: puma (/usr/local/bundle/bin/puma)
250
+ ```
251
+ このようなエラーになります。

4

追記

2022/08/24 09:11

投稿

senseIY
senseIY

スコア281

test CHANGED
File without changes
test CHANGED
@@ -27,8 +27,11 @@
27
27
  /usr/local/bundle/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
28
28
  bin/rails:4:in `<main>'
29
29
  ```
30
-
30
+ エラーが発生してしまうのは
31
-
31
+ ```wsl
32
+ docker-compose -f docker-compose.production.yml run rails rails assets:precompile RAILS_ENV=production
33
+ ```
34
+ このコマンドを打った時です
32
35
  ### docker-compose.production.yml
33
36
  ```yml
34
37
  version: "3.3"
@@ -213,3 +216,31 @@
213
216
 
214
217
  なぜこのようなエラーが発生してしまうのでしょうか?何かしらアドバイスがあればよろしくお願いいたします。欠けている情報があれば追記いたします。
215
218
 
219
+ ### 追記
220
+ [このGithubの議論](https://github.com/rmosolgo/graphiql-rails/issues/13)を参考に以下を試しました
221
+ 以下をGemfileに追記
222
+ ```
223
+ gem 'sass-rails'
224
+ gem 'uglifier'
225
+ gem 'coffee-rails'
226
+ ```
227
+ application.rbに追記
228
+ ```
229
+ require 'sprockets/railtie'
230
+ ```
231
+ これで再度buildしましたが、
232
+ ```
233
+ api_1 | For more information see: https://github.com/rails/sprockets/blob/070fc01947c111d35bb4c836e9bb71962a8e0595/UPGRADING.md#manifestjs
234
+ api_1 | bundler: failed to load command: puma (/usr/local/bundle/bin/puma)
235
+ api_1 | /usr/local/bundle/gems/sprockets-rails-3.4.2/lib/sprockets/railtie.rb:110:in `block in <class:Railtie>': Expected to find a manifest file in `app/assets/config/manifest.js` (Sprockets::Railtie::ManifestNeededError)
236
+ api_1 | But did not, please create this file and use it to link any assets that need
237
+ api_1 | to be rendered by your app:
238
+ api_1 |
239
+ api_1 | Example:
240
+ api_1 | //= link_tree ../images
241
+ api_1 | //= link_directory ../javascripts .js
242
+ api_1 | //= link_directory ../stylesheets .css
243
+ api_1 | and restart your server
244
+ api_1 |
245
+ ```
246
+ 以下のエラーが発生してしまいました。私の予想ですが、やはりrailsのAPIモードを使用する際には本番環境であってrails assets:precompile はいらないように思えます。

3

誤字修正

2022/08/24 08:30

投稿

senseIY
senseIY

スコア281

test CHANGED
File without changes
test CHANGED
@@ -43,7 +43,7 @@
43
43
  - ./backend/vendor/bundle:/myapp/vendor/bundle
44
44
  environment:
45
45
  TZ: Asia/Tokyo
46
- RAILS_ENV: development
46
+ RAILS_ENV: production
47
47
  # ports:
48
48
  # - "3001:3000"
49
49
  depends_on:

2

追記

2022/08/24 07:16

投稿

senseIY
senseIY

スコア281

test CHANGED
File without changes
test CHANGED
@@ -209,6 +209,7 @@
209
209
  (See full trace by running task with --trace)
210
210
  ```
211
211
  いろいろ調べてみると[Capistrano](https://pikawaka.com/rails/capistrano)は自動デプロイに使うものだと判明しました。ですが、私はそのような機能を入れる予定はないため、あまりエラーの解決策にはならないように思えました。
212
+ ・今使っているrailsは7系です
212
213
 
213
214
  なぜこのようなエラーが発生してしまうのでしょうか?何かしらアドバイスがあればよろしくお願いいたします。欠けている情報があれば追記いたします。
214
215
 

1

誤字修正

2022/08/24 06:56

投稿

senseIY
senseIY

スコア281

test CHANGED
@@ -1 +1 @@
1
- 本番環境railsの{Don't know how to build task 'assets:precompile'}エラーを解決したい。
1
+ 本番環境で起きるrailsの{Don't know how to build task 'assets:precompile'}エラーを解決したい。
test CHANGED
File without changes