プログラムを中心とした個人的なメモ用のブログです。 タイトルは迷走中。
内容の保証はできませんのであしからずご了承ください。

2021/04/22

ruby の gem install で SSL のエラーが発生する

event_note2021/04/21 23:13

Redmine をプラグインのインストールまで自動化して docker で動かそうとしたら、ruby の gem install で SSL 関係のエラーが出て、かなりはまってしまいました。

試しに作成した Redmine 用の Dockerfiledocker-compose.yml の例は以下です。

Windows (WSL2 + Docker Desktop) だと上手くいきましたが、Ubuntu 20.04 だと bundle install で証明書関係のエラーが出ました。

FROM redmine:4.2

# Git SSL認証チェックを無効にする
ENV GIT_SSL_NO_VERIFY=1

# プロキシ設定
ENV http_proxy=http://example:8080
ENV https_proxy=http://example:8080

# プラグインのダウンロード
RUN git clone --depth 1 https://github.com/pinzolo/redmine_persist_wfmt ./plugins/redmine_persist_wfmt
version: '3.1'
services:
  redmine:
    image: myredmine:4.2
    build: .
    container_name: myredmine
    restart: always
    depends_on:
      - mysql
    ports:
      - 3000:3000
    environment:
      REDMINE_DB_MYSQL: mysql
      REDMINE_DB_PASSWORD: example
      REDMINE_PLUGINS_MIGRATE: "true"
      http_proxy: http://example:8080
      https_proxy: http://example:8080
    volumes:
      - files:/usr/src/redmine/files
  mysql:
    image: mysql:5.7
    container_name: redmine-mysql
    command: mysqld --character-set-server=utf8 --collation-server=utf8_unicode_ci
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: example
      MYSQL_DATABASE: redmine
      http_proxy: http://example:8080
      https_proxy: http://example:8080
    volumes:
      - mysql:/var/lib/mysql
volumes:
  files:
  mysql:

docker-compose up を実行すると以下のエラーが出て止まりました。

myredmine  | Bundler can't satisfy your Gemfile's dependencies.
myredmine  | Install missing gems with `bundle install`.
myredmine  | The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x64-mingw32, x86-mswin32. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32`.
myredmine  | The dependency ffi (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x64-mingw32, x86-mswin32. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32`.
myredmine  | Fetching source index from https://rubygems.org/
myredmine  | Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/

ググると、最新の証明書をインストールしたら解決する的な記事が見つかります。

しかし、私の場合これらでは解決せず、証明書関係をいろいろ見直しても解決せず、途方に暮れていたところ、以下の記事で解決しました。

会社のプロキシ環境下で環境を構築しているのですが、Ubuntu 20.04 では CA 証明書の要求バージョンが上がっており、会社の証明書じゃ弱すぎるためにエラーが出ているっぽいです。

そして、openssl の設定を上記の記事のように変更すると一応回避可能なのですが、それだけではなく、Redmine の docker コンテナ内でも同じように openssl の設定を変更することで、やっとエラーが表示されなくなりました。

いや、めっちゃはまったわ~。