Closed cimtico closed 3 years ago
How can I build an api-only app instead of a full rails app?
You sure can! I would recommend you go two different routes.
bin/_rails-new
file by adding --api
. Then do a bin/build
and commit that to your own fork/branch. I did just that and made a pull request with the change so technically you can use this branch too. Hope that outlines the process or the manual files you have to change if #1 is what you choose.but got errors in aws about the gems not being found after deployment. So I'm not sure what is the best way to proceed
I think above will help but if needed you must share the errors. Cant help unless I know what they are. Cheers!
Thanks for your reply. I just ran through a new install following the steps in the readme (trying to just get something working and try to do precisely what you mentioned). However, with the "clean" install I get these errors:
2020-10-22T17:38:57.599-06:00 | Init error when loading handler app.handler |
---|---|
2020-10-22T17:38:57.599-06:00Copy{ "errorMessage": "Could not find public_suffix-4.0.6 in any of the sources", "errorType": "Initblock in materialize'", "/var/runtime/gems/bundler-2.1.4/lib/bundler/spec_set.rb:80:in map!'", "/var/runtime/gems/bundler-2.1.4/lib/bundler/spec_set.rb:80:in materialize'", "/var/runtime/gems/bundler-2.1.4/lib/bundler/definition.rb:170:in specs'", "/var/runtime/gems/bundler-2.1.4/lib/bundler/definition.rb:237:in specs_for'", "/var/runtime/gems/bundler-2.1.4/lib/bundler/definition.rb:226:in requested_specs'", "/var/runtime/gems/bundler-2.1.4/lib/bundler/runtime.rb:101:in block in definition_method'", "/var/runtime/gems/bundler-2.1.4/lib/bundler/runtime.rb:20:in setup'", "/var/runtime/gems/bundler-2.1.4/lib/bundler.rb:149:in setup'", "/var/runtime/gems/bundler-2.1.4/lib/bundler/setup.rb:20:in block in <top (required)>'", "/var/runtime/gems/bundler-2.1.4/lib/bundler/ui/shell.rb:136:in with_level'", "/var/runtime/gems/bundler-2.1.4/lib/bundler/ui/shell.rb:88:in silence'", "/var/runtime/gems/bundler-2.1.4/lib/bundler/setup.rb:20:in <top (required)>'", "/var/lang/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in require'", "/var/lang/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in require'", "/var/task/config/boot.rb:3:in <top (required)>'", "/var/task/app.rb:2:in require_relative'", "/var/task/app.rb:2:in <top (required)>'", "/var/lang/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in require'", "/var/lang/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in require'" ] } |
It seems to me it that for some reason it is trying to load the "dev" dependencies instead of the prod-only ones. Have you encountered anything like this before? I feel it might just be a bad config somewhere.
Interesting. It seems I get those errors when I use a container I built with the "newer" sam that is installed through "brew". Using your docker-compose and docker setup seems to get past those errors. However, I get an error about Missing `secret_key_base` for 'production' environment,...
eventhough the master.key file is there, and the key is registered in SSM.
Well, when you deploy to production the config/master.key
should not be in the deployed package (https://github.com/customink/lamby-cookiecutter/blob/master/%7B%7Bcookiecutter.project_name%7D%7D/bin/build-rails#L46) it should be written to the .env.production
file in the package (see line 19-24) further up from that same link. You could download the package from S3, change the suffix to .gz and check to make sure. Likewise to confirm that bin/deploy is doing as expected you can run ./bin/run bash
and that the aws ssm get-parameter ...
on Line 19 works as expected. Another method is to check the build artifact directory in .aws-sam director.
How can I build an api-only app instead of a full rails app? I noticed a _rails-new bin file, but it seems it isn't used during the sam init process, so adding the --api flag in there in my fork didn't do much.
I also tried adding the lamby gem to a new rails api setup, but got errors in aws about the gems not being found after deployment. So I'm not sure what is the best way to proceed