Dockerの学習をしているのですが、Railsでの環境構築が出来ず、行き詰まってしまいました。
実行したコマンド
docker-compose run web rails new . --force --database=mysql
発生したエラー
ffi-1.17.0-aarch64-linux-musl requires rubygems version >= 3.3.22, which is incompatible with the current version, 3.1.6
Could not find gem 'mysql2 (~> 0.5)' in any of the gem sources listed in your Gemfile.
ファイル内容
Gemfile
source 'https://rubygems.org'
gem 'rails', '~> 6.1.0'
Dockerfile
FROM ruby:2.7
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-get update -qq \
&& apt-get install -y nodejs yarn
WORKDIR /app
COPY ./src /app
RUN bundle config --local set path 'vendor/bundle' \
&& bundle install
docker-compose.yml
version: '3'
services:
db:
image: mysql:8.0
command: --default-authentication-plugin=mysql_native_password
volumes:
- ./src/db/mysql_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: password
web:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- ./src:/app
ports:
- "3000:3000"
environment:
RAILS_ENV: development
depends_on:
- db