btey / openproject-gitlab-integration

OpenProject module for integration with Gitlab
GNU General Public License v3.0
84 stars 18 forks source link

NameError while building Docker container (DB migrations?) #3

Closed aleuffre closed 2 years ago

aleuffre commented 2 years ago

Hello!

First of all, thanks so much for this addon, it's so incredibly useful.

I tried installing the new 2.0.0 version. I've installed OpenProject using the configuration provided here: https://github.com/opf/openproject-deploy/tree/stable/12

I've installed version 1 of this plugin following the instruction in OpenProject's documentation:

This all works well enough. However, doing the same thing with version 2 (just updating the "ref" in Gemfile.plugins), I get the following error during docker-compose build, specifically during the execution of postinstall.sh:

waiting for server to start.... done
server started
CREATE DATABASE
CREATE ROLE
GRANT
rake aborted!
NameError: uninitialized constant Cron::ClearOldMergeRequestsJob
Did you mean?  Cron::ClearOldPullRequestsJob
/app/vendor/bundle/ruby/2.7.0/bundler/gems/openproject-gitlab-integration-68ea542fd509/lib/open_project/gitlab_integration/engine.rb:96:in `block in <class:Engine>'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:427:in `instance_exec'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:427:in `block in make_lambda'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:604:in `block (2 levels) in default_terminator'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:603:in `catch'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:603:in `block in default_terminator'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:199:in `block in halting'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:512:in `block in invoke_before'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:512:in `each'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:512:in `invoke_before'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:105:in `run_callbacks'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/reloader.rb:88:in `prepare!'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/application/finisher.rb:124:in `block in <module:Finisher>'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:32:in `instance_exec'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:32:in `run'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:61:in `block in run_initializers'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:60:in `run_initializers'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/application.rb:391:in `initialize!'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/railtie.rb:207:in `public_send'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/railtie.rb:207:in `method_missing'
/app/config/environment.rb:34:in `<top (required)>'
/app/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `block in require'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:299:in `load_dependency'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/application.rb:367:in `require_environment!'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/application.rb:533:in `block in run_tasks_blocks'
/app/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
/usr/local/bundle/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/usr/local/bundle/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/usr/local/bundle/bin/bundle:23:in `load'
/usr/local/bundle/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate => db:load_config => environment
(See full trace by running task with --trace)
The command '/bin/sh -c ./docker/prod/setup/postinstall.sh' returned a non-zero code: 1

Thank you for your help!

btey commented 2 years ago

Hi @aleuffre

Doing some research this error message appears in different cases not all related with the migration process. Because your installation is docker-based, have you had the opportunity to read this point (https://www.openproject.org/docs/installation-and-operations/installation/docker/#openproject-plugins) of the official OpenProject documentation? It looks like "the docker image itself does not support plugins. But you can create your own docker image to include plugins." Are you using the original docker image, or have you created your own?

Regards, Ben

aleuffre commented 2 years ago

Hello!

That page is exactly the page I was referencing, I've followed those instructions for installing both v1 and v2 of the gitlab-integration plugin. I'm getting the error I described above on step 4 of that process, while executing docker build of the Dockerfile I've created.

Specifically, it's the last line in the Dockerfile that fails: RUN ./docker/prod/setup/postinstall.sh

And looking at https://github.com/opf/openproject/tree/dev/docker/prod/setup postinstall.sh,

I'm not 100% sure, but I think the error happens specifically during this line:

https://github.com/opf/openproject/blob/5ce73a8dace4408fd3074e0d328a19e966611151/docker/prod/setup/postinstall-common.sh#L24

But I also tried not doing postinstall.sh, i.e. commenting the last line of the dockerfile. Once again, with v1 this works fine, but with v2 I get the exact same error when I try to start openproject with docker-compose up.

seeder_1  | -----> Setting PGVERSION=13 PGBIN=/usr/lib/postgresql/13/bin PGCONF_FILE=/etc/postgresql/13/main/postgresql.conf
seeder_1  | Executing database migration and database seed...
web_1     | => Booting Puma
web_1     | => Rails 6.1.4.1 application starting in production 
web_1     | => Run `bin/rails server --help` for more startup options
seeder_1  | rake aborted!
seeder_1  | NameError: uninitialized constant Cron::ClearOldMergeRequestsJob
seeder_1  | Did you mean?  Cron::ClearOldPullRequestsJob
seeder_1  | /app/vendor/bundle/ruby/2.7.0/bundler/gems/openproject-gitlab-integration-68ea542fd509/lib/open_project/gitlab_integration/engine.rb:96:in `block in <class:Engine>'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:427:in `instance_exec'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:427:in `block in make_lambda'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:604:in `block (2 levels) in default_terminator'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:603:in `catch'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:603:in `block in default_terminator'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:199:in `block in halting'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:512:in `block in invoke_before'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:512:in `each'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:512:in `invoke_before'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/callbacks.rb:105:in `run_callbacks'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/reloader.rb:88:in `prepare!'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/application/finisher.rb:124:in `block in <module:Finisher>'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:32:in `instance_exec'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:32:in `run'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:61:in `block in run_initializers'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:60:in `run_initializers'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/application.rb:391:in `initialize!'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/railtie.rb:207:in `public_send'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/railtie.rb:207:in `method_missing'
seeder_1  | /app/config/environment.rb:34:in `<top (required)>'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `block in require'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:299:in `load_dependency'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `require'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/application.rb:367:in `require_environment!'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.1/lib/rails/application.rb:533:in `block in run_tasks_blocks'
seeder_1  | /app/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
seeder_1  | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
seeder_1  | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
seeder_1  | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
seeder_1  | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
seeder_1  | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
seeder_1  | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
seeder_1  | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
seeder_1  | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
seeder_1  | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
seeder_1  | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
seeder_1  | /usr/local/bundle/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
seeder_1  | /usr/local/bundle/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
seeder_1  | /usr/local/bundle/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
seeder_1  | /usr/local/bundle/bin/bundle:23:in `load'
seeder_1  | /usr/local/bundle/bin/bundle:23:in `<main>'
seeder_1  | Tasks: TOP => db:migrate => db:load_config => environment
seeder_1  | (See full trace by running task with --trace)

