Docker version 20.10.8, build 3967b7d
Ruby 3.0.0 / Rails6.1.0
docker初心者です。
railsをビルドしたいのですが、webpackerのインストールで躓いています。
Dockerfile
Dockerfile
# Rubyをインストール FROM ruby:3.0.0 # Node.jsをインストール RUN curl -sL RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \ apt install nodejs # Yarnをインストール RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ apt update && apt install yarn # 環境変数を設定 ENV APP_HOME /app # ディレクトリの作成と移動 WORKDIR $APP_HOME # ホストのGemfileなどをコンテナへコピー COPY Gemfile $APP_HOME/Gemfile COPY Gemfile.lock $APP_HOME/Gemfile.lock RUN bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include" # BundlerでGemをインストール RUN bundle install --path=vendor/bundle # Railsアプリを作成(既存のアプリをマウントする場合は不要) RUN rails new . -d mysql --skip-bundle || bundle update # Webpackerをインストール RUN rails webpacker:install # 設定ファイル書き換え(既存のアプリをマウントする場合は不要) COPY config $APP_HOME/config # マウントできるように公開 VOLUME $APP_HOME/public VOLUME $APP_HOME/tmp # コンテナ起動時にRailsサーバを起動 CMD ["rails", "server"]
Gemfile
ruby
source 'https://rubygems.org' gem 'rails', '6.1.0'
cmd
docker build -t test/rails .
すると
RUN rails webpacker:install
の行でエラーになるようです。
=> ERROR [10/11] RUN rails webpacker:install 0.6s ------ > [10/11] RUN rails webpacker:install: #15 0.557 /bin/sh: 1: rails: not found ------ executor failed running [/bin/sh -c rails webpacker:install]: exit code: 127
###調べたこと
yarnがインストールされていないと同様のエラーになるようですが、dockerfileの最初の方でインストールしています。
何が原因でしょうか?
分かる方教えてくださると幸いです。
まだ回答がついていません
会員登録して回答してみよう