From e99878315559c2dac68030f7e707179f6faae2fb Mon Sep 17 00:00:00 2001 From: Kevin McConnell Date: Thu, 5 Jun 2025 11:54:12 +0100 Subject: [PATCH] Use VFS-based Beamer --- Dockerfile | 2 +- config/database.yml | 2 +- config/deploy.staging.yml | 2 +- config/initializers/beamer.rb | 19 +++++++++++++++++++ 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 config/initializers/beamer.rb diff --git a/Dockerfile b/Dockerfile index 64436b2bd..e2308f371 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,7 +39,7 @@ RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile # Fetch beamer library -FROM basecamp/beamer:latest AS beamer +FROM basecamp/beamer:vfs AS beamer # Final stage for app image diff --git a/config/database.yml b/config/database.yml index 0ab08729c..1dd1481c7 100644 --- a/config/database.yml +++ b/config/database.yml @@ -40,7 +40,7 @@ test: production: &production primary: <<: *default - database: storage/tenants/<%= Rails.env %>/%{tenant}/db/main.sqlite3 + database: file:storage/tenants/<%= Rails.env %>/%{tenant}/db/main.sqlite3?vfs=beamer tenanted: true extensions: - ./bin/lib/beamer.so diff --git a/config/deploy.staging.yml b/config/deploy.staging.yml index 61c673377..efb8d36c7 100644 --- a/config/deploy.staging.yml +++ b/config/deploy.staging.yml @@ -21,7 +21,7 @@ env: RAILS_ENV: staging x-beamer-accessory: &beamer-accessory - image: basecamp/beamer + image: basecamp/beamer:vfs registry: username: bcbot password: diff --git a/config/initializers/beamer.rb b/config/initializers/beamer.rb new file mode 100644 index 000000000..9bc841182 --- /dev/null +++ b/config/initializers/beamer.rb @@ -0,0 +1,19 @@ +# This is a temporary shim to load the Beamer VFS prior to opening the tenanted +# databases that use it. +# +# It's here to get around the fact that the VFS needs to be registed before the +# databases are opened, so we can't rely on the normal extension loading to do +# it. +# +# We'll move this responsibility into a Beamer gem soon, at which point this +# file will be removed. + +Rails.application.config.after_initialize do + beamer_extension_path = Rails.root.join("bin/lib/beamer.so") + + if beamer_extension_path.exist? + db = SQLite3::Database.new ":memory:" + db.enable_load_extension(true) + db.load_extension(beamer_extension_path) + end +end