-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/improve frontend related flow #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| 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 |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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? %> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Summary
Added frontend-related code to the Dockerfile and compose templates.
Related issue:
Changes
Type
Additional information
Description
Checklist
Additional notes