hyku icon indicating copy to clipboard operation
hyku copied to clipboard

Docker without dory/proxy 404 error

Open crowesn opened this issue 5 years ago • 7 comments

Descriptive summary

Working off a mirror of https://github.com/samvera/hyku/commit/b93c53, getting 404 error on initial application load after following instructions to un-comment port binding when not using proxy (dory). docker-compose up -d. After the app has started, I get a 404. The error appears to originate in application controller due to no apartments: application controller. I tested this hypothesis by substituting a custom error at that point.

Rationale

Documentation indicates that running docker without dory requires tweak to port binding directive docker-compose.yml. Following those instructions results in 404 error.

Steps to reproduce the behavior

  1. Un-comment port key and binding value in for web container in docker-compose.yml
  2. docker-compose up -d and wait a moment for all services to start
  3. Visit localhost:3000

logs:

dev error log

actioncontroller::routingerror (not found):
  
app/controllers/application_controller.rb:28:in `block in <class:applicationcontroller>'
** [honeybadger] unable to send error report: api key is missing. id=e3f1ac08-7d4c-4aa8-80b8-79c8073bb24d level=3 pid=252
** [honeybadger] unable to send error report: api key is missing. id=4670ed9f-3a8c-4ecc-bc4b-84877fd4caa9 level=3 pid=1
registering local qa authority: resource_types - qa::authorities::local::filebasedauthority
registering local qa authority: licenses - qa::authorities::local::filebasedauthority
registering Local QA authority: rights_statements - Qa::Authorities::Local::FileBasedAuthority
Registering Local QA authority: subjects - Qa::Authorities::Local::TableBasedAuthority
Registering Local QA authority: languages - Qa::Authorities::Local::TableBasedAuthority
Registering Local QA authority: genres - Qa::Authorities::Local::TableBasedAuthority
DEPRECATION WARNING: ActiveSupport.halt_callback_chains_on_return_false= is deprecated and will be removed in Rails 5.2. (called from <top (required)> at /home/app/webapp/config/initializers/new_framework_defaults.rb:17)
  [1m[36mSipity::Role Load (0.4ms)[0m  [1m[34mSELECT  "sipity_roles".* FROM "sipity_roles" WHERE "sipity_roles"."name" = $1 LIMIT $2[0m  [["name", "managing"], ["LIMIT", 1]]
  [1m[35m (0.2ms)[0m  [1m[35mBEGIN[0m
  [1m[35m (0.2ms)[0m  [1m[35mCOMMIT[0m
  [1m[36mSipity::Role Load (0.3ms)[0m  [1m[34mSELECT  "sipity_roles".* FROM "sipity_roles" WHERE "sipity_roles"."name" = $1 LIMIT $2[0m  [["name", "approving"], ["LIMIT", 1]]
  [1m[35m (0.1ms)[0m  [1m[35mBEGIN[0m
  [1m[35m (0.1ms)[0m  [1m[35mCOMMIT[0m
  [1m[36mSipity::Role Load (0.2ms)[0m  [1m[34mSELECT  "sipity_roles".* FROM "sipity_roles" WHERE "sipity_roles"."name" = $1 LIMIT $2[0m  [["name", "depositing"], ["LIMIT", 1]]
  [1m[35m (0.1ms)[0m  [1m[35mBEGIN[0m
  [1m[35m (0.1ms)[0m  [1m[35mCOMMIT[0m
Hyrax::Engine.after_initialize - persisting registered roles!
** [Honeybadger] Initializing Honeybadger Error Tracker for Ruby. Ship it! version=3.1.2 framework=rails level=1 pid=1
** [Honeybadger] Entering development mode: data will not be reported. level=2 pid=1
Started GET "/" for 172.20.0.1 at 2019-06-14 14:12:20 +0000
Cannot render console from 172.20.0.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
  [1m[36mAccount Load (0.9ms)[0m  [1m[34mSELECT  "public"."accounts".* FROM "public"."accounts" WHERE "public"."accounts"."cname" = $1 LIMIT $2[0m  [["cname", "localhost"], ["LIMIT", 1]]
Processing by Hyrax::HomepageController#index as HTML
  [1m[36mCACHE Account Load (0.0ms)[0m  [1m[34mSELECT  "public"."accounts".* FROM "public"."accounts" WHERE "public"."accounts"."cname" = $1 LIMIT $2[0m  [["cname", "localhost"], ["LIMIT", 1]]
Completed 404 Not Found in 114ms (ActiveRecord: 7.3ms)

docker ps output

CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                    NAMES
7a50a721019e        hyku/main:latest             "bundle exec sidekiq"    21 minutes ago      Up 21 minutes       80/tcp, 443/tcp                          gdja_workers_1
4fd5b686e14f        hyku/main:latest             "/sbin/my_init"          21 minutes ago      Up 21 minutes       443/tcp, 0.0.0.0:3000->80/tcp            gdja_web_1
d193f7f6324d        solr                         "docker-entrypoint.s…"   21 minutes ago      Up 21 minutes       8983/tcp                                 gdja_solr_1
53701f754575        hyku/main:latest             "bundle exec rails z…"   21 minutes ago      Up 51 seconds       80/tcp, 443/tcp                          gdja_initialize_app_1
e91a2df589c2        cbeer/fcrepo4:4.7            "catalina.sh run"        21 minutes ago      Up 21 minutes       8080/tcp                                 gdja_fcrepo_1
87e913208bac        zookeeper                    "/docker-entrypoint.…"   21 minutes ago      Up 21 minutes       2181/tcp, 2888/tcp, 3888/tcp, 8080/tcp   gdja_zoo1_1
63eba38fa86b        postgres                     "docker-entrypoint.s…"   21 minutes ago      Up 21 minutes       5432/tcp                                 gdja_db_1
d8ec9d383233        selenium/standalone-chrome   "/opt/bin/entry_poin…"   21 minutes ago      Up 21 minutes       4444/tcp                                 gdja_chrome_1
aae6b173a5eb        hyku/base:latest             "/sbin/my_init"          21 minutes ago      Up 21 minutes       80/tcp, 443/tcp                          gdja_base_1
23a5b3933452        redis:3                      "docker-entrypoint.s…"   21 minutes ago      Up 21 minutes       6379/tcp                                 gdja_redis_1
c4281021bf2e        hyku/main:latest             "/sbin/my_init"          21 minutes ago      Up 21 minutes       80/tcp, 443/tcp                          gdja_app_1

Related work

Related? https://github.com/samvera/hyku/issues/1503

crowesn avatar Jun 14 '19 17:06 crowesn

It looks like when I disable multi-tenancy here the 404 is resolved but of course we are limited to one repo. Also it looks like connection to solr is messed up, etc.

crowesn avatar Jun 14 '19 17:06 crowesn

@crowesn if you skip dory (which acts as a proxy allowing you to have urls like site.hyku.docker and hyku.docker) you have to configure Hyku to match whatever urls you are using. An example (for local dev) would be to to change the following in docker-compose.yml

  - SETTINGS__MULTITENANCY__ADMIN_HOST=lvh.me
  - SETTINGS__MULTITENANCY__ADMIN_ONLY_TENANT_CREATION=false
  - SETTINGS__MULTITENANCY__DEFAULT_HOST=%{tenant}.lvh.me
  - SETTINGS__MULTITENANCY__ENABLED=true

lvh.me is a globally available DNS entry lvh.me that resolves to 127.0.0.1. There are a lot of other ways that this could be configured, I'm not sure it is practical to try and provide instructions for all of them. Because of that we're trying to provide the simplest config as the default. The thing to understand is that myapp.localhost:3000 does not trigger Rails subdomain logic and thus doesn't give you access to the tenants. You need a 3 part domain for that.

orangewolf avatar Jun 15 '19 05:06 orangewolf

I tried changing this as well as settings.yml, but I can't get it to work. I can sign up and sign in by going to http://test.lvh.me:3000/users/sign_up or http://test.lvh.me:3000/users/sign_in. Signing in redirects me to http://test.lvh.me:3000/dashboard?locale=en, where I get a routing error, Not Found.

Is there another place I need to configure something?

eltiffster avatar Jul 02 '19 19:07 eltiffster

@eltiffster it can you post what you have for the settings.yml and in the env? Is test.lvh.me:3000 the admin or is it one of the tenants?

orangewolf avatar Jul 02 '19 20:07 orangewolf

Thanks @orangewolf Currently in settings.yml, I have:

multitenancy:
  enabled: true
  default_host: "%{tenant}.lvh.me"
  admin_host: lvh.me
  admin_only_tenant_creation: true

And in docker-compose.yml I uncommented ports so it looks like

web:
ports:
  - "3000:80"

eltiffster avatar Jul 02 '19 21:07 eltiffster

@eltiffster can I get a full stack trace? also if you'd like to hope in the #hyku channel on the samvera slack I'd be happy to set up a screenshare to see if we can't figure it out.

orangewolf avatar Jul 08 '19 05:07 orangewolf

@orangewolf Here's a screenshot of the full stack trace (at test.lvh.me:3000) routingerror

And here's the development.log:

ActionController::RoutingError (Not Found):
  
app/controllers/application_controller.rb:28:in `block in <class:ApplicationController>'
** [Honeybadger] Unable to send error report: API key is missing. id=46445ab2-c29f-4264-9e55-24b2e3e8a831 level=3 pid=250
Started GET "/" for 172.20.0.1 at 2019-07-08 16:43:19 +0000
Cannot render console from 172.20.0.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
  [1m[36mAccount Load (0.2ms)[0m  [1m[34mSELECT  "public"."accounts".* FROM "public"."accounts" WHERE "public"."accounts"."cname" = $1 LIMIT $2[0m  [["cname", "test.lvh.me"], ["LIMIT", 1]]
Processing by Hyrax::HomepageController#index as HTML
  [1m[36mCACHE Account Load (0.0ms)[0m  [1m[34mSELECT  "public"."accounts".* FROM "public"."accounts" WHERE "public"."accounts"."cname" = $1 LIMIT $2[0m  [["cname", "test.lvh.me"], ["LIMIT", 1]]
  [1m[36mUser Load (0.4ms)[0m  [1m[34mSELECT  "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2[0m  [["id", 1], ["LIMIT", 1]]
Completed 404 Not Found in 12ms (ActiveRecord: 0.0ms)


  
ActionController::RoutingError (Not Found):
  
app/controllers/application_controller.rb:28:in `block in <class:ApplicationController>'
** [Honeybadger] Unable to send error report: API key is missing. id=7c205e8e-7951-4832-8a1f-d01853e6888a level=3 pid=250
Started GET "/" for 172.20.0.1 at 2019-07-08 16:48:23 +0000
Cannot render console from 172.20.0.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
  [1m[36mAccount Load (0.3ms)[0m  [1m[34mSELECT  "public"."accounts".* FROM "public"."accounts" WHERE "public"."accounts"."cname" = $1 LIMIT $2[0m  [["cname", "test.lvh.me"], ["LIMIT", 1]]
Processing by Hyrax::HomepageController#index as HTML
  [1m[36mCACHE Account Load (0.0ms)[0m  [1m[34mSELECT  "public"."accounts".* FROM "public"."accounts" WHERE "public"."accounts"."cname" = $1 LIMIT $2[0m  [["cname", "test.lvh.me"], ["LIMIT", 1]]
  [1m[36mUser Load (0.4ms)[0m  [1m[34mSELECT  "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2[0m  [["id", 1], ["LIMIT", 1]]
Completed 404 Not Found in 13ms (ActiveRecord: 0.0ms)


  
ActionController::RoutingError (Not Found):
  
app/controllers/application_controller.rb:28:in `block in <class:ApplicationController>'
** [Honeybadger] Unable to send error report: API key is missing. id=14f0c87b-7788-474f-856a-889d60c9fa40 level=3 pid=250
Registering Local QA authority: licenses - Qa::Authorities::Local::FileBasedAuthority
Registering Local QA authority: resource_types - Qa::Authorities::Local::FileBasedAuthority
Registering Local QA authority: rights_statements - Qa::Authorities::Local::FileBasedAuthority
Registering Local QA authority: subjects - Qa::Authorities::Local::TableBasedAuthority
Registering Local QA authority: languages - Qa::Authorities::Local::TableBasedAuthority
Registering Local QA authority: genres - Qa::Authorities::Local::TableBasedAuthority
DEPRECATION WARNING: ActiveSupport.halt_callback_chains_on_return_false= is deprecated and will be removed in Rails 5.2. (called from <top (required)> at /home/app/webapp/config/initializers/new_framework_defaults.rb:17)
  [1m[36mSipity::Role Load (0.2ms)[0m  [1m[34mSELECT  "sipity_roles".* FROM "sipity_roles" WHERE "sipity_roles"."name" = $1 LIMIT $2[0m  [["name", "managing"], ["LIMIT", 1]]
  [1m[35m (0.1ms)[0m  [1m[35mBEGIN[0m
  [1m[35m (0.1ms)[0m  [1m[35mCOMMIT[0m
  [1m[36mSipity::Role Load (0.2ms)[0m  [1m[34mSELECT  "sipity_roles".* FROM "sipity_roles" WHERE "sipity_roles"."name" = $1 LIMIT $2[0m  [["name", "approving"], ["LIMIT", 1]]
  [1m[35m (0.1ms)[0m  [1m[35mBEGIN[0m
  [1m[35m (0.1ms)[0m  [1m[35mCOMMIT[0m
  [1m[36mSipity::Role Load (0.2ms)[0m  [1m[34mSELECT  "sipity_roles".* FROM "sipity_roles" WHERE "sipity_roles"."name" = $1 LIMIT $2[0m  [["name", "depositing"], ["LIMIT", 1]]
  [1m[35m (0.1ms)[0m  [1m[35mBEGIN[0m
  [1m[35m (0.1ms)[0m  [1m[35mCOMMIT[0m
Hyrax::Engine.after_initialize - persisting registered roles!
** [Honeybadger] Initializing Honeybadger Error Tracker for Ruby. Ship it! version=3.1.2 framework=rails level=1 pid=399
** [Honeybadger] Entering development mode: data will not be reported. level=2 pid=399

I was actually able to sign up for an account by going to http://test.lvh.me:3000/users/sign_up. But after logging in, I was redirected to test.lvh.me:3000/dashboard, which fails with the same error message as the screenshot above (Routing Error: Not Found).

Thanks for looking into this!

eltiffster avatar Jul 08 '19 16:07 eltiffster