remy / jsonbin

A personal JSON store as a RESTful service
https://jsonbin.org
393 stars 25 forks source link

[WIP] Now 2.0 deployment #38

Closed paulogdm closed 3 years ago

paulogdm commented 5 years ago

This is a draft PR that makes jsonbin deployable with Now 2.0 PS: We need to test if dotenv is working as expected on the server or migrate to secrets, if possible...

remy commented 5 years ago

No dice (using that config): https://jsonbin-now2.now.sh/

If I deploy it public, will the now.json be publically available (because I've entered the env values directly in the file).

Logs don't yield anything that I can see explaining the error.

Static does look to have worked - though that's not my primary concern.

remy commented 5 years ago

Not sure how you found that change (please do share), and it doesn't crash, but it hangs instead now: https://jsonbin.rem.now.sh/

paulogdm commented 5 years ago

Sorry Remy. So I was getting an error like "cannot find module 'html'" and after a little dose of Stack Overflow, it seems this can be caused by Express not "knowing" how to handle .html. Today I will take a look at this error that I'm getting while deploying and also using now dev:

module initialization error: Error
    at Function.engine (/var/task/user/lib/index.js:116894:11)
    at Object.2730 (/var/task/user/lib/index.js:64504:5)
    at __webpack_require__ (/var/task/user/lib/index.js:22:30)
    at startup (/var/task/user/lib/index.js:36:19)
    at module.exports.5.module.exports.out (/var/task/user/lib/index.js:42:18)
    at Object.<anonymous> (/var/task/user/lib/index.js:45:10)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/var/task/launcher.js:10:41)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)

I will try:

Also, I want to state this is not an optimal setup for serverless. Since the server is pretty much "monolithic" it generates a big lambda in size hurting performance considerably. It would be better to split the server in "per-route" handlers or something that can generate more than one lambda to separate concerns. An example can be this one. Check the discussion regarding lambda size in this blog post.

remy commented 5 years ago

Also, I want to state this is not an optimal setup for serverless

I understand that - and (obviously) if I wrote this project from scratch approaching it using a lambda style, it would be structured completely differently.

However, this really is one of the simplest node based projects I have currently running on Zeit and I've yet to successfully deploy anything into now v2.

I've gotten the impression that I would be able to benefit from now v2 without completely rewriting all my projects. Though I'm getting a hint that perhaps that's not accurate at all and that my projects may not be a good fit for Zeit once v2 fully replaces v1.

One thing that is useful for me, is that seeing that taking a regular project isn't proving as simple for you/team-Zeit either (I had worried it was entirely me being clueless!). It's a good trial by fire I guess!

paulogdm commented 5 years ago

I've gotten the impression that I would be able to benefit from now v2 without completely rewriting all my projects. Though I'm getting a hint that perhaps that's not accurate at all and that my projects may not be a good fit for Zeit once v2 fully replaces v1.

That is the idea! Improving the builders to do this task for you is one of the main objectives of the platform... That requires time and we are increasing the code coverage with it.

One thing that is useful for me, is that seeing that taking a regular project isn't proving as simple for you/team-Zeit either (I had worried it was entirely me being clueless!). It's a good trial by fire I guess!

If you notice the changes so far it seems like a fair amount. Hopefully, with now dev fully released, we can bring the development process closer to what is being built in the cloud. It is just a question of improvement. I will check the error today in a few hours.

paulogdm commented 5 years ago

@remy Please authorize the deployment and let's see if the canary builder is prepared for your repo!