Skip to content

Commit fb321f7

Browse files
authored
Merge pull request #78 from P4PER/feat/add-chisel-to-templates
feat: add Chisel app template and SVG icon for service availability
2 parents dac7827 + a403bb0 commit fb321f7

4 files changed

Lines changed: 93 additions & 1 deletion

File tree

public/template-icons/chisel.svg

Lines changed: 6 additions & 0 deletions
Loading

src/server/services/app.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ class AppService {
185185
// for new objects, make sure some params are optional, wich will be created by prisma
186186
const optionalParam = z.object({
187187
id: z.string().optional(),
188+
appId: z.string().optional(),
188189
createdAt: z.date().optional(),
189190
updatedAt: z.date().optional(),
190191
});

src/shared/templates/all.templates.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import { openwebuiAppTemplate, postCreateOpenwebuiAppTemplate } from "./apps/ope
4444
import { AppExtendedModel } from "../model/app-extended.model";
4545
import { tikaAppTemplate } from "./apps/tika.template";
4646
import { libredeskAppTemplate, postCreateLibredeskAppTemplate } from "./apps/libredesk.template";
47+
import { chiselAppTemplate, postCreateChiselAppTemplate } from "./apps/chisel.template";
4748

4849

4950
export const databaseTemplates: AppTemplateModel[] = [
@@ -95,7 +96,8 @@ export const appTemplates: AppTemplateModel[] = [
9596
duplicatiAppTemplate,
9697
openwebuiAppTemplate,
9798
tikaAppTemplate,
98-
libredeskAppTemplate
99+
libredeskAppTemplate,
100+
chiselAppTemplate
99101
];
100102

101103
export const postCreateTemplateFunctions: Map<string, (createdApps: AppExtendedModel[]) => Promise<AppExtendedModel[]>> = new Map([
@@ -105,6 +107,7 @@ export const postCreateTemplateFunctions: Map<string, (createdApps: AppExtendedM
105107
[docmostAppTemplate.name, postCreateDocmostAppTemplate],
106108
[duplicatiAppTemplate.name, postCreateDuplicatiAppTemplate],
107109
[n8nAppTemplate.name, postCreateN8NAppTemplate],
110+
[chiselAppTemplate.name, postCreateChiselAppTemplate],
108111
]);
109112

110113

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import { Constants } from "@/shared/utils/constants";
2+
import { AppTemplateContentModel, AppTemplateModel } from "../../model/app-template.model";
3+
import { AppExtendedModel } from "@/shared/model/app-extended.model";
4+
import crypto from "crypto";
5+
6+
export function getChiselAppTemplate(config?: {
7+
appName?: string,
8+
username?: string,
9+
password?: string
10+
}): AppTemplateContentModel {
11+
return {
12+
inputSettings: [
13+
{
14+
key: "containerImageSource",
15+
label: "Container Image",
16+
value: "jpillora/chisel:latest",
17+
isEnvVar: false,
18+
randomGeneratedIfEmpty: false,
19+
},
20+
{
21+
key: "CHISEL_USER",
22+
label: "Username",
23+
value: config?.username || "chisel",
24+
isEnvVar: true,
25+
randomGeneratedIfEmpty: false,
26+
},
27+
{
28+
key: "CHISEL_PASSWORD",
29+
label: "Password",
30+
value: config?.password || "",
31+
isEnvVar: true,
32+
randomGeneratedIfEmpty: true,
33+
},
34+
],
35+
appModel: {
36+
name: config?.appName || "Chisel Tunnel",
37+
appType: 'APP',
38+
sourceType: 'CONTAINER',
39+
containerImageSource: "",
40+
replicas: 1,
41+
ingressNetworkPolicy: Constants.DEFAULT_INGRESS_NETWORK_POLICY_APPS,
42+
egressNetworkPolicy: Constants.DEFAULT_EGRESS_NETWORK_POLICY_APPS,
43+
envVars: ``,
44+
useNetworkPolicy: true,
45+
healthCheckPeriodSeconds: Constants.DEFAULT_HEALTH_CHECK_PERIOD_SECONDS,
46+
healthCheckTimeoutSeconds: Constants.DEFAULT_HEALTH_CHECK_TIMEOUT_SECONDS,
47+
healthCheckFailureThreshold: Constants.DEFAULT_HEALTH_CHECK_FAILURE_THRESHOLD,
48+
containerArgs: '["server", "--keyfile", "/etc/chisel/chisel.key", "--auth", "$(CHISEL_USER):$(CHISEL_PASSWORD)", "--reverse"]',
49+
},
50+
appDomains: [],
51+
appVolumes: [],
52+
appFileMounts: [],
53+
appPorts: [{
54+
port: 8080,
55+
}],
56+
};
57+
}
58+
59+
export const chiselAppTemplate: AppTemplateModel = {
60+
name: "Chisel Tunnel",
61+
iconName: 'chisel.svg',
62+
templates: [
63+
getChiselAppTemplate()
64+
],
65+
};
66+
67+
export const postCreateChiselAppTemplate = async (createdApps: AppExtendedModel[]): Promise<AppExtendedModel[]> => {
68+
const app = createdApps[0];
69+
70+
const { privateKey } = crypto.generateKeyPairSync('ec', {
71+
namedCurve: 'P-256',
72+
privateKeyEncoding: { type: 'sec1', format: 'pem' },
73+
publicKeyEncoding: { type: 'spki', format: 'pem' },
74+
});
75+
76+
app.appFileMounts.push({
77+
containerMountPath: '/etc/chisel/chisel.key',
78+
content: privateKey,
79+
} as any);
80+
81+
return [app];
82+
};

0 commit comments

Comments
 (0)