前提
現在個人開発をしています。
dockerで作ったRailsAPIです。
Github
https://github.com/takoyan33/rails-react-backend
実現したいこと
RailsAPIのbuildを成功し、エラーを解消したい
発生している問題・エラーメッセージ
以前はdocker buildできたが、Herokuに公開できなくなった。
原因としては、
docker buildx build . --platform linux/amd64 -t username/rails-react-app-backend:latest
時にエラーが出ます。
エラーメッセージ #0 2.510 Your Ruby version is 2.7.7, but your Gemfile specified 2.7.6
rbenvのバージョンエラーというのは分かったのですが、2.7,6に設定してもバージョンを変更してもうまく変わりませんでした。
BUILD FAILED (macOS 13.1 using ruby-build 20221225) Inspect or clean up the working tree at /var/folders/vh/2zbpwnb173n9dldfch8b2qdc0000gn/T/ruby-build.20230117153832.12320.9phto8 Results logged to /var/folders/vh/2zbpwnb173n9dldfch8b2qdc0000gn/T/ruby-build.20230117153832.12320.log
以前までは上手くいったのですが、なぜでしょうか。
なぜか2.7,7
分かる方がいれば回答よろしくお願いします。
該当のソースコード
#Dockerfile # FROMでベースイメージを設定 # 今回はRubyのバージョン2.7をベースイメージとして設定 FROM ruby:2.7 # nodeやyarn等の必要なライブラリをインストール RUN apt-get update -qq && apt-get install -y nodejs postgresql-client # Railsアプリを配置するフォルダをコンテナ内に作成 RUN mkdir /myapp # 作成したディレクトリをワークディレクトリとして設定 WORKDIR /myapp # ルート配下のGemfileをコンテナ内のRailsアプリを配置場所にコピー COPY Gemfile /myapp/Gemfile # Gemfile.lockも同様にコンテナ内にコピーする COPY Gemfile.lock /myapp/Gemfile.lock # Gemfileの記述を元にbundle installを実行 RUN bundle install COPY . /myapp # ローカルで作成したentrypoint.shファイル(後で記述)を/usr/bin/へコピー COPY entrypoint.sh /usr/bin/ # /usr/bin/entrypoint.shに対して実行権限を付与している(chmod +x) # これによってシェルスクリプトファイルを実行可能にする RUN chmod +x /usr/bin/entrypoint.sh # exec形式でデフォルトで実行するコマンドラインの引数としてentrypoint.shを指定 ENTRYPOINT ["entrypoint.sh"] # ネットワーク上のポートを指定する EXPOSE 4000 # Railsサーバーを稼働させる CMD ["rails", "server", "-b", "0.0.0.0"]
#Gemfile source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.7.6' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' gem 'rails', '~> 6.0.5', '>= 6.0.5.1' # Use postgresql as the database for Active Record gem 'pg', '>= 0.18', '< 2.0' # Use Puma as the app server gem 'puma', '~> 4.1' gem "devise" gem "devise_token_auth" # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder # gem 'jbuilder', '~> 2.7' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use Active Model has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use Active Storage variant # gem 'image_processing', '~> 1.2' # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.4.2', require: false # Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible gem 'rack-cors' gem 'graphql' group :development do gem 'graphiql-rails' gem 'sass-rails' end group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] end group :development do gem 'listen', '~> 3.2' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
試したこと
一通りエラーについては検索して試しましたが、変化がありませんでした。
rbenvのバージョン変更
補足情報(FW/ツールのバージョンなど)
githubにて詳しく記載

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。