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: Languagetool service

Andras Bacsai5d722183d333
diff --git a/package.json b/package.json
index dd531e9463..d9b5225e04 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "coolify",
"description": "An open-source & self-hostable Heroku / Netlify alternative.",
- "version": "2.0.24",
+ "version": "2.0.25",
"license": "AGPL-3.0",
"scripts": {
"dev": "docker-compose -f docker-compose-dev.yaml up -d && NODE_ENV=development svelte-kit dev --host 0.0.0.0",
diff --git a/src/lib/components/svg/services/LanguageTool.svelte b/src/lib/components/svg/services/LanguageTool.svelte
new file mode 100644
index 0000000000..65a8f0a03b
--- /dev/null
+++ b/src/lib/components/svg/services/LanguageTool.svelte
@@ -0,0 +1,27 @@
+<script lang="ts">
+ export let isAbsolute = false;
+</script>
+
+<svg
+ xmlns="http://www.w3.org/2000/svg"
+ class={isAbsolute ? 'w-10 h-10 absolute top-0 left-0 -m-5' : 'w-8 mx-auto'}
+ fill="none"
+ viewBox="0 0 140 140"
+ data-lt-extension-installed="true"
+ ><g clip-path="url(#clip0)"
+ ><path
+ fill="#fff"
+ fill-rule="evenodd"
+ d="M140 43.602c0-1.662.001-3.324-.01-4.987-.008-1.4-.024-2.8-.062-4.2-.082-3.05-.262-6.126-.805-9.142-.55-3.06-1.448-5.907-2.864-8.688A29.227 29.227 0 0 0 123.476 3.81c-2.783-1.416-5.634-2.314-8.697-2.864-3.016-.542-6.094-.722-9.144-.804-1.4-.038-2.801-.054-4.202-.063C99.77.068 98.107.07 96.444.07L77.135 0H62.694L43.726.07c-1.666 0-3.332-.002-4.998.008-1.404.01-2.807.025-4.21.063-3.058.082-6.142.262-9.166.805-3.067.55-5.922 1.447-8.709 2.862a29.293 29.293 0 0 0-7.419 5.377 29.223 29.223 0 0 0-5.389 7.4c-1.42 2.78-2.32 5.63-2.871 8.691-.543 3.016-.723 6.091-.806 9.14-.038 1.4-.054 2.8-.062 4.2C.086 40.277 0 42.342 0 44.004v33.3l.086 19.102c0 1.665 0 3.33.01 4.994a200.6 200.6 0 0 0 .062 4.205c.083 3.054.263 6.135.807 9.155.551 3.064 1.451 5.916 2.87 8.7a29.294 29.294 0 0 0 12.807 12.794c2.788 1.418 5.645 2.317 8.714 2.868 3.022.542 6.105.722 9.162.804 1.403.038 2.806.054 4.21.063 1.666.01 3.332.009 4.998.009l19.14.001h14.477l19.101-.001c1.663 0 3.326.001 4.989-.009a202.92 202.92 0 0 0 4.202-.063c3.052-.082 6.13-.262 9.148-.805 3.061-.551 5.911-1.45 8.692-2.867a29.215 29.215 0 0 0 7.405-5.384 29.22 29.22 0 0 0 5.378-7.409c1.417-2.785 2.315-5.639 2.866-8.704.542-3.02.722-6.099.804-9.152.038-1.402.054-2.804.062-4.205.011-1.665.01-3.33.01-4.993l-.001-19.103V62.694L140 43.602"
+ clip-rule="evenodd"
+ /><path
+ fill="#000"
+ fill-rule="evenodd"
+ d="M39.375 40.188h8.313a6.25 6.25 0 0 1 6.25 6.25v24.25h16.25v8.75h-18.75a6.25 6.25 0 0 1-6.25-6.25v-24.25h-5.813v-8.75zm63.563 6.25v6.5h-8.75v-4h-6.876v30.5h-8.75v-30.5h-6.874v4h-8.75v-6.5a6.25 6.25 0 0 1 6.25-6.25h27.5a6.25 6.25 0 0 1 6.25 6.25z"
+ clip-rule="evenodd"
+ /><path
+ fill="#239AFF"
+ d="M35.319 102.906l-8.138-5.812c2.39-3.347 4.857-5.936 7.452-7.753 2.884-2.018 5.948-3.091 9.117-3.091 2.942 0 5.491.714 7.768 2.08a17.622 17.622 0 0 1 2.615 1.94c.589.518 1.009.926 1.903 1.82 1.355 1.354 1.917 1.851 2.591 2.255.731.439 1.503.655 2.623.655 1.121 0 1.896-.217 2.631-.657.677-.405 1.245-.905 2.6-2.257l.012-.012c.89-.888 1.314-1.299 1.902-1.817a17.643 17.643 0 0 1 2.61-1.933c2.273-1.362 4.814-2.074 7.745-2.074s5.472.712 7.745 2.074c.916.55 1.758 1.183 2.61 1.933.589.518 1.013.929 1.902 1.817l.013.012c1.354 1.352 1.922 1.852 2.599 2.257.735.44 1.51.657 2.631.657.998 0 2.1-.386 3.383-1.284 1.572-1.1 3.272-2.886 5.048-5.372l8.138 5.812c-2.391 3.347-4.857 5.936-7.452 7.753-2.884 2.018-5.948 3.091-9.117 3.091-2.941 0-5.49-.713-7.769-2.078a17.627 17.627 0 0 1-2.619-1.938c-.59-.519-1.015-.93-1.906-1.82l-.013-.013c-1.351-1.348-1.917-1.846-2.59-2.25-.728-.436-1.494-.651-2.603-.651-1.109 0-1.875.215-2.603.651-.673.404-1.239.902-2.59 2.25l-.012.013c-.892.89-1.317 1.301-1.907 1.82-.855.752-1.7 1.388-2.62 1.938C66.74 104.287 64.192 105 61.25 105c-2.942 0-5.49-.714-7.768-2.08a17.654 17.654 0 0 1-2.615-1.939c-.588-.519-1.009-.927-1.902-1.82-1.355-1.355-1.918-1.852-2.592-2.256-.731-.439-1.503-.655-2.623-.655-.998 0-2.1.386-3.383 1.284-1.572 1.1-3.272 2.886-5.048 5.372z"
+ /></g
+ ><defs><clipPath id="clip0"><path fill="#fff" d="M0 0h140v140H0z" /></clipPath></defs></svg
+>
diff --git a/src/lib/database/common.ts b/src/lib/database/common.ts
index 04bf54d6bc..4638e483e1 100644
--- a/src/lib/database/common.ts
+++ b/src/lib/database/common.ts
@@ -156,6 +156,15 @@ export const supportedServiceTypesAndVersions = [
ports: {
main: 80
}
+ },
+ {
+ name: 'languagetool',
+ fancyName: 'LanguageTool',
+ baseImage: 'silviof/docker-languagetool',
+ versions: ['latest'],
+ ports: {
+ main: 8010
+ }
}
];
diff --git a/src/lib/database/services.ts b/src/lib/database/services.ts
index 5cbf2cbfb1..56606109bc 100644
--- a/src/lib/database/services.ts
+++ b/src/lib/database/services.ts
@@ -105,6 +105,13 @@ export async function configureServiceType({ id, type }) {
type
}
});
+ } else if (type === 'languagetool') {
+ await prisma.service.update({
+ where: { id },
+ data: {
+ type
+ }
+ });
}
}
export async function setServiceVersion({ id, version }) {
@@ -128,6 +135,9 @@ export async function updatePlausibleAnalyticsService({ id, fqdn, email, usernam
export async function updateNocoDbOrMinioService({ id, fqdn, name }) {
return await prisma.service.update({ where: { id }, data: { fqdn, name } });
}
+export async function updateLanguageToolService({ id, fqdn, name }) {
+ return await prisma.service.update({ where: { id }, data: { fqdn, name } });
+}
export async function updateVaultWardenService({ id, fqdn, name }) {
return await prisma.service.update({ where: { id }, data: { fqdn, name } });
}
diff --git a/src/routes/services/[id]/__layout.svelte b/src/routes/services/[id]/__layout.svelte
index e1f5b21a61..a096c14cd9 100644
--- a/src/routes/services/[id]/__layout.svelte
+++ b/src/routes/services/[id]/__layout.svelte
@@ -110,23 +110,6 @@
loading = false;
}
}
- // onMount(async () => {
- // if (
- // service.type &&
- // service.destinationDockerId &&
- // service.version &&
- // service.fqdn &&
- // !isRunning
- // ) {
- // try {
- // await post(`/services/${service.id}/${service.type}/stop.json`, {});
- // } catch ({ error }) {
- // return errorNotification(error);
- // } finally {
- // loading = false;
- // }
- // }
- // });
</script>
<nav class="nav-side">
diff --git a/src/routes/services/[id]/configuration/type.svelte b/src/routes/services/[id]/configuration/type.svelte
index 398f6a4d5d..0dec45c5ff 100644
--- a/src/routes/services/[id]/configuration/type.svelte
+++ b/src/routes/services/[id]/configuration/type.svelte
@@ -37,6 +37,7 @@
import { goto } from '$app/navigation';
import { post } from '$lib/api';
import VaultWarden from '$lib/components/svg/services/VaultWarden.svelte';
+ import LanguageTool from '$lib/components/svg/services/LanguageTool.svelte';
const { id } = $page.params;
const from = $page.url.searchParams.get('from');
@@ -74,6 +75,8 @@
<Wordpress isAbsolute />
{:else if type.name === 'vaultwarden'}
<VaultWarden isAbsolute />
+ {:else if type.name === 'languagetool'}
+ <LanguageTool isAbsolute />
{/if}{type.fancyName}
</button>
</form>
diff --git a/src/routes/services/[id]/index.svelte b/src/routes/services/[id]/index.svelte
index 7e4a4eb95e..573ec26acc 100644
--- a/src/routes/services/[id]/index.svelte
+++ b/src/routes/services/[id]/index.svelte
@@ -35,10 +35,10 @@
import VsCodeServer from '$lib/components/svg/services/VSCodeServer.svelte';
import Wordpress from '$lib/components/svg/services/Wordpress.svelte';
import Services from './_Services/_Services.svelte';
- import { getDomain } from '$lib/components/common';
import VaultWarden from '$lib/components/svg/services/VaultWarden.svelte';
import cuid from 'cuid';
import { browser } from '$app/env';
+ import LanguageTool from '$lib/components/svg/services/LanguageTool.svelte';
export let service;
export let isRunning;
@@ -105,6 +105,10 @@
<a href="https://github.com/dani-garcia/vaultwarden" target="_blank">
<VaultWarden />
</a>
+ {:else if service.type === 'languagetool'}
+ <a href="https://languagetool.org/dev" target="_blank">
+ <LanguageTool />
+ </a>
{/if}
</div>
</div>
diff --git a/src/routes/services/[id]/languagetool/index.json.ts b/src/routes/services/[id]/languagetool/index.json.ts
new file mode 100644
index 0000000000..e33112fe8a
--- /dev/null
+++ b/src/routes/services/[id]/languagetool/index.json.ts
@@ -0,0 +1,21 @@
+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.updateLanguageToolService({ id, fqdn, name });
+ return { status: 201 };
+ } catch (error) {
+ return ErrorHandler(error);
+ }
+};
diff --git a/src/routes/services/[id]/languagetool/start.json.ts b/src/routes/services/[id]/languagetool/start.json.ts
new file mode 100644
index 0000000000..95f6e9c47a
--- /dev/null
+++ b/src/routes/services/[id]/languagetool/start.json.ts
@@ -0,0 +1,58 @@
+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 } = service;
+ const network = destinationDockerId && destinationDocker.network;
+ const host = getEngine(destinationDocker.engine);
+
+ const { workdir } = await createDirectories({ repository: type, buildId: id });
+ const image = getServiceImage(type);
+ const composeFile = {
+ version: '3.8',
+ services: {
+ [id]: {
+ container_name: id,
+ image: `${image}:${version}`,
+ networks: [network],
+ restart: 'always',
+ volumes: [`${id}-ngrams:/ngrams`],
+ labels: makeLabelForServices('languagetool')
+ }
+ },
+ networks: {
+ [network]: {
+ external: true
+ }
+ },
+ volumes: {
+ [`${id}-ngrams`]: {}
+ }
+ };
+ 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]/languagetool/stop.json.ts b/src/routes/services/[id]/languagetool/stop.json.ts
new file mode 100644
index 0000000000..c604e1cc3b
--- /dev/null
+++ b/src/routes/services/[id]/languagetool/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);
+ }
+};
diff --git a/src/routes/services/index.svelte b/src/routes/services/index.svelte
index 997c8d313c..1ea70b904c 100644
--- a/src/routes/services/index.svelte
+++ b/src/routes/services/index.svelte
@@ -26,6 +26,7 @@
import VsCodeServer from '$lib/components/svg/services/VSCodeServer.svelte';
import Wordpress from '$lib/components/svg/services/Wordpress.svelte';
import VaultWarden from '$lib/components/svg/services/VaultWarden.svelte';
+ import LanguageTool from '$lib/components/svg/services/LanguageTool.svelte';
export let services;
</script>
@@ -70,6 +71,8 @@
<Wordpress isAbsolute />
{:else if service.type === 'vaultwarden'}
<VaultWarden isAbsolute />
+ {:else if service.type === 'languagetool'}
+ <LanguageTool isAbsolute />
{/if}
<div class="font-bold text-xl text-center truncate">
{service.name}