K.MIURA@OUC

The special secret of making dreams come true can be summarized in four C’s. They are Curiosity, Confidence, Courage, and Constancy. –Walt Disney

Docker上でRedmineを展開する

[基本環境]
  • Ubuntu 18.04
  • Docker 19.03.12
[参考サイト]
[注意]
[Dockerコンテナの展開(ホストOS上で実行)]
  1. docker pull ubuntu:18.04
  2. docker run -itd --privileged -p 80:80/tcp --name redmine ubuntu:18.04
  3. docker exec -it redmine /bin/bash
[コンテナ(redmine)内での手続き]
  1. adduser ubuntu
  2. apt-get update
  3. apt-get upgrade
  4. apt-get install sudo
  5. usermod -G sudo ubuntu
  6. su - ubuntu
  7. sudo apt-get install locales
  8. sudo locale-gen ja_JP.UTF-8
  9. locale -a
    • ja_JP.utf8の存在を確認
  10. sudo apt-get install build-essential zlib1g-dev libssl-dev libreadline-dev
  11. sudo apt-get install libyaml-dev libcurl4-openssl-dev libffi-dev
  12. sudo apt-get install postgresql libpq-dev
  13. sudo apt-get install apache2 apache2-dev
  14. sudo apt-get install imagemagick fonts-takao-pgothic
  15. sudo apt-get install subversion git vim
  16. curl -O https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.5.tar.gz
  17. tar xvf ruby-2.6.5.tar.gz
  18. cd ruby-2.6.5
  19. ./configure --disable-install-doc
  20. make
  21. sudo make install
  22. cd
  23. ruby -v
    • Rubyのバージョンを確認
  24. sudo service postgresql start
  25. sudo -u postgres createuser -P redmine
    • パスワードをredmineと仮定
  26. sudo -u postgres createdb -E UTF-8 -l ja_JP.UTF-8 -O redmine -T template0 redmine
  27. sudo mkdir /var/lib/redmine
  28. sudo chown www-data /var/lib/redmine
  29. sudo -u www-data svn co https://svn.redmine.org/redmine/branches/4.1-stable /var/lib/redmine
  30. cd
  31. vi database-yml.sh
  32. chmod 755 database-yml.sh
  33. sudo ./database-yml.sh
  34. more /var/lib/redmine/config/database.yml
    • ファイルの存在を確認
    • password:にpostgresqlのユーザredmineのパスワードを書く
  35. vi configuration-yml.sh
  36. chmod 755 configuration-yml.sh
  37. sudo ./configuration-yml.sh
  38. more /var/lib/redmine/config/configuration.yml
    • ファイルの存在を確認
  39. cd /var/lib/redmine/config/
  40. sudo chown www-data:www-data database.yml
  41. sudo chown www-data:www-data configuration.yml
  42. cd /var/lib/redmine/
  43. sudo -u www-data bundle install --without development test --path vendor/bundle
  44. sudo -u www-data bin/rake generate_secret_token
  45. sudo -u www-data RAILS_ENV=production bin/rake db:migrate
  46. sudo gem install passenger -N
  47. sudo passenger-install-apache2-module --auto --languages ruby
  48. cd
  49. vi redmine-conf.sh
  50. chmod 755 redmine-conf.sh
  51. sudo ./redmine-conf.sh
  52. more /etc/apache2/conf-available/redmine.conf
    • ファイルの存在を確認
    • 3行目(</Directory>)以降の内容がpassenger-install-apache2-module --snippetの出力結果であることを確認
  53. sudo a2enconf redmine
  54. apache2ctl configtest
  55. sudo service apache2 reload
  56. sudo vi /etc/apache2/sites-enabled/000-default.conf
    • DocumentRootの値を /var/lib/redmine/public に変更
  57. apache2ctl configtest
  58. sudo service apache2 reload
  59. sudo service apache2 start
  60. sudo vi /etc/init.d/redmine-start.sh
  61. sudo chmod 755 /etc/init.d/redmine-start.sh
  62. sudo vi /etc/init.d/redmine-stop.sh
  63. sudo chmod 755 /etc/init.d/redmine-stop.sh
  64. sudo service postgresql stop
  65. sudo service apache2 stop
  66. exit
  67. exit
[Dockerイメージの生成(ホストOS上で実行)]
  1. docker stop redmine
  2. docker commit redmine ubuntu1804:redmine
[DockerイメージからRedmineを展開(ホストOS上で実行)]
  1. docker run -itd --privileged -p 8080:80 --name sample ubuntu1804:redmine
  2. docker exec sample /etc/init.d/redmine-start.sh
[Redmineコンテナの停止]
  1. docker exec sample /etc/init.d/redmine-stop.sh
  2. docker stop sample
[Redmineコンテナの起動]
  1. docker start sample
  2. docker exec sample /etc/init.d/redmine-start.sh
[Redmineの起動を確認]
  1. 手元PCのウェブブラウザで http://RedmineのIPアドレス:8080/ に接続する

Share