Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preset and docs for coolify #2762

Open
pi0 opened this issue Sep 29, 2024 · 7 comments
Open

preset and docs for coolify #2762

pi0 opened this issue Sep 29, 2024 · 7 comments
Labels

Comments

@pi0
Copy link
Member

pi0 commented Sep 29, 2024

https://github.com/coollabsio/coolify

https://github.com/coollabsio/coolify-examples/tree/main/nuxt/nitro

/cc @justserdar if you want to take on this :)

@pi0 pi0 added the preset label Sep 29, 2024
@sandros94
Copy link
Contributor

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:

  • With the current Coolify version, we are more talking about a "Nixpacks Preset" rather than a Coolify one.
  • If someone would like to focus on image size, a custom approach is currently a better choice.

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.

@pi0
Copy link
Member Author

pi0 commented Sep 29, 2024

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 (#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.

@justserdar
Copy link

justserdar commented Sep 29, 2024

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?

@pi0
Copy link
Member Author

pi0 commented Sep 29, 2024

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.

@justserdar
Copy link

justserdar commented Sep 29, 2024

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.

@justserdar
Copy link

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.

@justserdar justserdar mentioned this issue Oct 1, 2024
2 tasks
@justserdar
Copy link

justserdar commented Oct 2, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants