add trilium-notes-service
This commit is contained in:
parent
ab07adb14f
commit
1f40c2ccf8
@ -20,7 +20,7 @@ export const includeServices: any = {
|
|||||||
glitchTip: true,
|
glitchTip: true,
|
||||||
searxng: true,
|
searxng: true,
|
||||||
weblate: true,
|
weblate: true,
|
||||||
taiga: true
|
taiga: true,
|
||||||
};
|
};
|
||||||
export async function configureServiceType({
|
export async function configureServiceType({
|
||||||
id,
|
id,
|
||||||
@ -350,6 +350,13 @@ export async function configureServiceType({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if (type === 'trilium') {
|
||||||
|
await prisma.service.update({
|
||||||
|
where: { id },
|
||||||
|
data: {
|
||||||
|
type
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
await prisma.service.update({
|
await prisma.service.update({
|
||||||
where: { id },
|
where: { id },
|
||||||
|
@ -69,6 +69,10 @@ export async function startService(request: FastifyRequest<ServiceStartStop>) {
|
|||||||
if (type === 'taiga') {
|
if (type === 'taiga') {
|
||||||
return await startTaigaService(request)
|
return await startTaigaService(request)
|
||||||
}
|
}
|
||||||
|
if (type === 'trilium') {
|
||||||
|
return await startTriliumService(request)
|
||||||
|
}
|
||||||
|
|
||||||
throw `Service type ${type} not supported.`
|
throw `Service type ${type} not supported.`
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw { status: 500, message: error?.message || error }
|
throw { status: 500, message: error?.message || error }
|
||||||
@ -900,8 +904,8 @@ async function startMeilisearchService(request: FastifyRequest<ServiceStartStop>
|
|||||||
const {
|
const {
|
||||||
meiliSearch: { masterKey }
|
meiliSearch: { masterKey }
|
||||||
} = service;
|
} = service;
|
||||||
const { type, version, destinationDockerId, destinationDocker, serviceSecret, exposePort, persistentStorage } =
|
const { type, version, destinationDockerId, destinationDocker,
|
||||||
service;
|
serviceSecret, exposePort, persistentStorage } = service;
|
||||||
const network = destinationDockerId && destinationDocker.network;
|
const network = destinationDockerId && destinationDocker.network;
|
||||||
const port = getServiceMainPort('meilisearch');
|
const port = getServiceMainPort('meilisearch');
|
||||||
|
|
||||||
@ -2590,3 +2594,58 @@ async function startTaigaService(request: FastifyRequest<ServiceStartStop>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function startTriliumService(request: FastifyRequest<ServiceStartStop>) {
|
||||||
|
try {
|
||||||
|
const { id } = request.params;
|
||||||
|
const teamId = request.user.teamId;
|
||||||
|
const service = await getServiceFromDB({ id, teamId });
|
||||||
|
const { type, version, destinationDockerId, destinationDocker, serviceSecret, exposePort, persistentStorage } =
|
||||||
|
service;
|
||||||
|
const network = destinationDockerId && destinationDocker.network;
|
||||||
|
const port = getServiceMainPort('trilium');
|
||||||
|
|
||||||
|
const { workdir } = await createDirectories({ repository: type, buildId: id });
|
||||||
|
const image = getServiceImage(type);
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
trilium: {
|
||||||
|
image: `${image}:${version}`,
|
||||||
|
volumes: [`${id}-trilium:/home/node/trilium-data`],
|
||||||
|
environmentVariables: {}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (serviceSecret.length > 0) {
|
||||||
|
serviceSecret.forEach((secret) => {
|
||||||
|
config.trilium.environmentVariables[secret.name] = secret.value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const { volumeMounts } = persistentVolumes(id, persistentStorage, config)
|
||||||
|
const composeFile: ComposeFile = {
|
||||||
|
version: '3.8',
|
||||||
|
services: {
|
||||||
|
[id]: {
|
||||||
|
container_name: id,
|
||||||
|
image: config.trilium.image,
|
||||||
|
volumes: config.trilium.volumes,
|
||||||
|
environment: config.trilium.environmentVariables,
|
||||||
|
...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
|
||||||
|
labels: makeLabelForServices('trilium'),
|
||||||
|
...defaultComposeConfiguration(network),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
networks: {
|
||||||
|
[network]: {
|
||||||
|
external: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
volumes: volumeMounts
|
||||||
|
};
|
||||||
|
const composeFileDestination = `${workdir}/docker-compose.yaml`;
|
||||||
|
await fs.writeFile(composeFileDestination, yaml.dump(composeFile));
|
||||||
|
await startServiceContainers(destinationDocker.id, composeFileDestination)
|
||||||
|
return {}
|
||||||
|
} catch ({ status, message }) {
|
||||||
|
return errorHandler({ status, message })
|
||||||
|
}
|
||||||
|
}
|
@ -212,4 +212,15 @@ export const supportedServiceTypesAndVersions = [
|
|||||||
// main: 80
|
// main: 80
|
||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
|
{
|
||||||
|
name: 'trilium',
|
||||||
|
fancyName: 'Trilium Notes',
|
||||||
|
baseImage: 'zadam/trilium',
|
||||||
|
images: [],
|
||||||
|
versions: ['latest'],
|
||||||
|
recommendedVersion: 'latest',
|
||||||
|
ports: {
|
||||||
|
main: 8080
|
||||||
|
}
|
||||||
|
},
|
||||||
];
|
];
|
@ -42,4 +42,6 @@
|
|||||||
<Icons.Searxng {isAbsolute} />
|
<Icons.Searxng {isAbsolute} />
|
||||||
{:else if type === 'weblate'}
|
{:else if type === 'weblate'}
|
||||||
<Icons.Weblate {isAbsolute} />
|
<Icons.Weblate {isAbsolute} />
|
||||||
|
{:else if type === 'trilium'}
|
||||||
|
<Icons.Trilium {isAbsolute} />
|
||||||
{/if}
|
{/if}
|
||||||
|
9
apps/ui/src/lib/components/svg/services/Trilium.svelte
Normal file
9
apps/ui/src/lib/components/svg/services/Trilium.svelte
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
export let isAbsolute = false;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<img
|
||||||
|
alt="trilium logo"
|
||||||
|
class={isAbsolute ? 'w-9 h-9 absolute top-3 left-0 -m-3 -mt-5' : 'w-8 h-8 mx-auto'}
|
||||||
|
src="/trilium.png"
|
||||||
|
/>
|
@ -18,3 +18,4 @@ export { default as Moodle } from './Moodle.svelte';
|
|||||||
export { default as GlitchTip } from './GlitchTip.svelte';
|
export { default as GlitchTip } from './GlitchTip.svelte';
|
||||||
export { default as Searxng } from './Searxng.svelte';
|
export { default as Searxng } from './Searxng.svelte';
|
||||||
export { default as Weblate } from './Weblate.svelte';
|
export { default as Weblate } from './Weblate.svelte';
|
||||||
|
export { default as Trilium } from './Trilium.svelte'
|
@ -75,4 +75,8 @@
|
|||||||
<a href="https://weblate.org" target="_blank">
|
<a href="https://weblate.org" target="_blank">
|
||||||
<Icons.Weblate />
|
<Icons.Weblate />
|
||||||
</a>
|
</a>
|
||||||
|
{:else if service.type === 'trilium'}
|
||||||
|
<a href="https://github.com/zadam/trilium" target="_blank">
|
||||||
|
<Icons.Trilium />
|
||||||
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
|
BIN
apps/ui/static/trilium.png
Normal file
BIN
apps/ui/static/trilium.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
Loading…
x
Reference in New Issue
Block a user