Thanks for any help!

yanx1990 commented 2 years ago

Hi, I confirm I have exactly the same issue ... Could be nice to find a way to make it working :/.

btey commented 2 years ago

I have released a new version v2.0.1 just for OpenProject 12 (v12.0.7) with some fixes needed for this last version (do not use with OpenProject 11).

I haven't had time to test a Docker based scenario. In short, in a manual installation scenario, the steps to add the plugin are:

I hope this helps.

Regards, Ben

aleuffre commented 2 years ago

Tried a new installation over OpenProject 12.0.7. Similar issue:

waiting for server to start.... done
server started
CREATE DATABASE
CREATE ROLE
GRANT
rake aborted!
NameError: uninitialized constant Cron::ClearOldMergeRequestsJob
Did you mean?  Cron::ClearOldPullRequestsJob
/app/vendor/bundle/ruby/2.7.0/bundler/gems/openproject-gitlab-integration-fe4eb8ba638e/lib/open_project/gitlab_integration/engine.rb:96:in `block in <class:Engine>'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/callbacks.rb:427:in `instance_exec'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/callbacks.rb:427:in `block in make_lambda'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/callbacks.rb:604:in `block (2 levels) in default_terminator'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/callbacks.rb:603:in `catch'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/callbacks.rb:603:in `block in default_terminator'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/callbacks.rb:199:in `block in halting'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/callbacks.rb:512:in `block in invoke_before'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/callbacks.rb:512:in `each'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/callbacks.rb:512:in `invoke_before'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/callbacks.rb:105:in `run_callbacks'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/reloader.rb:88:in `prepare!'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/application/finisher.rb:124:in `block in <module:Finisher>'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/initializable.rb:32:in `instance_exec'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/initializable.rb:32:in `run'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/initializable.rb:61:in `block in run_initializers'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/initializable.rb:60:in `run_initializers'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/application.rb:391:in `initialize!'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/railtie.rb:207:in `public_send'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/railtie.rb:207:in `method_missing'
/app/config/environment.rb:34:in `<top (required)>'
/app/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/dependencies.rb:332:in `block in require'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/dependencies.rb:299:in `load_dependency'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/dependencies.rb:332:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/application.rb:367:in `require_environment!'
/app/vendor/bundle/ruby/2.7.0/gems/railties-6.1.4.4/lib/rails/application.rb:533:in `block in run_tasks_blocks'
/app/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
/usr/local/bundle/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/usr/local/bundle/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/usr/local/bundle/bin/bundle:23:in `load'
/usr/local/bundle/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate => db:load_config => environment
(See full trace by running task with --trace)
The command '/bin/sh -c ./docker/prod/setup/postinstall.sh' returned a non-zero code: 1
btey commented 2 years ago

After investigating the matter and performing various tests building the docker image following the documentation, these are the conclusions.

The process to build the image uses the OpenProject Community 12 image as a base. Simply add the Gemfile.plugins file so that during the construction of the final image the Gemfile.pluging file is included and the plugin code is added inside the image in an unknown path. In practice, we don't need to know the path, because it should work the same way. And then the plugin assets are precompiled.

However, the plugin code seems to be included in a separate path which requires adding more headers like "require ..." because it is not able to find some files, this is the meaning of the error we are getting.

The first test was adding to the file "lib/open_project/gitlab_integration/engine.rb":

require_relative '../../../app/workers/cron/clear_old_merge_requests_job'

With that the first error disappear, but then another error appeared which required adding this other line:

require_relative '../../../lib/api/v3/gitlab_merge_requests/gitlab_merge_requests_by_work_package_api'

And then another error appeared, and so on...:

NameError: uninitialized constant API::OpenProjectAPI

The Github integration plugin is included with the main OpenProject code. The code of the Gitlab plugin is based on that same code, and it works correctly if the code is put in an equivalent path as Github. In theory it should not be necessary to add these "require", but this docker image was constructed working with a different way. I'll try to open a ticket to the OpenProject team in case they can shed more light. But for now, I don't see the correct way to use the base docker image provided by OpenProject.

The other option is build a new custom docker image of OpenProject (not using the image provided by OpenProject), using the source code of OpenProject, adding the source of the plugin in the same place as Github plugin, and setting up the required services inside the docker to run an instance of OpenProject. It's a lot more work but it won't be a black box for you.

aleuffre commented 2 years ago

I'm incredibly grateful you went through all that effort, you didn't have to but you did anyway, that's awesome! Thanks so much.

I'll give your suggestions a try as soon as I can, and report back.

aleuffre commented 2 years ago

The other option is build a new custom docker image of OpenProject (not using the image provided by OpenProject), using the source code of OpenProject, adding the source of the plugin in the same place as Github plugin, and setting up the required services inside the docker to run an instance of OpenProject. It's a lot more work but it won't be a black box for you.

I'm glad to report that this worked.

  1. I cloned https://github.com/opf/openproject/ (branch stable/12)
  2. I made the necessary changes to install the plugin as per documentation, and committed (that's necessary to pass a check later)
    • Of note, I had to make another modification to the Gemfile.lock that's not listed in the Readme: I had to add the name of the plugin in the DEPENDENCIES section. Lines 1061-1063:
      openproject-github_integration!
      openproject-gitlab_integration!
      openproject-job_status!
  3. I moved the Dockerfile from docker/prod/Dockerfile to the root of the directory and built it.
  4. I used the container I just built, instead of openproject/community:12 (with docker image tag)

I haven't had the chance to really test it and put it to good use, but it installed fine with no errors so far.

If this could be interesting/useful for people, I would be happy to provide more detailed documentation and maybe even a .patch file to git apply on the base repo for easier maintainability.

btey commented 2 years ago

I'm so glad it worked for you. Surely the information you can provide will be useful for others who come here.

Thank you very much!

oliverguenther commented 2 years ago

Hi @btey ,

I think that this is related to https://github.com/opf/openproject/pull/10095, which was an error in our eager loading of bundle-provided paths, as they were being removed from eager loading even if they were a plugin/engine that should have eager loading active.

Best Oliver

btey commented 2 years ago

Hi @oliverguenther

If I haven't seen it wrong I think that this change is not part of the current release 12.0.7, right? Will it be available in the next version 12.0.8? It is just to be aware and test the operation with the next version.

Thank you very much! Ben

oliverguenther commented 2 years ago

Hi Ben,

you're absolutely right, this is targeting dev and will not be of much help for the current stable releases. I backported the changes to the next patch release (12.0.8), which however is not released yet.

Best Oliver

aleuffre commented 2 years ago

Hello,

I tried building the Dockerfile from dev instead of 12.0.7, to see if the issue was fixed. I have a different error during the compilation phase, but it seems promising at least.

Dockerfile:

FROM openproject/community:dev
COPY Gemfile.plugins /app/
RUN bundle config unset deployment && bundle install && bundle config set deployment 'true'
RUN ./docker/prod/setup/postinstall.sh

Gemfile.plugins

group :opf_plugins do
  gem "openproject-gitlab_integration", git: "https://github.com/btey/openproject-gitlab-integration.git", ref: "3763aa2562afee8a2a59d2739d60650515d5e15f"
end

Log of docker build:

Error: src/app/features/plugins/linked-plugins.module.ts:50:14 - error NG6002: Appears in the NgModule.imports of OpenProjectModule, but itself has errors

50 export class LinkedPluginsModule { }
                ~~~~~~~~~~~~~~~~~~~

Error: src/app/features/plugins/linked/openproject-gitlab_integration/main.ts:66:5 - error NG6001: The class 'TabMrsComponent' is listed in the declarations of the NgModule 'PluginModule', but is not a directive, a component, or a pipe. Either remove it from the NgModule's declarations, or add an appropriate Angular decorator.

66     TabMrsComponent,
       ~~~~~~~~~~~~~~~

  src/app/features/plugins/linked/openproject-gitlab_integration/tab-mrs/tab-mrs.component.ts:43:14
    43 export class TabMrsComponent implements OnInit {
                    ~~~~~~~~~~~~~~~
    'TabMrsComponent' is declared here.

Error: src/app/features/plugins/linked/openproject-gitlab_integration/main.ts:79:14 - error NG6002: Appears in the NgModule.imports of LinkedPluginsModule, but itself has errors

79 export class PluginModule {
                ~~~~~~~~~~~~

Error: src/app/features/plugins/linked/openproject-gitlab_integration/tab-mrs/tab-mrs.component.ts:36:9 - errorm TS2724: '"core-app/core/apiv3/api-v3.service"' has no exported member named 'APIV3Service'. Did you mean 'ApiV3Service'?

36 import {APIV3Service} from "core-app/core/apiv3/api-v3.service";
           ~~~~~~~~~~~~

  src/app/core/apiv3/api-v3.service.ts:66:14
    66 export class ApiV3Service {
                    ~~~~~~~~~~~~
    'ApiV3Service' is declared here.

Error: src/app/features/plugins/linked/openproject-gitlab_integration/tab-mrs/tab-mrs.component.ts:43:14 - error NG6003: Appears in the NgModule.exports of PluginModule, but could not be resolved to an NgModule, Component, Directive, or Pipe class.

Is it missing an Angular annotation?

43 export class TabMrsComponent implements OnInit {
                ~~~~~~~~~~~~~~~

Error: src/app/features/plugins/linked/openproject-gitlab_integration/tab-mrs/tab-mrs.component.ts:50:14 - error NG2003: No suitable injection token for parameter 'apiV3Service' of class 'TabMrsComponent'.
  Consider using the @Inject decorator to specify an injection token.

50     readonly apiV3Service:APIV3Service,
                ~~~~~~~~~~~~

  src/app/features/plugins/linked/openproject-gitlab_integration/tab-mrs/tab-mrs.component.ts:50:27
    50     readonly apiV3Service:APIV3Service,
                                 ~~~~~~~~~~~~
    This type does not have a value, so it cannot be used as injection token.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! openproject-frontend@0.1.0 build: `node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng build --configuration production --named-chunks --extract-css --source-map`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the openproject-frontend@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-02-20T13_01_08_700Z-debug.log
rake aborted!
Failed to compile angular frontend: 1
/app/lib/tasks/assets.rake:70:in `block (4 levels) in <top (required)>'
/app/lib/tasks/assets.rake:69:in `block (3 levels) in <top (required)>'
/app/lib/tasks/assets.rake:68:in `chdir'
/app/lib/tasks/assets.rake:68:in `block (2 levels) in <top (required)>'
/app/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
/usr/local/bundle/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/usr/local/bundle/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/usr/local/bundle/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/usr/local/bundle/bin/bundle:23:in `load'
/usr/local/bundle/bin/bundle:23:in `<main>'
Tasks: TOP => assets:precompile => assets:compile_environment => assets:prepare_op => assets:angular
(See full trace by running task with --trace)
The command '/bin/sh -c ./docker/prod/setup/postinstall.sh' returned a non-zero code: 1
oliverguenther commented 2 years ago

@aleuffre You need to base your image on 12.0.7 tag, not dev. Please note that the two versions are not database compatible. The alternative would be to provide a dev compatible version of this plugin, but you shouldn't run dev as your production system.

aleuffre commented 2 years ago

@aleuffre You need to base your image on 12.0.7 tag, not dev. Please note that the two versions are not database compatible. The alternative would be to provide a dev compatible version of this plugin, but you shouldn't run dev as your production system.

Thanks for the warning, but I wasn't planning on running it in production. I was just testing to see if the image would build with the changes that would be coming to 12.0.8, or if it was still worthwhile to document all the steps necessary to install the plugin using Docker.

btey commented 2 years ago

Hi @aleuffre

Thank you very much for your time, documentation and PR. Fortunately these changes are no longer necessary. With @oliverguenther's PR changes to the OpenProject code are no longer necessary. And with the latest version 12.0.8, the steps in the official OpenProject documentation to generate a Docker with the plugin (https://www.openproject.org/docs/installation-and-operations/installation/docker/#openproject-plugins) already works correctly. I just generated a Docker image with the plugin without errors following these steps.

I will just update the Readme in the master branch simply by referring to the OpenProject documentation. In future versions it may be necessary to make a slight change when "APIV3Service" changes to "ApiV3Service".

Thanks everyone for your help!!