0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Rails】DockerでRails6起動時のエラー:An error occurred while installing mimemagic (0.3.9), and Bundler cannot continue.

Posted at

個人メモです。

DockerでRubyのAlpineイメージを使って、Rails6を起動使用とした時に以下のエラーが発生。

An error occurred while installing mimemagic (0.3.9), and Bundler cannot continue.

Bundler could not find compatible versions for gem "mimemagic":
  In Gemfile:
    mimemagic (~> 0.4.0)

    rails (~> 6.0.3, >= 6.0.3.4) was resolved to 6.0.3.4, which depends on
      activestorage (= 6.0.3.4) was resolved to 6.0.3.4, which depends on
        marcel (~> 0.3.1) was resolved to 0.3.3, which depends on
          mimemagic (~> 0.3.2)

mimemagicというパッケージでエラーが発生している。


##対処法

RubyのAlpineイメージではなく、普通のRubyイメージを使う。

DockerfileのFROM ruby:3.0.0-alpine3.13apk の組み合わせを、ruby3.0.0apt-getに変更。

dockerfile
FROM ruby:3.0.0

RUN apt-get update -qq && apt-get install -y nodejs postgresql-client

# yamlをインストール
RUN apt-get update && apt-get install -y curl apt-transport-https wget && \
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 && apt-get install -y yarn

RUN mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
COPY . /myapp

#コンテナ起動時に毎回実行される処理
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000

#イメージからコンテナを作る(run)時に実行する処理
CMD ["rails", "server", "-b", "0.0.0.0"]
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?