以下の内容をEC2上にデプロイしたのですが、バックエンドのrailsのみうまく動作していません。
フロントエンド:react
バックエンド:rails(APIモード) , nginx, puma
ローカルでdocker-composeを用いて開発しており、本番環境でも同様にdocker-composeを用いてデプロイしています。
ec2にsshでログインし、デプロイしているアドレスにリクエストをした際のログを見ると500のエラーがでているのですが、詳しい情報がなく、なぜ500になっているのかわからず困っております。
ターミナルのログ(/gymsにアクセス、つまり/gymsにgetリクエストを出した際のログ)
https://gyazo.com/5f1282f3a35d3a89a9d414545b6abbdd
routes.rbなどのファイルは以下に記載しております。
初心者質問で恐縮ですがよろしくお願いいたします。
ファイル構成
https://gyazo.com/e92a44c33eacf9f8d0b09ee6322d8234
routes.rb
Rails.application.routes.draw do get '/gyms', to: 'gyms#index' post '/gyms', to: 'gyms#create' delete '/gyms/:id', to: 'gyms#destroy' get '/login', to: 'sessions#new' post '/login', to: 'sessions#create' delete '/logout', to: 'sessions#destroy' get '/trainings', to: 'trainings#index' get '/trainings/:id', to: 'trainings#user_training' post '/trainings', to: 'trainings#create' post '/trainings/search', to: 'trainings#search' delete '/trainings/:id', to: 'trainings#destroy' get '/trainings/:id/followers', to: 'trainings#getting_followers' resources :users get 'users/trainings/:training_id', to: 'users#follow_training' get 'users/:user_id/trainings/:training_id', to: 'users#followed_training?' delete 'users/:user_id/trainings/:training_id', to: 'users#unfollow_training' get '/chats/:id', to: 'chats#show' post '/chats', to: 'chats#create' delete '/chats/:id', to: 'chats#destroy' end
docker-compose
version: "3" services: app: build: context: ./api/ dockerfile: Dockerfile env_file: - ./api/environments/db.env command: bundle exec puma -C config/puma.rb -e production volumes: - ./api:/webapp - public-data:/webapp/public - tmp-data:/webapp/tmp - log-data:/webapp/log front: build: context: ./front/ dockerfile: Dockerfile volumes: - ./front:/usr/src/app command: sh -c "cd react_front && yarn start" ports: - "3000:3000" volumes: public-data: tmp-data: log-data:
DockerFile(rails)
FROM ruby:2.6 # リポジトリを更新し依存モジュールをインストール RUN apt-get update -qq && \ apt-get install -y build-essential \ nodejs # ルート直下にwebappという名前で作業ディレクトリを作成(コンテナ内のアプリケーションディレクトリ) RUN mkdir /webapp WORKDIR /webapp # ホストのGemfileとGemfile.lockをコンテナにコピー ADD Gemfile /webapp/Gemfile ADD Gemfile.lock /webapp/Gemfile.lock # bundle installの実行 RUN bundle install # ホストのアプリケーションディレクトリ内をすべてコンテナにコピー ADD . /webapp # puma.sockを配置するディレクトリを作成 RUN mkdir -p tmp/sockets
DockerFile(nginx)
FROM nginx:1.15.8 # インクルード用のディレクトリ内を削除 RUN rm -f /etc/nginx/conf.d/* # Nginxの設定ファイルをコンテナにコピー ADD nginx.conf /etc/nginx/conf.d/webapp.conf # ビルド完了後にNginxを起動(デーモンをオフにしてフォアグラウンドで実行) CMD /usr/sbin/nginx -g 'daemon off;' -c /etc/nginx/nginx.conf
回答1件
あなたの回答
tips
プレビュー