Running rake:assets:precompile without database


  • Used Zammad version: 3.7.0
  • Used Zammad installation source: source
  • Operating system: NixOS


I’m trying to package Zammad for NixOS. This is a stateless distribution, and it uses a sandbox for building. I have only weak Ruby skills. I’ll need to package it in such a way that the app is in a certain folder with the compiled assets and all application state is in e.g. /var/lib/zammad.

I got as far building the gemset, and I’m now trying to precompile the assets. The problem is that packages are built in a network-less sandbox.

when I run

cp config/database/database.yml config/database.yml
bundle exec rake rake:assets:precompile RAILS_ENV=production NODE_ENV=production

it errors out, wanting to connect to PostgreSQL.

How can I make it skip the DB connection?

I found support for NullDB, but when I set the database adapter to nulldb, I get this error

You can’t skip the database connection.
It’s deeply soldered in the application to ensure everything is up and running that’s needed.

@MrGeneration Isn’t it a bit strange to require database connection to compile some javascript?


Well I get what you’re aiming at, but sorry, that’s not my cup of tea.
I can’t tell if there’s a good reason for it. :man_shrugging:

Maybe @thorsteneckel can.

As mentioned before this is default Rails behaviour and not directly related to Zammads codebase.

I googled for a minute and found a straight forward workaround:

  1. Added this gem to the Gemfile
gem "activerecord-nulldb-adapter"
  1. Modified the assets precompile command to look like this:
bundle exec rake DATABASE_URL=nulldb://user:pass@ assets:precompile

We can take part 1 into the core to reduce the zammad-docker and zammad-docker-compose setup time.

However, our resources are limited. Since this is a pretty low hanging fruit contributions from the community are very welcome.

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