Complete beamer gem adoption
- stop importing beamer during Dockerfile builds - add a "bin/beamer" gemstub - invoke `bin/beamer` explicitly - drop the beamer initializer
This commit is contained in:
@@ -44,11 +44,6 @@ RUN bundle exec bootsnap precompile app/ lib/
|
||||
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
|
||||
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
|
||||
|
||||
|
||||
# Fetch beamer library
|
||||
FROM registry.37signals.com/basecamp/beamer:vfs AS beamer
|
||||
|
||||
|
||||
# Final stage for app image
|
||||
FROM base
|
||||
|
||||
@@ -60,8 +55,6 @@ RUN apt-get update -qq && \
|
||||
# Copy built artifacts: gems, application
|
||||
COPY --from=build /usr/local/bundle /usr/local/bundle
|
||||
COPY --from=build /rails /rails
|
||||
COPY --from=beamer /home/beamer/bin/beamer.so /rails/bin/lib/beamer.so
|
||||
COPY --from=beamer /usr/local/bin/beamer /rails/bin/beamer
|
||||
|
||||
# Run and own only the runtime files as a non-root user for security
|
||||
RUN useradd rails --create-home --shell /bin/bash && \
|
||||
|
||||
@@ -26,17 +26,9 @@ RUN --mount=type=secret,id=GITHUB_TOKEN --mount=type=cache,id=fizzy-devbundle-${
|
||||
cp -a /devbundle/. "$BUNDLE_PATH"/ && \
|
||||
bundle clean --force
|
||||
|
||||
# Fetch beamer library
|
||||
FROM registry.37signals.com/basecamp/beamer:vfs AS beamer
|
||||
|
||||
# Final stage
|
||||
FROM base
|
||||
|
||||
# Copy beamer into /usr/local because /rails is mounted as a volume and will overwrite anything
|
||||
# there.
|
||||
COPY --from=beamer /home/beamer/bin/beamer.so /usr/local/lib/beamer/beamer.so
|
||||
COPY --from=beamer /usr/local/bin/beamer /usr/local/bin/beamer
|
||||
|
||||
# Entrypoint prepares the database
|
||||
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
web: bin/thrust bin/rails server
|
||||
beamer: beamer --debug --directory ./storage/ run --primary ${BEAMER_PRIMARY:-$(hostname)}
|
||||
beamer: bin/beamer --debug --directory ./storage/ run --primary ${BEAMER_PRIMARY:-$(hostname)}
|
||||
migrations: bin/beamer-testbed run-migrations --debug --directory ./storage/
|
||||
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# This file was generated by Bundler.
|
||||
#
|
||||
# The application 'beamer' is installed as part of a gem, and
|
||||
# this file is here to facilitate running it.
|
||||
#
|
||||
|
||||
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
||||
|
||||
require "rubygems"
|
||||
require "bundler/setup"
|
||||
|
||||
load Gem.bin_path("beamer-rails", "beamer")
|
||||
+2
-2
@@ -178,7 +178,7 @@ cmd_run_migrations() {
|
||||
echo "Waiting for beamer to be ready..."
|
||||
|
||||
# Wait for beamer status to succeed
|
||||
while ! beamer $BEAMER_OPTIONS status >/dev/null 2>&1; do
|
||||
while ! bin/beamer $BEAMER_OPTIONS status >/dev/null 2>&1; do
|
||||
echo "Beamer not ready yet, waiting..."
|
||||
sleep 1
|
||||
done
|
||||
@@ -187,7 +187,7 @@ cmd_run_migrations() {
|
||||
sleep 1
|
||||
|
||||
# Check if this is the primary node
|
||||
if beamer $BEAMER_OPTIONS is-primary; then
|
||||
if bin/beamer $BEAMER_OPTIONS is-primary; then
|
||||
echo "This is the primary node, running migrations..."
|
||||
./bin/rails db:prepare
|
||||
echo "Migrations complete!"
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
# 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
|
||||
paths = [
|
||||
Rails.root.join("bin/lib/beamer.so"),
|
||||
Pathname("/usr/local/lib/beamer/beamer.so")
|
||||
]
|
||||
|
||||
paths.each do |beamer_extension_path|
|
||||
if beamer_extension_path.exist?
|
||||
db = SQLite3::Database.new ":memory:"
|
||||
db.enable_load_extension(true)
|
||||
db.load_extension(beamer_extension_path)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user