Open pi0 opened 1 month ago
Here are some of my notes on the topic: Coolify, by default, uses Nixpacks under the hood to deploy a project.
As you can see in the example, Nixpacks uses the build
and start
scripts inside package.json
. One drawback is that the final Docker image, by default built at with each push, will include all the source code and node_modules
, effectively making it way larger than required.
Nuxt's new experimental.buildCache
might be easier to handle via Nixpacks compared to Dockerfiles. As the first natively supports node_modules
caching between each build stage, but does require a custom nixpacks.toml
(although I haven't succeeded, yet).
I started building my own Dockerfiles (available in this gist) when deploying to production-like envs. On average this results in my projects going from >600MB to 150-190MB per image, per build, (with 46MB being the base image, thus shared).
To conclude:
P.S.: The shared Gist has multiple Dockerfiles, one solely based on bun
, one on pnpm+bun
, while the last one is based on pnpm+node
. Based on the project I usually switch between one or the other based on build/runtime stability or req/s performance.
Thanks for notes dear @sandros94 .
Deployments should always have a dedicated preset. In this case, coolify. regardless of how-it-works details (i suggest to read my writeup).
Docker support (and Nixpack/Buildpack) are also long time in track (https://github.com/unjs/nitro/issues/54) and indeed it is the main pain point that they depend on packing root instead of output dir.
We should only bundle .output
dir in output in docker images. By all these, i think our first goal should be see how we can have a coolify setup that achieves this.
Happy to pick this up @pi0 and thank you @sandros94 for sharing your notes.
Incorporating the Coolify preset into Nitro will help ensure our efforts align with the existing standards. Currently, deploying a Nitro or Nuxt app would fail due to the absence of a start command (which is empty by default through Nixpacks and not present in default Nuxt/Nitro CLI output).
I addressed this by adding the start script at Line 8 within my Coolify examples. Without it, Nixpack won't have a command to run post-build. Nixpack calls the start command, which can be modified both in the Coolify dashboard and the project's package.json. At its core, this should serve as a solid foundation for a basic Coolify preset to start with via Coolify's GitHub deployment route, Docker will require more work and maybe result in a secondary coolify preset.
We need to do some research about the best way forward, I'll talk with Andras on monday. Can't promise a quick turnover in delivering this new preset but hopefully with the help of @sandros94, we can speed it up.
BTW @pi0: Would you like me to branch off these Nitro examples from the Nuxt examples (including the Coolify docs), like in to separate folders on the Coolify example repo?
I think one first good step, if you can create a nitro-coolify
playground repository (and invite us if need help of course) we can iterate over it.
Update: Dear @pi0 and @sandros94 , I created the initial repositories, nitro-coolify-preset
and nitro-coolify
playground, will definitely appreciate all the help I can get from you two. Added notes in the readme's where I require input whenever you are avail.
I will work further on these two repo's starting tomorrow. Happy to hear from you.
PS: Already started the docs side of things too for the Nitro docs locally.
The previously created repositories seem redundant, apologies for overdoing it. I will invite both of you to a Nitro fork tomorrow with my coolify branch, after some research I realised It's more straightforward this way in terms of working on Nitro going forward.
Will keep you up to date and call for help when in need.
Dear @pi0 and @sandros94, I created the single Nitro playground repo and invited you both as mentioned before. The preset and the same server utils as in Nuxt can co-exist and be developed here as we go. I put out a initial PR that we can go over and discuss, expand, finetune and get it ready whenever we get the chance too.
https://github.com/coollabsio/coolify
https://github.com/coollabsio/coolify-examples/tree/main/nuxt/nitro
/cc @justserdar if you want to take on this :)