Allow overriding detection of api_only?
Closed this issue · 6 comments
Hey!
My app is 99% like an API only rails app with a frontend folder. We don't use the api_only
rails setting but I'd like to be able to override the API only detection with a generator flag here: https://github.com/rubys/dockerfile-rails/blob/6e69810279fe46d6f5b9d09a3a6b4b4ae876bc0c/lib/generators/dockerfile_generator.rb#L241-L243
Does that sound useful to you?
Does that sound useful to you?
If it is useful to you, lets add it. I might be misunderstanding your app, but I'm not sure what you described will meet your needs.
api_only?
is used for two things:
- removing the
assets:precompile
step - enabling the detection of an
api_client_dir
.
If I'm understanding your application (correct me if I'm wrong!), you would still want an assets:precompile
, but you also have a frontend folder.
Can you describe your frontend folder more? How is it named, how is it built, and where is the build placed, and where should the build ultimately end up?
Using my API only example as an example, the front end folder is named client
and is in the same directory as the app
, Gemfile
, public
, etc. It is built using npm run build
and produces a client/build
directory. This should be copied into public
directory of the deployed image.
How close does this match your frontend? What is different? If the pattern is common enough, we might not even need a flag.
Hey! The example you describe is pretty close to how our app works. We have an Ember app in a /frontend
directory at the root of the project. Compilation happens the same way you describe, and the node js and yarn / npm logic works for us. The only difference is that we do not use rails in api_only
mode because we need some of the features from the non api rails middleware.
Forcing the generator by hardcoding
def api_only?
true
end
gave me a good enough starting point for our app that I thought it could be useful if other users where in the same situation.
I was thinking something like this:
def api_only?
Rails.application.config.api_only || options.generate_client?
end
gave me a good enough starting point
I'm just wondering if I could aim higher than that :-) How does the following look to you?
I made some more fixes and optimistically pushed out a new gem. When you get a chance, give it a try and see if it works for you or if there is more that can be done.
I'll have a look, thanks!
Optimistically closing this as completed. Feel free to reopen if more needs to be done.