rails-lambda / lamby

🐑🛤 Simple Rails & AWS Lambda Integration
https://lamby.cloud
MIT License
602 stars 29 forks source link

Local Development #172

Closed arinhouck closed 5 months ago

arinhouck commented 11 months ago

Hey long time lurker here, I'm just now setting things up for Lamby and getting familiar. However, I don't see any clear instructions on how I should be using Lamby in a local environment. It's a bit unclear to me if the app container service has any entrypoint that I can call via HTTP?

I can just run the rails server and go about my business but I'd be curious if there is any proposed approach here. Is there a proxy server or something that we're responsible for setting up? (eg. like localstack with a gateway lambda)

I'm a bit unfamiliar with Codespaces. Not really interested in inheriting any costs related for that service either.

I couldn't quite pinpoint where the config/environment.Lamby.cmd script is and didn't see any port expose method calls in the Dockerfile.

jeremiahlukus commented 5 months ago

I guess its really up to you. It seems @ metaskills has a fondness of codespaces and using vscode .devcontainer .

For other languages I use .devcontainer but for rails I normally just locally install things.

to answer your other question

Lamby.cmd method is designed to handle AWS Lambda events by invoking the handler method . https://github.com/rails-lambda/lamby/blob/master/lib/lamby.rb#L24

metaskills commented 5 months ago

Answer might be more along the lines of this is how the SAM (Serverless Application Model) works. As it builds the final docker image, the Entrypoint & Command are done for you as part of the sam build process. The devcontainers are a CI/CD convention I explored at one time. It is neat... and benefits for development using the same image as the build system. But at the end of the day you could take any of the CI/CD conventions in the cookiecutter and replace them with your own linux env that has SAM installed, etc. Hope that helps?

arinhouck commented 5 months ago

Hey, thanks guys. I ended up using dev containers locally, however I did run into some issues with query params support (array of objects does not work the same locally via standard Rails server as in the AWS environment). I never got the chance to investigate if that was a limitation of AWS Lambda or just something that wasn't handed in the Lambda event handler mapping code of Lamby.

I thought maybe I would mess with serverless (to run a local lambda) to see if I could get a closer 1:1 of live environments to local someday when I get the chance.