How to deploy Redmine to Heroku

Fatos Morina
Mozaix LLC
Published in
3 min readAug 20, 2017
Img source: redmine.org

Redmine is a flexible project management web application that is open source, written in Ruby on Rails. If you need to start using it for your own projects, then chances are you need to deploy it to a server. In this article, you can see how to deploy the current latest stable version of Redmine to Heroku, as it sometimes can be a bit problematic.

We first need to clone the latest stable version:

git clone https://github.com/redmine/redmine.git -b 3.4-stable

You can find the latest version by looking at the branches at Github.

Then we have to change the directory to the one in which redmine is currently located at:

cd redmine

Then we need to delete certain lines from .gitignore:

Gemfile.lock
Gemfile.local
public/plugin_assets
config/initializers/session_store.rb
config/initializers/secret_token.rb
config/configuration.yml
config/email.yml

Then we need to remove the following block from Gemfile:

database_file = File.join(File.dirname(__FILE__), "config/database.yml")
if File.exist?(database_file)
database_config = YAML::load(ERB.new(IO.read(database_file)).result)
adapters = database_config.values.map {|c| c['adapter']}.compact.uniq
if adapters.any?
adapters.each do |adapter|
case adapter
when 'mysql2'
gem "mysql2", "~> 0.4.6", :platforms => [:mri, :mingw, :x64_mingw]
when /postgresql/
gem "pg", "~> 0.18.1", :platforms => [:mri, :mingw, :x64_mingw]
when /sqlite3/
gem "sqlite3", (RUBY_VERSION < "2.0" && RUBY_PLATFORM =~ /mingw/ ? "1.3.12" : "~>1.3.12"),
:platforms => [:mri, :mingw, :x64_mingw]
when /sqlserver/
gem "tiny_tds", (RUBY_VERSION >= "2.0" ? "~> 1.0.5" : "~> 0.7.0"), :platforms => [:mri, :mingw, :x64_mingw]
gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw, :x64_mingw]
else
warn("Unknown database adapter `#{adapter}` found in config/database.yml, use Gemfile.local to load your own database gems")
end
end
else
warn("No adapter found in config/database.yml, please configure it first")
end
else
warn("Please configure your config/database.yml first")
end

We then need to add the block displayed down below:

group :development, :test do
gem 'sqlite3'
end

group :production do
gem 'pg'
gem 'rails_12factor'
gem 'thin' # change this if you want to use other rack web server
end

Then we need to install these gem files without production:

bundle install --without production test

Our application needs a secret token, which we can generate using the following command:

rake generate_secret_token

We need to create a heroku app:

heroku create APP_NAME

Then we need to avoid aborting when doing the deployment to Heroku, by commenting or removing the following line at config/environment.rb:

exit 1

We then need to add this line config/application.rb:

config.assets.initialize_on_precompile = false

We also need to add a database to this application:

heroku addons:create heroku-postgresql

Now we can commit and push our changes:

git add -A
git commit -m “Prepare Redmine for Heroku deployment”
git push heroku 3.4-stable:master

Notice that the version 3.4 may change at the time when you read this article, so it is probably better for you to get the latest version at GitHub and deploy it.

We also need to run the following rake tasks:

heroku run rake db:migrate
heroku run rake redmine:load_default_data

If we want to login into application, we can use a user that is created in the beginning:
Username: admin
Password: admin

If we want to reset the database, we can use the following:
heroku pg:reset DB_NAME

That’s all we need to do. We can now open the application deployed to Heroku:

heroku open

--

--