Docker-compose implementation & zpm auto_install

Hi Zammad Community,

I’m currently deploying a custom zpm package using the docker-compose zammad implementation.

My zpm package repo is here. It works fine through rails console when I follow instructions ( Package::Migration.migrate) located here

Actual behavior:

I, [2021-08-17T09:44:40.600853 #22-47388527343980]  INFO -- : Migrating to SettingAddInternalArticleCheck (202104070000001)
== 202104070000001 SettingAddInternalArticleCheck: migrating ==================
== 202104070000001 SettingAddInternalArticleCheck: migrated (0.0014s) =========

I, [2021-08-17T09:45:01.730981 #23-46942811666780]  INFO -- : Can't fetch image for 'nicole.braun@zammad.org' (maybe no avatar available), http code: 422
W, [2021-08-17T09:45:01.884869 #23-46942811666780]  WARN -- : Scoped order is ignored, it's forced to be batch order.
W, [2021-08-17T09:45:02.145175 #23-46942811666780]  WARN -- : Scoped order is ignored, it's forced to be batch order.
I, [2021-08-17T09:45:50.851395 #23-46942811666780]  INFO -- : NOTICE: install '/opt/zammad/db/addon/opensvc/20210813175700_add_org_support_contract.rb' (664)
I, [2021-08-17T09:45:50.851900 #23-46942811666780]  INFO -- : NOTICE: install '/opt/zammad/db/addon/opensvc/20210813180000_add_ticket_customer_priority.rb' (664)
changing settings...
I, [2021-08-17T09:45:54.615967 #32-46963152083300]  INFO -- : Setting.set('models_searchable', ["Chat::Session", "KnowledgeBase::Answer::Translation", "Ticket", "Organization", "User"])
I, [2021-08-17T09:45:55.638607 #32-46963152083300]  INFO -- : Setting.set('es_url', "http://elastic:9200")

  • The problem is that nothing actually run my 2 rb files, so my changes are not sent to the database, and my custom options are not available in zammad

Expected behavior:

  • As zpm packages presents in /opt/zammad/auto_install are automatically installed by the product, I suppose that docker-entrypoint.sh should deals with installation of any zammad addon present. Actually, I’m not sure because I miss knowledge on rails/zammad, so I’m not confident on how this feature should be properly implemented. I would be happy to submit a PR if it is simple enough for me.
  • Does adding a call to something like bundle exec rake db:addons make sense ?
  • How to do it properly ?

Workaround:

  • I suppose that bind mounting my 2 rb scripts into the /opt/zammad/db/migrate folder would do the trick, and rb files would be installed during the bundle exec rake db:migrate but I’m not very sure that it is a clean way to do.

Infos:

  • Used Zammad version: 4.1.x
  • Used Zammad installation type: docker/ansible playbook inspired from zammad docker-compose
  • Operating system: Ubuntu 20.04 LTS
  • Browser + version: Firefox 90.0 (64 bit) / Google Chrome 92.0.4515.107

Thanks for your help

Hi @averon - thanks for your comprehensive writeup. I’m not sure if packages will work in the docker compose setup. However, you can try to apply the following diff:

diff --git a/containers/zammad/docker-entrypoint.sh b/containers/zammad/docker-entrypoint.sh
index 619cbd1..2ac344f 100755
--- a/containers/zammad/docker-entrypoint.sh
+++ b/containers/zammad/docker-entrypoint.sh
@@ -81,6 +81,13 @@ if [ "$1" = 'zammad-init' ]; then
     bundle exec rake db:migrate
   fi

+  # ensure package DB and asset changes are applied
+  if [ -d "${ZAMMAD_DIR}/auto_install/" ]; then
+    echo "Performing package migrations and rebuilding assets..."
+    bundle exec rake zammad:package:migrate
+    bundle exec rake assets:precompile
+  fi
+
   # es config
   echo "changing settings..."
   if [ "${ELASTICSEARCH_ENABLED}" == "false" ]; then

Hi @thorsteneckel - Thanks for your patch, I tried it, and it works fine :ok_hand:

Please find the init container logs below:

I, [2021-08-18T09:14:13.870063 #25-47434909448560]  INFO -- : Can't fetch image for 'nicole.braun@zammad.org' (maybe no avatar available), http code: 422
W, [2021-08-18T09:14:14.032770 #25-47434909448560]  WARN -- : Scoped order is ignored, it's forced to be batch order.
W, [2021-08-18T09:14:14.237975 #25-47434909448560]  WARN -- : Scoped order is ignored, it's forced to be batch order.
I, [2021-08-18T09:14:59.027437 #25-47434909448560]  INFO -- : NOTICE: install '/opt/zammad/db/addon/opensvc/20210813175700_add_org_support_contract.rb' (664)
I, [2021-08-18T09:14:59.027935 #25-47434909448560]  INFO -- : NOTICE: install '/opt/zammad/db/addon/opensvc/20210813180000_add_ticket_customer_priority.rb' (664)
Performing package migrations and rebuilding assets...
I, [2021-08-18T09:15:02.596449 #42-47127785101680]  INFO -- : Setting.set('models_searchable', ["Chat::Session", "KnowledgeBase::Answer::Translation", "Ticket", "Organization", "User"])
Executing all pending package migrations...
I, [2021-08-18T09:15:02.902202 #42-47127785101680]  INFO -- : NOTICE: up package migration '20210813175700_add_org_support_contract.rb'
-- add_column("organizations", "support_contract", :string, {:limit=>255, :null=>true})
   -> 0.0266s
I, [2021-08-18T09:15:03.077055 #42-47127785101680]  INFO -- : Setting.set('app_version', "20210818091503:true")
I, [2021-08-18T09:15:03.116168 #42-47127785101680]  INFO -- : NOTICE: up package migration '20210813180000_add_ticket_customer_priority.rb'
-- add_column("tickets", "customer_priority", :string, {:limit=>255, :null=>true})
   -> 0.0263s
I, [2021-08-18T09:15:03.284683 #42-47127785101680]  INFO -- : Setting.set('app_version', "20210818091503:true")
done.
I, [2021-08-18T09:15:06.885332 #43-47062365493620]  INFO -- : Setting.set('models_searchable', ["Chat::Session", "KnowledgeBase::Answer::Translation", "Ticket", "Organization", "User"])
Yarn executable was not detected in the system.
Download Yarn at https://yarnpkg.com/en/docs/install
changing settings...
I, [2021-08-18T09:15:41.425547 #49-47400149686620]  INFO -- : Setting.set('models_searchable', ["Chat::Session", "KnowledgeBase::Answer::Translation", "Ticket", "Organization", "User"])
I, [2021-08-18T09:15:42.694657 #49-47400149686620]  INFO -- : Setting.set('es_url', "http://elastic:9200")
I, [2021-08-18T09:15:46.240474 #50-47223793023320]  INFO -- : Setting.set('models_searchable', ["Chat::Session", "KnowledgeBase::Answer::Translation", "Ticket", "Organization", "User"])
I, [2021-08-18T09:15:47.204808 #50-47223793023320]  INFO -- : Setting.set('es_index', "zammad")

I don’t know if the yarn warning is important or not ?

I look forward to see your patch merged in the docker-entrypoint.

Please ask if I can help.

Thanks a lot for your time.

Nice. You’re welcome. We’re currently busy with the 5.0 preparations so it would be great if you could support me on creating the pull request over at GitHub :star:

ok, done. PR230

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.