5
4

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 5 years have passed since last update.

IBM Bluemix 上でRedmineを動かすまで(その2: https化, 外部DB化)

Last updated at Posted at 2016-08-27

その1では、Bluemix上でRedmineのコンテナを起動するところまでいきました。
今回は、

  • Letsencryptを利用してHTTPS化
  • Postgresを利用してDBを外部化

したいと思います。
(オレオレ証明書の場合はググればいくらでもやり方が出てくるので省略します。

Letsencryptを利用してHTTPS化

Letsencryptの利用

Get HTTPS for free!を利用して、手動で証明書を取得します。

ここは頑張ってください。

うまくいくと、Step 5: Install Certificate (see below) まで来ます。
その中の、Apache用の設定を見ながら、
スクリーンショット 2016-08-27 12.27.21 PM.png

  • domain.crt
  • intermediate.pem
  • domain.key

を、ローカルの任意のディレクトリに作っておきましょう。

rails, Dockerfileの修正

Dockerfileで適当な場所に上書きするので、上の3つのファイルと、下記の2つのファイルを同じディレクトリに置いておいてください。

redmine/3.3/rails
# !/usr/bin/env ruby

require 'rails/commands/server'
require 'rack'
require 'webrick'
require 'webrick/https'

module Rails
    class Server < ::Rack::Server
        def default_options
             

            super.merge({
                :Port => 3000,
                :environment => (ENV['RAILS_ENV'] || "development").dup,
                :daemonize => false,
                :debugger => false,
                :pid => File.expand_path("tmp/pids/server.pid"),
                :config => File.expand_path("config.ru"),
                :SSLEnable => true,
                :SSLPrivateKey => OpenSSL::PKey::RSA.new(File.read('/usr/src/redmine/ssl/private/domain.key'), ''),
                :SSLCertificate => OpenSSL::X509::Certificate.new(File.read('/usr/src/redmine/ssl/certs/domain.crt')),
                :SSLCACertificateFile => '/usr/src/redmine/ssl/certs/intermediate.pem',
                :SSLCertName => [["CN", WEBrick::Utils::getservername]]
            })
        end
    end
end



APP_PATH = File.expand_path('../../config/application',  __FILE__)
require_relative '../config/boot'
require 'rails/commands'

redmine/3.3/Dockerfile
(前略)
COPY rails /usr/src/redmine/bin
COPY domain.crt /usr/src/redmine/ssl/certs/
COPY intermediate.pem /usr/src/redmine/ssl/certs/
COPY domain.key /usr/src/redmine/ssl/private/
(後略)

Dockerコンテナを作成

$ docker build . あとはtag付けしてpushして起動。

Postgresを利用してDBを外部化

Postgresコンテナの登録、起動

Redmineと同様です。

$ docker pull postgres
$ docker tag postgres registry.ng.bluemix.net/aaaaaaa/postgres
$ docker push registry.ng.bluemix.net/aaaaaaa/postgres

コンテナ起動時に、DBのパスワードを設定します。
スクリーンショット 2016-08-27 1.23.12 PM.png

スクリーンショット 2016-08-27 12.44.22 PM.png

Redmineコンテナの起動

PostgresのローカルIPをコンソールからコピーして、
スクリーンショット 2016-08-27 1.21.04 PM.png

環境変数に設定して起動。
スクリーンショット 2016-08-27 1.01.59 PM.png

うまくいったみたいです。

スクリーンショット 2016-08-27 1.24.11 PM.png
5
4
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
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?