Skip to content

Environment Variable RELATIVE_URL_ROOT to Specify Web-Root-Path #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from

Conversation

mwaeckerlin
Copy link

Added a new optional environment variable RELATIVE_URL_ROOT allows to specify a webroot path in the url. This fixes #14.

@tianon
Copy link
Member

tianon commented Dec 21, 2017

I'm personally -1 on adding this functionality to the base image. It's not something included in upstream's config file, so I think in this case we ought to instead simply defer to upstream's documentation on the subject: https://www.redmine.org/projects/redmine/wiki/HowTo_Install_Redmine_in_a_sub-URI

@JongleurNin
Copy link
Contributor

FWIW, I'd personally find this useful, and it is an option, after all. As a Redmine admin that isn't a Rails dev, I've wasted a lot of time in the past trying to wrestle with conflicting "upstream" wiki pages to deploy to a sub-URI.

Does this PR work for both the standard tags and the "passenger" series of tags?

@mwaeckerlin
Copy link
Author

mwaeckerlin commented Dec 21, 2017

@tianon: My patch implements exactly what the referenced document writes. There is no way to get it into the docker container other than my patch — except if you really want to manually edit the container after each update, which is nonsense and absolutely not the concept of docker. The concept of docker is to get a working instance directly from the image plus configuration by command line or compose file, i.e. using the environment.

I'd prefer to see my patch in upstream soon. I don't have the time to keep track with your changes here. But since this seems to last for a while, I'll setup the image build for mwaeckerlin/redmine, so you can use image mwaeckerlin/redmine until build here is ready.

@mwaeckerlin
Copy link
Author

sorry, wrong button

@mwaeckerlin mwaeckerlin reopened this Dec 21, 2017
@mwaeckerlin
Copy link
Author

mwaeckerlin commented Dec 21, 2017

@JongleurNin, I tested the normal latest build. It should work for all, since it is the same change following the redmine developper's instructions. Passenger uses the same file that I modified.

@mwaeckerlin
Copy link
Author

@JongleurNin, the first passenger build is ready. You can try from here: https://hub.docker.com/r/mwaeckerlin/redmine/tags/

@mwaeckerlin
Copy link
Author

mwaeckerlin commented Dec 21, 2017

Now my projects run on mwaeckerlin/redmine, version 3.4 without passenger. Please feel free to test the other versions, i.e. passenger.

@tianon
Copy link
Member

tianon commented Dec 21, 2017

I've had success with the following simple Dockerfile:

FROM redmine

RUN { \
		echo; \
		echo 'unless ENV["REDMINE_RELATIVE_URL_ROOT"].to_s.empty?'; \
		echo '  Redmine::Utils::relative_url_root = ENV["REDMINE_RELATIVE_URL_ROOT"]'; \
		echo 'end'; \
	} >> config/environment.rb

Combine that with automated builds (https://docs.docker.com/docker-hub/builds/) and repository links (https://docs.docker.com/docker-hub/builds/#repository-links) and it's reasonably easy to have an up-to-date image built FROM this one with this additional functionality added, so I'm still dubious of whether we should officially support this out-of-the-box.

It'd be really great to get some perspective on this from someone who can represent upstream, but I'm not sure what the best way to go about that would be. 😞

@mwaeckerlin
Copy link
Author

@tianon, that's even a better solution than mine. But there is no reason for not implementing this RUN-command in the official docker image. There is absolutely now drawback, but a huge gain in flexibility. So I suggest to include this command in the official image.

@jouve
Copy link
Contributor

jouve commented Mar 8, 2018

hi,

I got relative url working with this:

# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment',  __FILE__)
map ENV['RAILS_RELATIVE_URL_ROOT'] || '/' do
  run RedmineApp::Application
end

That is how gitlab does it for exemple : https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config.ru#L25

I tested this with webrick and puma.

What is does:

  • RAILS_RELATIVE_URL_ROOT=/prefix make rails generate prefixed urls
  • the config.ru patch makes rack namespace all the routes

@mwaeckerlin
Copy link
Author

Would please anyone be so kind and add this simple feature to the main branch?

There are different ways to do it, any of them would be fine.

@ghost
Copy link

ghost commented Jan 7, 2019

Hi,

I have tested the @mwaeckerlin's and @jouve's method on the latest version of official Redmine image (4.0 passenger), but the passenger daemon still listened for the "/" even if the "config/environment.rb" and "config.ru" are all patched.

Any tips for this? Thanks a lot.

@yosifkit
Copy link
Member

yosifkit commented Jan 8, 2019

Closing since this branch is no longer a suggested change but a separate image.

At this point we don't want to add more custom environment variables that aren't part of normal upstream recommended config. The current upstream recommended ways are documented here: https://www.redmine.org/projects/redmine/wiki/HowTo_Install_Redmine_in_a_sub-URI

@yosifkit yosifkit closed this Jan 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If any way to set sub-uri to /redmine
5 participants