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

feat: coolify preset #2767

Draft
wants to merge 3 commits into
base: v2
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/2.deploy/0.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ When deploying to production using CI/CD, Nitro tries to automatically detect th
- [stormkit](/deploy/providers/stormkit)
- [vercel](/deploy/providers/vercel)
- [zeabur](/deploy/providers/zeabur)
- [coolify](/deploy/providers/coolify)

## Changing the deployment preset

Expand Down
38 changes: 38 additions & 0 deletions docs/2.deploy/20.providers/coolify.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Coolify

> Deploy Nitro apps to [Coolify](https://coolify.io).
**Preset:** `coolify`

:read-more{title="coolify.io" to="https://coolify.io/docs/"}

::note
This is the recommended preset for Coolify deployments.
::

Coolify supports deploying both static and server-side rendered apps with zero configuration.

## Set up your web app

In your project, set Nitro preset to `coolify`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead, we should instruct the build commands to use SERVER_PRESET=coolify environment variable.


```js
export default {
nitro: {
Copy link
Member

@pi0 pi0 Oct 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This config works in nuxt only + it is boilerplate (ie: provider fixed in project)

preset: 'coolify'
}
}
```

## Getting started

1. Log in to Coolify dashboard and create a new project.
2. Select GitHub App and repository, then click "Load Repository".
3. Set `Build Pack` to `nixpacks` and `Port` to `3000`.
4. Enable healthchecks in project sidebar.
5. Add environment variables if needed.
6. Click "Deploy".

You're all set up!

When you push changes to your repository, Coolify will automatically rebuild your app.
10 changes: 6 additions & 4 deletions src/presets/_all.gen.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// Auto-generated using gen-presets script

import _nitro from "./_nitro/preset";
import _static from "./_static/preset";
import _alwaysdata from "./alwaysdata/preset";
import _awsAmplify from "./aws-amplify/preset";
import _awsLambda from "./aws-lambda/preset";
import _azure from "./azure/preset";
import _bun from "./bun/preset";
import _cleavr from "./cleavr/preset";
import _cloudflare from "./cloudflare/preset";
import _coolify from "./coolify/preset";
import _deno from "./deno/preset";
import _digitalocean from "./digitalocean/preset";
import _edgio from "./edgio/preset";
Expand All @@ -27,17 +26,18 @@ import _vercel from "./vercel/preset";
import _winterjs from "./winterjs/preset";
import _zeabur from "./zeabur/preset";
import _zerops from "./zerops/preset";
import _nitro from "./_nitro/preset";
import _static from "./_static/preset";

export default [
..._nitro,
..._static,
..._alwaysdata,
..._awsAmplify,
..._awsLambda,
..._azure,
..._bun,
..._cleavr,
..._cloudflare,
..._coolify,
..._deno,
..._digitalocean,
..._edgio,
Expand All @@ -56,4 +56,6 @@ export default [
..._winterjs,
..._zeabur,
..._zerops,
..._nitro,
..._static,
] as const;
4 changes: 2 additions & 2 deletions src/presets/_types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ export interface PresetOptions {
vercel: VercelOptions;
}

export type PresetName = "alwaysdata" | "aws-amplify" | "aws-lambda" | "aws-lambda-streaming" | "azure" | "azure-functions" | "azure-swa" | "base-worker" | "bun" | "cleavr" | "cli" | "cloudflare" | "cloudflare-module" | "cloudflare-pages" | "cloudflare-pages-static" | "cloudflare-worker" | "deno" | "deno-deploy" | "deno-server" | "digital-ocean" | "edgio" | "firebase" | "flight-control" | "genezio" | "github-pages" | "gitlab-pages" | "heroku" | "iis" | "iis-handler" | "iis-node" | "koyeb" | "layer0" | "netlify" | "netlify-builder" | "netlify-edge" | "netlify-legacy" | "netlify-static" | "nitro-dev" | "nitro-prerender" | "node" | "node-cluster" | "node-listener" | "node-server" | "platform-sh" | "render-com" | "service-worker" | "static" | "stormkit" | "vercel" | "vercel-edge" | "vercel-static" | "winterjs" | "zeabur" | "zeabur-static" | "zerops" | "zerops-static";
export type PresetName = "alwaysdata" | "aws-amplify" | "aws-lambda" | "aws-lambda-streaming" | "azure" | "azure-functions" | "azure-swa" | "base-worker" | "bun" | "cleavr" | "cli" | "cloudflare" | "cloudflare-module" | "cloudflare-pages" | "cloudflare-pages-static" | "cloudflare-worker" | "coolify" | "deno" | "deno-deploy" | "deno-server" | "digital-ocean" | "edgio" | "firebase" | "flight-control" | "genezio" | "github-pages" | "gitlab-pages" | "heroku" | "iis" | "iis-handler" | "iis-node" | "koyeb" | "layer0" | "netlify" | "netlify-builder" | "netlify-edge" | "netlify-legacy" | "netlify-static" | "nitro-dev" | "nitro-prerender" | "node" | "node-cluster" | "node-listener" | "node-server" | "platform-sh" | "render-com" | "service-worker" | "static" | "stormkit" | "vercel" | "vercel-edge" | "vercel-static" | "winterjs" | "zeabur" | "zeabur-static" | "zerops" | "zerops-static";

export type PresetNameInput = "alwaysdata" | "aws-amplify" | "awsAmplify" | "aws_amplify" | "aws-lambda" | "awsLambda" | "aws_lambda" | "aws-lambda-streaming" | "awsLambdaStreaming" | "aws_lambda_streaming" | "azure" | "azure-functions" | "azureFunctions" | "azure_functions" | "azure-swa" | "azureSwa" | "azure_swa" | "base-worker" | "baseWorker" | "base_worker" | "bun" | "cleavr" | "cli" | "cloudflare" | "cloudflare-module" | "cloudflareModule" | "cloudflare_module" | "cloudflare-pages" | "cloudflarePages" | "cloudflare_pages" | "cloudflare-pages-static" | "cloudflarePagesStatic" | "cloudflare_pages_static" | "cloudflare-worker" | "cloudflareWorker" | "cloudflare_worker" | "deno" | "deno-deploy" | "denoDeploy" | "deno_deploy" | "deno-server" | "denoServer" | "deno_server" | "digital-ocean" | "digitalOcean" | "digital_ocean" | "edgio" | "firebase" | "flight-control" | "flightControl" | "flight_control" | "genezio" | "github-pages" | "githubPages" | "github_pages" | "gitlab-pages" | "gitlabPages" | "gitlab_pages" | "heroku" | "iis" | "iis-handler" | "iisHandler" | "iis_handler" | "iis-node" | "iisNode" | "iis_node" | "koyeb" | "layer0" | "netlify" | "netlify-builder" | "netlifyBuilder" | "netlify_builder" | "netlify-edge" | "netlifyEdge" | "netlify_edge" | "netlify-legacy" | "netlifyLegacy" | "netlify_legacy" | "netlify-static" | "netlifyStatic" | "netlify_static" | "nitro-dev" | "nitroDev" | "nitro_dev" | "nitro-prerender" | "nitroPrerender" | "nitro_prerender" | "node" | "node-cluster" | "nodeCluster" | "node_cluster" | "node-listener" | "nodeListener" | "node_listener" | "node-server" | "nodeServer" | "node_server" | "platform-sh" | "platformSh" | "platform_sh" | "render-com" | "renderCom" | "render_com" | "service-worker" | "serviceWorker" | "service_worker" | "static" | "stormkit" | "vercel" | "vercel-edge" | "vercelEdge" | "vercel_edge" | "vercel-static" | "vercelStatic" | "vercel_static" | "winterjs" | "zeabur" | "zeabur-static" | "zeaburStatic" | "zeabur_static" | "zerops" | "zerops-static" | "zeropsStatic" | "zerops_static" | (string & {});
export type PresetNameInput = "alwaysdata" | "aws-amplify" | "awsAmplify" | "aws_amplify" | "aws-lambda" | "awsLambda" | "aws_lambda" | "aws-lambda-streaming" | "awsLambdaStreaming" | "aws_lambda_streaming" | "azure" | "azure-functions" | "azureFunctions" | "azure_functions" | "azure-swa" | "azureSwa" | "azure_swa" | "base-worker" | "baseWorker" | "base_worker" | "bun" | "cleavr" | "cli" | "cloudflare" | "cloudflare-module" | "cloudflareModule" | "cloudflare_module" | "cloudflare-pages" | "cloudflarePages" | "cloudflare_pages" | "cloudflare-pages-static" | "cloudflarePagesStatic" | "cloudflare_pages_static" | "cloudflare-worker" | "cloudflareWorker" | "cloudflare_worker" | "coolify" | "deno" | "deno-deploy" | "denoDeploy" | "deno_deploy" | "deno-server" | "denoServer" | "deno_server" | "digital-ocean" | "digitalOcean" | "digital_ocean" | "edgio" | "firebase" | "flight-control" | "flightControl" | "flight_control" | "genezio" | "github-pages" | "githubPages" | "github_pages" | "gitlab-pages" | "gitlabPages" | "gitlab_pages" | "heroku" | "iis" | "iis-handler" | "iisHandler" | "iis_handler" | "iis-node" | "iisNode" | "iis_node" | "koyeb" | "layer0" | "netlify" | "netlify-builder" | "netlifyBuilder" | "netlify_builder" | "netlify-edge" | "netlifyEdge" | "netlify_edge" | "netlify-legacy" | "netlifyLegacy" | "netlify_legacy" | "netlify-static" | "netlifyStatic" | "netlify_static" | "nitro-dev" | "nitroDev" | "nitro_dev" | "nitro-prerender" | "nitroPrerender" | "nitro_prerender" | "node" | "node-cluster" | "nodeCluster" | "node_cluster" | "node-listener" | "nodeListener" | "node_listener" | "node-server" | "nodeServer" | "node_server" | "platform-sh" | "platformSh" | "platform_sh" | "render-com" | "renderCom" | "render_com" | "service-worker" | "serviceWorker" | "service_worker" | "static" | "stormkit" | "vercel" | "vercel-edge" | "vercelEdge" | "vercel_edge" | "vercel-static" | "vercelStatic" | "vercel_static" | "winterjs" | "zeabur" | "zeabur-static" | "zeaburStatic" | "zeabur_static" | "zerops" | "zerops-static" | "zeropsStatic" | "zerops_static" | (string & {});
21 changes: 21 additions & 0 deletions src/presets/coolify/preset.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { defineNitroPreset } from "nitropack/kit";
import { updatePackageJSON } from "./utils";
import type { Nitro } from "nitropack/types";
const coolify = defineNitroPreset(
{
extends: "node-server",
hooks: {
async compiled(nitro: Nitro) {
await updatePackageJSON(nitro);
},
},
},
{
name: "coolify" as const,
url: import.meta.url,
}
);

export default [
coolify
];
15 changes: 15 additions & 0 deletions src/presets/coolify/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Nitro } from "nitropack/types";
import { join } from "pathe";
import { readPackageJSON, writePackageJSON } from "pkg-types";

export async function updatePackageJSON(nitro: Nitro) {
const packageJSONPath = join(nitro.options.output.serverDir, "package.json");
const packageJSON = await readPackageJSON(packageJSONPath);
await writePackageJSON(packageJSONPath, {
...packageJSON,
scripts: {
...packageJSON.scripts,
start: "node ./server/index.mjs"
},
});
}