Skip to content

Conversation

@vlakre
Copy link
Contributor

@vlakre vlakre commented Oct 23, 2025

Summary

Added frontend-related code to the Dockerfile and compose templates.

Related issue:

Changes

Type

  • Feature: This pull request introduces a new feature.
  • Bug fix: This pull request fixes a bug.
  • Refactor: This pull request refactors existing code.
  • Documentation: This pull request updates documentation.
  • Other: This pull request makes other changes.

Additional information

  • This pull request introduces a breaking change.

Description

Checklist

  • I have performed a self-review of my own code.
  • I have tested my changes, including edge cases.
  • I have added necessary tests for the changes introduced (if applicable).
  • I have updated the documentation to reflect my changes (if applicable).

Additional notes

@vlakre vlakre requested a review from a team as a code owner October 23, 2025 14:10
COPY --chown=deploy:deploy --from=builder /app/node_modules /app/node_modules<% end %>
ARG RAILS_ENV=production
RUN --mount=type=secret,id=app-secrets,target=.env \
bundle exec rails assets:precompile
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need node_modules, package.json, and yarn to build the assets. That's why this step was moved to deploy-base. Later on, the deploy stage will take all the code, including built assets, and has no need for node, yarn or node_modules.

<<: *backend
command: ["bundle", "exec", "rails", "s", "-b", "0.0.0.0"]
command: ["bundle", "exec", "rails", "s", "-b", "0.0.0.0"]<% if uses_node? %>
depends_on:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be left up to the each project and does not need to be a part of the template.
Let me know if it's unnecessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks OK to me 👍

rm -rf ~/.bundle/ ${BUNDLE_PATH}/ruby/*/cache ${BUNDLE_PATH}/ruby/*/bundler/gems/*/.git<% if uses_bootsnap? %> && \
bundle exec bootsnap precompile --gemfile<% end %>

COPY --chown=deploy:deploy . /app<% if uses_node? %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think skip_asset_pipeline? would be more appropriate compared to uses_node?. In case of API only app (--api), asset precompilation should be skipped.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vr4b4c, on a second glance, it seems to me that we should have both uses_node? and skip_asset_pipeline?.

We can not use node and still need assets compilations (e.g. importmaps).
Or we can be an API only app and not need compilation at all.

So, unless skip_asset_pipeline? around the whole block (lines 72 to 76), and uses_node? around this

COPY --chown=deploy:deploy --from=builder /app/node_modules /app/node_modules

What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on a second glance, it seems to me that we should have both uses_node? and skip_asset_pipeline?.

Agreed

What do you think?

I think your logic isn't correct for the case of API only (skip_asset_pipeline? => true) but uses Node (uses_node? => true). Because of asset pipeline is skipped, node_modules won't be copied in this stage. I think it should be

COPY --chown=deploy:deploy . /app<% if uses_node? || !skip_asset_pipeline? %>
COPY --chown=deploy:deploy --from=builder /app/node_modules /app/node_modules<% end %>
<% unless skip_asset_pipeline? %>
ARG RAILS_ENV=production
RUN --mount=type=secret,id=app-secrets,target=.env \
  bundle exec rails assets:precompile
<% end %>

Definitely fact check me on this.

@vlakre vlakre requested a review from vr4b4c November 7, 2025 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants