# Running rake:assets:precompile without database

**URL:** <https://community.zammad.org/t/running-rakeprecompile-without-database/6026>\
**Category:** Technical assistance\
**Created:** [January 12, 2021, 1:06pm UTC](https://community.zammad.org/t/running-rakeprecompile-without-database/6026 "2021-01-12T13:06:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![wmertens](https://community.zammad.org/user_avatar/community.zammad.org/wmertens/32/3701_2.png) [@wmertens](https://community.zammad.org/u/wmertens)\
**Post date:** [January 12, 2021, 1:06pm UTC](https://community.zammad.org/t/running-rakeprecompile-without-database/6026/1 "2021-01-12T13:06:46Z")

</div>

### Infos:

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

### Problem:

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?

---

<div class="post-metadata">

**Author:** ![wmertens](https://community.zammad.org/user_avatar/community.zammad.org/wmertens/32/3701_2.png) [@wmertens](https://community.zammad.org/u/wmertens)\
**Post date:** [January 12, 2021, 1:42pm UTC](https://community.zammad.org/t/running-rakeprecompile-without-database/6026/2 "2021-01-12T13:42:56Z")

</div>

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

> <https://github.com/nulldb/nulldb/blob/master/lib/nulldb/core.rb#L15>

---

<div class="post-metadata">

**Author:** ![MrGeneration](https://community.zammad.org/user_avatar/community.zammad.org/mrgeneration/32/9260_2.png) [@MrGeneration](https://community.zammad.org/u/MrGeneration)\
**Post date:** [February 5, 2021, 8:19am UTC](https://community.zammad.org/t/running-rakeprecompile-without-database/6026/3 "2021-02-05T08:19:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![garbas](https://community.zammad.org/user_avatar/community.zammad.org/garbas/32/3888_2.png) [@garbas](https://community.zammad.org/u/garbas)\
**Post date:** [February 22, 2021, 10:57pm UTC](https://community.zammad.org/t/running-rakeprecompile-without-database/6026/4 "2021-02-22T22:57:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![MrGeneration](https://community.zammad.org/user_avatar/community.zammad.org/mrgeneration/32/9260_2.png) [@MrGeneration](https://community.zammad.org/u/MrGeneration)\
**Post date:** [April 4, 2021, 4:24pm UTC](https://community.zammad.org/t/running-rakeprecompile-without-database/6026/5 "2021-04-04T16:24:27Z")

</div>

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. 🤷‍♂️

Maybe @anon29869905 can.

---

<div class="post-metadata">

**Author:** ![anon29869905](https://community.zammad.org/letter_avatar_proxy/v4/letter/a/b782af/32.png) [@anon29869905](https://community.zammad.org/u/anon29869905)\
**Post date:** [April 9, 2021, 12:05pm UTC](https://community.zammad.org/t/running-rakeprecompile-without-database/6026/6 "2021-04-09T12:05:24Z")

</div>

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](http://www.carlos-roque.com/2020/12/09/assets-precompile-without-a-database-in-rails-4-and-5/):

1. Added this gem to the Gemfile

```auto
gem "activerecord-nulldb-adapter"

```

1. Modified the assets precompile command to look like this:

```auto
bundle exec rake DATABASE_URL=nulldb://user:pass@127.0.0.1/dbname assets:precompile

```

We can take part 1 into the core to reduce the [zammad-docker](https://github.com/zammad/zammad-docker/blob/b16ae60cb9961c9576718af5fb67d7f1b64a2c47/install-zammad.sh#L76) and [zammad-docker-compose](https://github.com/zammad/zammad-docker-compose/blob/8eadbd39a1233d527dd6210667e0451e8eec221b/containers/zammad/setup.sh#L33) setup time.

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

---

<div class="post-metadata">

**Author:** ![system](https://community.zammad.org/uploads/default/original/1X/5c5afaea2d23f811dbec33cd4edb02fa29d3262f.png) [@system](https://community.zammad.org/u/system)\
**Post date:** [August 7, 2021, 12:05pm UTC](https://community.zammad.org/t/running-rakeprecompile-without-database/6026/7 "2021-08-07T12:05:26Z")

</div>

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