環境下ではインターネットに直接接続できないため、以下のような形でインストールをすることになります。
- 別の端末でrack-corsをダウンロード
- Redmine環境に送信
- インストール
- CORS設定
- 再起動
上記1については以下のURLから.gemをダウンロードしました。
"gem list"でリストに表示されていることが確認できています。
RubyGemsサイト
3のインストール手順については以下です。
gemインストール手順
ただ起動するとエラーになります。
The Gemfile's dependencies are satisfied
Your Gemfile lists the gem puma (< 6.0.0) more than once.
You should probably keep only one of them.
Remove any duplicate entries and specify the gem only once.
While it's not a problem now, it could cause errors if you change the version of one of them later.
The Gemfile's dependencies are satisfied
rake aborted!
NameError: uninitialized constant Rack::Cors
/usr/src/redmine/config/initializers/cors.rb:1:in `<top (required)>'
/usr/local/bundle/gems/railties-6.1.7/lib/rails/engine.rb:681:in `block in load_config_initializer'
/usr/local/bundle/gems/activesupport-6.1.7/lib/active_support/notifications.rb:205:in `instrument'
/usr/local/bundle/gems/railties-6.1.7/lib/rails/engine.rb:680:in `load_config_initializer'
/usr/local/bundle/gems/railties-6.1.7/lib/rails/engine.rb:634:in `block (2 levels) in <class:Engine>'
/usr/local/bundle/gems/railties-6.1.7/lib/rails/engine.rb:633:in `each'
/usr/local/bundle/gems/railties-6.1.7/lib/rails/engine.rb:633:in `block in <class:Engine>'
/usr/local/bundle/gems/railties-6.1.7/lib/rails/initializable.rb:32:in `instance_exec'
/usr/local/bundle/gems/railties-6.1.7/lib/rails/initializable.rb:32:in `run'
/usr/local/bundle/gems/railties-6.1.7/lib/rails/initializable.rb:61:in `block in run_initializers'
/usr/local/bundle/gems/railties-6.1.7/lib/rails/initializable.rb:50:in `each'
/usr/local/bundle/gems/railties-6.1.7/lib/rails/initializable.rb:50:in `tsort_each_child'
/usr/local/bundle/gems/railties-6.1.7/lib/rails/initializable.rb:60:in `run_initializers'
/usr/local/bundle/gems/railties-6.1.7/lib/rails/application.rb:391:in `initialize!'
/usr/src/redmine/config/environment.rb:16:in `<top (required)>'
/usr/local/bundle/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
/usr/local/bundle/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
/usr/local/bundle/gems/railties-6.1.7/lib/rails/application.rb:367:in `require_environment!'
/usr/local/bundle/gems/railties-6.1.7/lib/rails/application.rb:533:in `block in run_tasks_blocks'
Tasks: TOP => db:migrate => db:load_config => environment
(See full trace by running task with --trace)
環境はDockerDesktopです。
Dockerfileは以下内容です。
4のCORS設定は"cors.rb"ファイルです。
FROM redmine:latest
# CORS
RUN apt-get update -y
RUN apt-get install git vim unzip -y
WORKDIR /usr/src/redmine/
# install lib for CORS.
COPY ./rack-cors-1.1.1.gem /root/
RUN gem install --local /root/rack-cors-1.1.1.gem
# CORS setting.
RUN { \
echo "Rails.application.config.middleware.insert_before 0, Rack::Cors do"; \
echo " allow do"; \
echo " origins '*'" ; \
echo " resource '*', headers: :any, methods: [:get, :post, :patch, :put, :options]" ; \
echo " end" ; \
echo "end" ; \
echo; \
} >> /root/cors.rb
RUN cp /root/cors.rb ./config/initializers/