From 81ffe855fdccf7a0bc56c19dd3da395a89079757 Mon Sep 17 00:00:00 2001 From: David Zuckerman Date: Tue, 3 Feb 2026 17:53:36 -0800 Subject: [PATCH 1/3] Added NODE_PATH to Dockerfile and configure yarn build in prod target moved application.js into packs directory moved application.js, removed from manifest.js Moved yarn build removed commented out code --- Dockerfile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index b017c18..243792d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,6 +76,9 @@ RUN mkdir -p /opt/app/tmp \ # Add binstubs to the path. ENV PATH="/usr/bin:/opt/app/bin:/usr/local/yarn/node_modules/.bin:$PATH" +# Add path to node_modules +ENV NODE_PATH=/usr/local/yarn/node_modules + # If run with no other arguments, the image will start the rails server by # default. Note that we must bind to all interfaces (0.0.0.0) because when # running in a docker container, the actual public interface is created @@ -85,7 +88,7 @@ ENV PATH="/usr/bin:/opt/app/bin:/usr/local/yarn/node_modules/.bin:$PATH" # yet, so if the build fails before the `bundle install` step below, you # will need to override the default command when troubleshooting the buggy # image. -CMD ["rails", "server", "-b", "0.0.0.0"] +CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"] # ============================================================================= # Target: development @@ -131,7 +134,7 @@ RUN bundle install # re-install. COPY --chown=$APP_USER:$APP_USER . . -RUN yarn install --cwd /usr/local/yarn +RUN yarn install --cwd /usr/local/yarn # ============================================================================= # Target: production @@ -166,8 +169,10 @@ RUN bundle install --local # TODO: Figure out why jsbundling-rails doesn't invoke `yarn build` # *before* Sprockets reads app/assets/config/manifest.js -RUN yarn install --cwd /usr/local/yarn +WORKDIR /usr/local/yarn +RUN yarn build +WORKDIR /opt/app # Pre-compile assets so we don't have to do it after deployment. # NOTE: dummy SECRET_KEY_BASE to prevent spurious initializer issues # -- see https://github.com/rails/rails/issues/32947 From 926bd0fc8e5e0156604d701a36555a95ab7921eb Mon Sep 17 00:00:00 2001 From: David Zuckerman Date: Wed, 4 Feb 2026 15:12:51 -0800 Subject: [PATCH 2/3] setting type to module in application layout, setting asset precompile in assets.rb initializer,having bundle call rails in Dockerfile for precompile --- Dockerfile | 2 +- app/views/layouts/application.html.erb | 3 +-- config/initializers/assets.rb | 7 +++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 243792d..66ceaa5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -176,7 +176,7 @@ WORKDIR /opt/app # Pre-compile assets so we don't have to do it after deployment. # NOTE: dummy SECRET_KEY_BASE to prevent spurious initializer issues # -- see https://github.com/rails/rails/issues/32947 -RUN SECRET_KEY_BASE=1 rails assets:precompile --trace +RUN SECRET_KEY_BASE=1 bundle exec rails assets:precompile --trace # ------------------------------------------------------------ # Preserve build arguments diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 22a2aed..2391434 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -9,8 +9,7 @@ <%= csp_meta_tag %> - - <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %> + <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true, type: "module" %> <%= javascript_include_tag "items", "data-turbo-track": "reload", defer: true %> <%= javascript_include_tag "terms", "data-turbo-track": "reload", defer: true %> <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index e77b173..404859e 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -13,6 +13,13 @@ # folder are already added. Rails.application.config.assets.precompile += %w[*.png] +Rails.application.config.assets.precompile += %w[ + application.js + items.js + terms.js + viewer.js + marc-reload.js +] # Rails.application.config.assets.configure do |env| # env.css_compressor = :sass # end From 6c0ea46961eb2518be51ac0a003b59938a031d68 Mon Sep 17 00:00:00 2001 From: David Zuckerman Date: Wed, 4 Feb 2026 18:36:01 -0800 Subject: [PATCH 3/3] added symbolic link to node_modules --- Dockerfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 66ceaa5..03f3209 100644 --- a/Dockerfile +++ b/Dockerfile @@ -134,7 +134,7 @@ RUN bundle install # re-install. COPY --chown=$APP_USER:$APP_USER . . -RUN yarn install --cwd /usr/local/yarn +RUN yarn install --frozen-lockfile --cwd /usr/local/yarn # ============================================================================= # Target: production @@ -163,16 +163,15 @@ COPY --from=development --chown=$APP_USER /usr/local/yarn /usr/local/yarn # Ensure the bundle is installed and the Gemfile.lock is synced. RUN bundle config set frozen 'true' RUN bundle install --local - +RUN ln -s /usr/local/yarn/node_modules /opt/app/node_modules # ------------------------------------------------------------ # Precompile production assets # TODO: Figure out why jsbundling-rails doesn't invoke `yarn build` # *before* Sprockets reads app/assets/config/manifest.js -WORKDIR /usr/local/yarn +WORKDIR /opt/app RUN yarn build -WORKDIR /opt/app # Pre-compile assets so we don't have to do it after deployment. # NOTE: dummy SECRET_KEY_BASE to prevent spurious initializer issues # -- see https://github.com/rails/rails/issues/32947