Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat: Add update kuma service

Andras Bacsaia742a3d2e32b
diff --git a/src/app.d.ts b/src/app.d.ts
index d69042fe83..2ebfc021b9 100644
--- a/src/app.d.ts
+++ b/src/app.d.ts
@@ -8,9 +8,11 @@ declare namespace App {
interface Platform {}
interface Session extends SessionData {}
interface Stuff {
+ service: any;
application: any;
isRunning: boolean;
appId: string;
+ readOnly: boolean;
}
}
diff --git a/src/lib/components/svg/services/UptimeKuma.svelte b/src/lib/components/svg/services/UptimeKuma.svelte
new file mode 100644
index 0000000000..e043ea54b7
--- /dev/null
+++ b/src/lib/components/svg/services/UptimeKuma.svelte
@@ -0,0 +1,159 @@
+<script lang="ts">
+ export let isAbsolute = false;
+</script>
+
+<svg
+ class={isAbsolute ? 'w-10 h-10 absolute top-0 left-0 -m-5' : 'w-10 h-10 mx-auto'}
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ version="1.1"
+ preserveAspectRatio="xMidYMid meet"
+ viewBox="0 0 640 640"
+ width="640"
+ height="640"
+ ><defs
+ ><path
+ d="M407.55 916.24C471.25 916.24 522.89 967.88 522.89 1031.57C522.89 1113.88 522.89 1245.44 522.89 1327.74C522.89 1391.44 471.25 1443.08 407.55 1443.08C325.25 1443.08 193.68 1443.08 111.38 1443.08C47.69 1443.08 -3.95 1391.44 -3.95 1327.74C-3.95 1245.44 -3.95 1113.88 -3.95 1031.57C-3.95 967.88 47.69 916.24 111.38 916.24C193.68 916.24 325.25 916.24 407.55 916.24Z"
+ id="a1LdTs1gvU"
+ /><linearGradient
+ id="gradientcoH7TNh19"
+ gradientUnits="userSpaceOnUse"
+ x1="256.07"
+ y1="1132.14"
+ x2="609.11"
+ y2="1480.42"
+ ><stop style="stop-color: #c2efd2;stop-opacity: 1" offset="0%" /><stop
+ style="stop-color: #8ff0e5;stop-opacity: 1"
+ offset="100%"
+ /></linearGradient
+ ><path
+ d="M-467.41 394.63C-467.41 554.76 -597.42 684.76 -757.55 684.76C-917.68 684.76 -1047.69 554.76 -1047.69 394.63C-1047.69 234.5 -917.68 104.49 -757.55 104.49C-597.42 104.49 -467.41 234.5 -467.41 394.63Z"
+ id="a1uaEBd4xM"
+ /><path
+ d="M-96.99 -586.14C-57.24 -619.85 -5.79 -604.75 19.26 -580.46C31.43 -568.66 56.57 -546.36 40.97 -491.67C32.76 -462.87 10.41 -436.4 -26.05 -412.27C-15.07 -377.85 -5.6 -344.76 2.36 -313C14.29 -265.36 13.55 -189.67 -26.05 -155.4C-67.27 -119.73 -166.91 -104.09 -234.24 -103.09C-301.57 -102.1 -406.19 -113.09 -461.6 -155.4C-517.01 -197.7 -512.24 -257.07 -498.04 -313C-488.58 -350.28 -476.43 -383.38 -461.6 -412.27C-505.54 -441.3 -530.54 -467.76 -536.6 -491.67C-545.68 -527.54 -530.93 -565.61 -501.12 -586.14C-471.31 -606.67 -435.18 -606.9 -400.45 -586.14C-377.3 -572.3 -354.79 -542.13 -332.92 -495.62C-287.85 -505.25 -254.96 -509.57 -234.24 -508.6C-214.74 -507.68 -186.57 -503.36 -149.72 -495.62C-135.81 -537.95 -118.23 -568.12 -96.99 -586.14Z"
+ id="f8p7QlEjN3"
+ /><linearGradient
+ id="gradienta4Tg99ZOOp"
+ gradientUnits="userSpaceOnUse"
+ x1="-440.25"
+ y1="-388.59"
+ x2="-100.49"
+ y2="-147.33"
+ ><stop style="stop-color: #5cdd8b;stop-opacity: 1" offset="0%" /><stop
+ style="stop-color: #7ae6a1;stop-opacity: 1"
+ offset="100%"
+ /></linearGradient
+ ><path
+ d="M-86.03 -10.69C-61.35 -10.69 -41.34 9.32 -41.34 34.01C-41.34 119.07 -41.34 329.58 -41.34 414.65C-41.34 439.33 -61.35 459.34 -86.03 459.34C-136.01 459.34 -241.25 459.34 -291.23 459.34C-315.92 459.34 -335.93 439.33 -335.93 414.65C-335.93 329.58 -335.93 119.07 -335.93 34.01C-335.93 9.32 -315.92 -10.69 -291.23 -10.69C-241.25 -10.69 -136.01 -10.69 -86.03 -10.69Z"
+ id="d32ZZRxd1S"
+ /><linearGradient
+ id="gradientb1JxIe4xUm"
+ gradientUnits="userSpaceOnUse"
+ x1="-791.65"
+ y1="-33.27"
+ x2="892.1"
+ y2="418.94"
+ ><stop style="stop-color: #5cdd8b;stop-opacity: 1" offset="0%" /><stop
+ style="stop-color: #5ae98f;stop-opacity: 1"
+ offset="100%"
+ /></linearGradient
+ ><path
+ d="M-257.95 458.12C-247.92 449.62 -234.93 453.43 -228.61 459.56C-225.54 462.54 -219.19 468.17 -223.13 481.97C-225.2 489.24 -230.84 495.92 -240.05 502.01C-237.27 510.7 -234.88 519.06 -232.88 527.07C-229.86 539.1 -230.05 558.21 -240.05 566.86C-250.45 575.86 -275.6 579.81 -292.6 580.06C-309.6 580.31 -336.01 577.54 -349.99 566.86C-363.98 556.18 -362.77 541.19 -359.19 527.07C-356.8 517.66 -353.73 509.31 -349.99 502.01C-361.08 494.69 -367.39 488.01 -368.92 481.97C-371.22 472.92 -367.49 463.31 -359.97 458.12C-352.44 452.94 -343.32 452.88 -334.56 458.12C-328.71 461.62 -323.03 469.23 -317.51 480.97C-306.13 478.54 -297.83 477.45 -292.6 477.7C-287.68 477.93 -280.56 479.02 -271.26 480.97C-267.75 470.29 -263.32 462.67 -257.95 458.12Z"
+ id="b19LRRbPrG"
+ /><path
+ d="M490.4 235.64C544.09 358.38 544.09 435.34 490.4 466.5C409.85 513.24 199.96 527.49 139.54 455.64C99.26 407.74 99.26 334.4 139.54 235.64C180.5 168.18 238.71 134.45 314.17 134.45C389.64 134.45 448.38 168.18 490.4 235.64Z"
+ id="bN5StdyPU"
+ /><linearGradient
+ id="gradientb1HT15TsY0"
+ gradientUnits="userSpaceOnUse"
+ x1="259.78"
+ y1="261.15"
+ x2="463.85"
+ y2="456.49"
+ ><stop style="stop-color: #5cdd8b;stop-opacity: 1" offset="0%" /><stop
+ style="stop-color: #86e6a9;stop-opacity: 1"
+ offset="100%"
+ /></linearGradient
+ ><path
+ d="M393.81 -775.89C428.26 -748.09 439.99 -725.54 429 -708.22C412.51 -682.24 353.16 -646.07 324.5 -657.93C305.39 -665.83 294.22 -687.32 290.97 -722.41C292.69 -748.43 304.61 -767.19 326.73 -778.69C348.85 -790.19 371.21 -789.26 393.81 -775.89Z"
+ id="arh6miPP2"
+ /><linearGradient
+ id="gradientc2g6rBSAiq"
+ gradientUnits="userSpaceOnUse"
+ x1="330.1"
+ y1="-733.26"
+ x2="419.69"
+ y2="-707.1"
+ ><stop style="stop-color: #5cdd8b;stop-opacity: 1" offset="0%" /><stop
+ style="stop-color: #86e6a9;stop-opacity: 1"
+ offset="100%"
+ /></linearGradient
+ ><path
+ d="M675.36 -369.24C669.97 -325.31 657.02 -303.43 636.51 -303.61C605.74 -303.87 543.67 -335.15 538.59 -365.74C535.2 -386.14 547.54 -406.99 575.61 -428.29C598.61 -440.58 620.83 -440.37 642.29 -427.67C663.74 -414.97 674.77 -395.49 675.36 -369.24Z"
+ id="a2VENFzCvL"
+ /><linearGradient
+ id="gradientc18GuJy4sZ"
+ gradientUnits="userSpaceOnUse"
+ x1="605.5"
+ y1="-400.8"
+ x2="630.64"
+ y2="-310.92"
+ ><stop style="stop-color: #5cdd8b;stop-opacity: 1" offset="0%" /><stop
+ style="stop-color: #86e6a9;stop-opacity: 1"
+ offset="100%"
+ /></linearGradient
+ ></defs
+ ><g
+ ><g
+ ><g><use xlink:href="#a1LdTs1gvU" opacity="1" fill="url(#gradientcoH7TNh19)" /></g><g
+ ><use xlink:href="#a1uaEBd4xM" opacity="1" fill="#ebf0ed" fill-opacity="1" /></g
+ ><g
+ ><use xlink:href="#f8p7QlEjN3" opacity="1" fill="url(#gradienta4Tg99ZOOp)" /><g
+ ><use
+ xlink:href="#f8p7QlEjN3"
+ opacity="1"
+ fill-opacity="0"
+ stroke="#ffffff"
+ stroke-width="98"
+ stroke-opacity="0.57"
+ /></g
+ ></g
+ ><g
+ ><use xlink:href="#d32ZZRxd1S" opacity="1" fill="url(#gradientb1JxIe4xUm)" /><g
+ ><use
+ xlink:href="#d32ZZRxd1S"
+ opacity="1"
+ fill-opacity="0"
+ stroke="#f2f2f2"
+ stroke-width="60"
+ stroke-opacity="0.51"
+ /></g
+ ></g
+ ><g
+ ><use xlink:href="#b19LRRbPrG" opacity="1" fill="#d8ad9a" fill-opacity="1" /><g
+ ><use
+ xlink:href="#b19LRRbPrG"
+ opacity="1"
+ fill-opacity="0"
+ stroke="#ffffff"
+ stroke-width="17"
+ stroke-opacity="1"
+ /></g
+ ></g
+ ><g
+ ><use xlink:href="#bN5StdyPU" opacity="1" fill="url(#gradientb1HT15TsY0)" /><g
+ ><use
+ xlink:href="#bN5StdyPU"
+ opacity="1"
+ fill-opacity="0"
+ stroke="#f2f2f2"
+ stroke-width="200"
+ stroke-opacity="0.51"
+ /></g
+ ></g
+ ><g><use xlink:href="#arh6miPP2" opacity="1" fill="url(#gradientc2g6rBSAiq)" /></g><g
+ ><use xlink:href="#a2VENFzCvL" opacity="1" fill="url(#gradientc18GuJy4sZ)" /></g
+ ></g
+ ></g
+ ></svg
+>
diff --git a/src/lib/database/common.ts b/src/lib/database/common.ts
index 67316fd062..19922cece1 100644
--- a/src/lib/database/common.ts
+++ b/src/lib/database/common.ts
@@ -174,6 +174,15 @@ export const supportedServiceTypesAndVersions = [
ports: {
main: 5678
}
+ },
+ {
+ name: 'uptimekuma',
+ fancyName: 'Uptime Kuma',
+ baseImage: 'louislam/uptime-kuma',
+ versions: ['latest'],
+ ports: {
+ main: 3001
+ }
}
];
diff --git a/src/lib/database/services.ts b/src/lib/database/services.ts
index 4ed11f7fe1..daec2a5da2 100644
--- a/src/lib/database/services.ts
+++ b/src/lib/database/services.ts
@@ -126,6 +126,13 @@ export async function configureServiceType({ id, type }) {
type
}
});
+ } else if (type === 'uptimekuma') {
+ await prisma.service.update({
+ where: { id },
+ data: {
+ type
+ }
+ });
}
}
export async function setServiceVersion({ id, version }) {
diff --git a/src/routes/services/[id]/configuration/type.svelte b/src/routes/services/[id]/configuration/type.svelte
index af10189a2d..6a56354bea 100644
--- a/src/routes/services/[id]/configuration/type.svelte
+++ b/src/routes/services/[id]/configuration/type.svelte
@@ -39,6 +39,7 @@
import VaultWarden from '$lib/components/svg/services/VaultWarden.svelte';
import LanguageTool from '$lib/components/svg/services/LanguageTool.svelte';
import N8n from '$lib/components/svg/services/N8n.svelte';
+ import UptimeKuma from '$lib/components/svg/services/UptimeKuma.svelte';
const { id } = $page.params;
const from = $page.url.searchParams.get('from');
@@ -80,6 +81,8 @@
<LanguageTool isAbsolute />
{:else if type.name === 'n8n'}
<N8n isAbsolute />
+ {:else if type.name === 'uptimekuma'}
+ <UptimeKuma isAbsolute />
{/if}{type.fancyName}
</button>
</form>
diff --git a/src/routes/services/[id]/index.svelte b/src/routes/services/[id]/index.svelte
index 6dbf5b6f6c..bcc69b8a7c 100644
--- a/src/routes/services/[id]/index.svelte
+++ b/src/routes/services/[id]/index.svelte
@@ -40,6 +40,7 @@
import { browser } from '$app/env';
import LanguageTool from '$lib/components/svg/services/LanguageTool.svelte';
import N8n from '$lib/components/svg/services/N8n.svelte';
+ import UptimeKuma from '$lib/components/svg/services/UptimeKuma.svelte';
export let service;
export let isRunning;
@@ -114,6 +115,10 @@
<a href="https://n8n.io" target="_blank">
<N8n />
</a>
+ {:else if service.type === 'uptimekuma'}
+ <a href="https://github.com/louislam/uptime-kuma" target="_blank">
+ <UptimeKuma />
+ </a>
{/if}
</div>
</div>
diff --git a/src/routes/services/[id]/uptimekuma/index.json.ts b/src/routes/services/[id]/uptimekuma/index.json.ts
new file mode 100644
index 0000000000..5ec3fa69a8
--- /dev/null
+++ b/src/routes/services/[id]/uptimekuma/index.json.ts
@@ -0,0 +1,20 @@
+import { getUserDetails } from '$lib/common';
+import * as db from '$lib/database';
+import { ErrorHandler } from '$lib/database';
+import type { RequestHandler } from '@sveltejs/kit';
+
+export const post: RequestHandler = async (event) => {
+ const { status, body } = await getUserDetails(event);
+ if (status === 401) return { status, body };
+ const { id } = event.params;
+
+ let { name, fqdn } = await event.request.json();
+ if (fqdn) fqdn = fqdn.toLowerCase();
+
+ try {
+ await db.updateService({ id, fqdn, name });
+ return { status: 201 };
+ } catch (error) {
+ return ErrorHandler(error);
+ }
+};
diff --git a/src/routes/services/[id]/uptimekuma/start.json.ts b/src/routes/services/[id]/uptimekuma/start.json.ts
new file mode 100644
index 0000000000..961a546c46
--- /dev/null
+++ b/src/routes/services/[id]/uptimekuma/start.json.ts
@@ -0,0 +1,72 @@
+import { asyncExecShell, createDirectories, getEngine, getUserDetails } from '$lib/common';
+import * as db from '$lib/database';
+import { promises as fs } from 'fs';
+import yaml from 'js-yaml';
+import type { RequestHandler } from '@sveltejs/kit';
+import { ErrorHandler, getServiceImage } from '$lib/database';
+import { makeLabelForServices } from '$lib/buildPacks/common';
+
+export const post: RequestHandler = async (event) => {
+ const { teamId, status, body } = await getUserDetails(event);
+ if (status === 401) return { status, body };
+
+ const { id } = event.params;
+
+ try {
+ const service = await db.getService({ id, teamId });
+ const { type, version, destinationDockerId, destinationDocker, serviceSecret } = service;
+ const network = destinationDockerId && destinationDocker.network;
+ const host = getEngine(destinationDocker.engine);
+
+ const { workdir } = await createDirectories({ repository: type, buildId: id });
+ const image = getServiceImage(type);
+
+ const config = {
+ image: `${image}:${version}`,
+ volume: `${id}-uptimekuma:/app/data`,
+ environmentVariables: {}
+ };
+ if (serviceSecret.length > 0) {
+ serviceSecret.forEach((secret) => {
+ config.environmentVariables[secret.name] = secret.value;
+ });
+ }
+ const composeFile = {
+ version: '3.8',
+ services: {
+ [id]: {
+ container_name: id,
+ image: config.image,
+ networks: [network],
+ volumes: [config.volume],
+ environment: config.environmentVariables,
+ restart: 'always',
+ labels: makeLabelForServices('uptimekuma')
+ }
+ },
+ networks: {
+ [network]: {
+ external: true
+ }
+ },
+ volumes: {
+ [config.volume.split(':')[0]]: {
+ name: config.volume.split(':')[0]
+ }
+ }
+ };
+ const composeFileDestination = `${workdir}/docker-compose.yaml`;
+ await fs.writeFile(composeFileDestination, yaml.dump(composeFile));
+
+ try {
+ await asyncExecShell(`DOCKER_HOST=${host} docker compose -f ${composeFileDestination} up -d`);
+ return {
+ status: 200
+ };
+ } catch (error) {
+ return ErrorHandler(error);
+ }
+ } catch (error) {
+ return ErrorHandler(error);
+ }
+};
diff --git a/src/routes/services/[id]/uptimekuma/stop.json.ts b/src/routes/services/[id]/uptimekuma/stop.json.ts
new file mode 100644
index 0000000000..c604e1cc3b
--- /dev/null
+++ b/src/routes/services/[id]/uptimekuma/stop.json.ts
@@ -0,0 +1,35 @@
+import { getUserDetails, removeDestinationDocker } from '$lib/common';
+import * as db from '$lib/database';
+import { ErrorHandler } from '$lib/database';
+import { checkContainer } from '$lib/haproxy';
+import type { RequestHandler } from '@sveltejs/kit';
+
+export const post: RequestHandler = async (event) => {
+ const { teamId, status, body } = await getUserDetails(event);
+ if (status === 401) return { status, body };
+
+ const { id } = event.params;
+
+ try {
+ const service = await db.getService({ id, teamId });
+ const { destinationDockerId, destinationDocker, fqdn } = service;
+ if (destinationDockerId) {
+ const engine = destinationDocker.engine;
+
+ try {
+ const found = await checkContainer(engine, id);
+ if (found) {
+ await removeDestinationDocker({ id, engine });
+ }
+ } catch (error) {
+ console.error(error);
+ }
+ }
+
+ return {
+ status: 200
+ };
+ } catch (error) {
+ return ErrorHandler(error);
+ }
+};