Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 --frozen-lockfile --cwd /usr/local/yarn

# =============================================================================
# Target: production
Expand Down Expand Up @@ -160,18 +163,19 @@ 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
RUN yarn install --cwd /usr/local/yarn
WORKDIR /opt/app
RUN yarn build

# 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
Expand Down
3 changes: 1 addition & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
<%= csp_meta_tag %>

<link rel="stylesheet" href="https://use.typekit.net/rxa5jay.css">

<%= 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" %>
Expand Down
7 changes: 7 additions & 0 deletions config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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