diff --git a/src/lib/types/composeFile.ts b/src/lib/types/composeFile.ts new file mode 100644 index 000000000..b7e88210f --- /dev/null +++ b/src/lib/types/composeFile.ts @@ -0,0 +1,49 @@ +import { makeLabelForServices } from '../buildPacks/common'; + +export type ComposeFile = { + version: ComposerFileVersion; + services: Record; + networks: Record; + volumes?: Record; +}; + +export type ComposeFileService = { + container_name: string; + image?: string; + networks: string[]; + environment: Record; + volumes?: string[]; + ulimits?: unknown; + labels?: string[]; + restart: ComposeFileRestartOption; + depends_on?: string[]; + command?: string; + build?: string; +}; + +export type ComposerFileVersion = + | '3.8' + | '3.7' + | '3.6' + | '3.5' + | '3.4' + | '3.3' + | '3.2' + | '3.1' + | '3.0' + | '2.4' + | '2.3' + | '2.2' + | '2.1' + | '2.0'; + +export type ComposeFileRestartOption = 'no' | 'always' | 'on-failure' | 'unless-stopped'; + +export type ComposeFileNetwork = { + external: boolean; +}; + +export type ComposeFileVolume = { + external?: boolean; + name?: string; +}; diff --git a/src/routes/databases/[id]/start.json.ts b/src/routes/databases/[id]/start.json.ts index bca2995d4..59fd7c1ea 100644 --- a/src/routes/databases/[id]/start.json.ts +++ b/src/routes/databases/[id]/start.json.ts @@ -6,6 +6,7 @@ import yaml from 'js-yaml'; import type { RequestHandler } from '@sveltejs/kit'; import { makeLabelForStandaloneDatabase } from '$lib/buildPacks/common'; import { startTcpProxy } from '$lib/haproxy'; +import type { ComposeFile } from '$lib/types/composeFile'; export const post: RequestHandler = async (event) => { const { teamId, status, body } = await getUserDetails(event); @@ -33,7 +34,7 @@ export const post: RequestHandler = async (event) => { const { workdir } = await createDirectories({ repository: type, buildId: id }); - const composeFile = { + const composeFile: ComposeFile = { version: '3.8', services: { [id]: { diff --git a/src/routes/services/[id]/ghost/start.json.ts b/src/routes/services/[id]/ghost/start.json.ts index 4fd9e7fa4..9e0b4ba11 100644 --- a/src/routes/services/[id]/ghost/start.json.ts +++ b/src/routes/services/[id]/ghost/start.json.ts @@ -11,6 +11,7 @@ import yaml from 'js-yaml'; import type { RequestHandler } from '@sveltejs/kit'; import { ErrorHandler, getServiceImage } from '$lib/database'; import { makeLabelForServices } from '$lib/buildPacks/common'; +import type { ComposeFile } from '$lib/types/composeFile'; export const post: RequestHandler = async (event) => { const { teamId, status, body } = await getUserDetails(event); @@ -75,7 +76,7 @@ export const post: RequestHandler = async (event) => { config.ghost.environmentVariables[secret.name] = secret.value; }); } - const composeFile = { + const composeFile: ComposeFile = { version: '3.8', services: { [id]: { diff --git a/src/routes/services/[id]/languagetool/start.json.ts b/src/routes/services/[id]/languagetool/start.json.ts index a6a81d475..ac0f6a5bb 100644 --- a/src/routes/services/[id]/languagetool/start.json.ts +++ b/src/routes/services/[id]/languagetool/start.json.ts @@ -5,6 +5,7 @@ import yaml from 'js-yaml'; import type { RequestHandler } from '@sveltejs/kit'; import { ErrorHandler, getServiceImage } from '$lib/database'; import { makeLabelForServices } from '$lib/buildPacks/common'; +import type { ComposeFile } from '$lib/types/composeFile'; export const post: RequestHandler = async (event) => { const { teamId, status, body } = await getUserDetails(event); @@ -32,7 +33,7 @@ export const post: RequestHandler = async (event) => { config.environmentVariables[secret.name] = secret.value; }); } - const composeFile = { + const composeFile: ComposeFile = { version: '3.8', services: { [id]: { diff --git a/src/routes/services/[id]/meilisearch/start.json.ts b/src/routes/services/[id]/meilisearch/start.json.ts index 646a8b1ba..5a5a9d5c0 100644 --- a/src/routes/services/[id]/meilisearch/start.json.ts +++ b/src/routes/services/[id]/meilisearch/start.json.ts @@ -5,6 +5,7 @@ import yaml from 'js-yaml'; import type { RequestHandler } from '@sveltejs/kit'; import { ErrorHandler, getServiceImage } from '$lib/database'; import { makeLabelForServices } from '$lib/buildPacks/common'; +import type { ComposeFile } from '$lib/types/composeFile'; export const post: RequestHandler = async (event) => { const { teamId, status, body } = await getUserDetails(event); @@ -37,7 +38,7 @@ export const post: RequestHandler = async (event) => { config.environmentVariables[secret.name] = secret.value; }); } - const composeFile = { + const composeFile: ComposeFile = { version: '3.8', services: { [id]: { diff --git a/src/routes/services/[id]/minio/start.json.ts b/src/routes/services/[id]/minio/start.json.ts index bcffd9e8f..6e14a42ca 100644 --- a/src/routes/services/[id]/minio/start.json.ts +++ b/src/routes/services/[id]/minio/start.json.ts @@ -8,6 +8,7 @@ import getPort, { portNumbers } from 'get-port'; import { getDomain } from '$lib/components/common'; import { ErrorHandler, getServiceImage } from '$lib/database'; import { makeLabelForServices } from '$lib/buildPacks/common'; +import type { ComposeFile } from '$lib/types/composeFile'; export const post: RequestHandler = async (event) => { const { teamId, status, body } = await getUserDetails(event); @@ -55,7 +56,7 @@ export const post: RequestHandler = async (event) => { config.environmentVariables[secret.name] = secret.value; }); } - const composeFile = { + const composeFile: ComposeFile = { version: '3.8', services: { [id]: { diff --git a/src/routes/services/[id]/n8n/start.json.ts b/src/routes/services/[id]/n8n/start.json.ts index e5ad7e930..3df1855d0 100644 --- a/src/routes/services/[id]/n8n/start.json.ts +++ b/src/routes/services/[id]/n8n/start.json.ts @@ -5,6 +5,7 @@ import yaml from 'js-yaml'; import type { RequestHandler } from '@sveltejs/kit'; import { ErrorHandler, getServiceImage } from '$lib/database'; import { makeLabelForServices } from '$lib/buildPacks/common'; +import type { ComposeFile } from '$lib/types/composeFile'; export const post: RequestHandler = async (event) => { const { teamId, status, body } = await getUserDetails(event); @@ -33,7 +34,7 @@ export const post: RequestHandler = async (event) => { config.environmentVariables[secret.name] = secret.value; }); } - const composeFile = { + const composeFile: ComposeFile = { version: '3.8', services: { [id]: { diff --git a/src/routes/services/[id]/nocodb/start.json.ts b/src/routes/services/[id]/nocodb/start.json.ts index ebc59ce97..1642038b3 100644 --- a/src/routes/services/[id]/nocodb/start.json.ts +++ b/src/routes/services/[id]/nocodb/start.json.ts @@ -5,6 +5,7 @@ import yaml from 'js-yaml'; import type { RequestHandler } from '@sveltejs/kit'; import { ErrorHandler, getServiceImage } from '$lib/database'; import { makeLabelForServices } from '$lib/buildPacks/common'; +import type { ComposeFile } from '$lib/types/composeFile'; export const post: RequestHandler = async (event) => { const { teamId, status, body } = await getUserDetails(event); @@ -30,7 +31,7 @@ export const post: RequestHandler = async (event) => { config.environmentVariables[secret.name] = secret.value; }); } - const composeFile = { + const composeFile: ComposeFile = { version: '3.8', services: { [id]: { diff --git a/src/routes/services/[id]/plausibleanalytics/start.json.ts b/src/routes/services/[id]/plausibleanalytics/start.json.ts index 836bd0178..6ca37c5e8 100644 --- a/src/routes/services/[id]/plausibleanalytics/start.json.ts +++ b/src/routes/services/[id]/plausibleanalytics/start.json.ts @@ -5,6 +5,7 @@ import yaml from 'js-yaml'; import type { RequestHandler } from '@sveltejs/kit'; import { ErrorHandler, getServiceImage } from '$lib/database'; import { makeLabelForServices } from '$lib/buildPacks/common'; +import type { ComposeFile } from '$lib/types/composeFile'; export const post: RequestHandler = async (event) => { const { teamId, status, body } = await getUserDetails(event); @@ -120,7 +121,7 @@ COPY ./init.query /docker-entrypoint-initdb.d/init.query COPY ./init-db.sh /docker-entrypoint-initdb.d/init-db.sh`; await fs.writeFile(`${workdir}/Dockerfile`, Dockerfile); - const composeFile = { + const composeFile: ComposeFile = { version: '3.8', services: { [id]: { diff --git a/src/routes/services/[id]/uptimekuma/start.json.ts b/src/routes/services/[id]/uptimekuma/start.json.ts index 845873bb0..7a72326e1 100644 --- a/src/routes/services/[id]/uptimekuma/start.json.ts +++ b/src/routes/services/[id]/uptimekuma/start.json.ts @@ -5,6 +5,7 @@ import yaml from 'js-yaml'; import type { RequestHandler } from '@sveltejs/kit'; import { ErrorHandler, getServiceImage } from '$lib/database'; import { makeLabelForServices } from '$lib/buildPacks/common'; +import type { ComposeFile } from '$lib/types/composeFile'; export const post: RequestHandler = async (event) => { const { teamId, status, body } = await getUserDetails(event); @@ -31,7 +32,7 @@ export const post: RequestHandler = async (event) => { config.environmentVariables[secret.name] = secret.value; }); } - const composeFile = { + const composeFile: ComposeFile = { version: '3.8', services: { [id]: { diff --git a/src/routes/services/[id]/vaultwarden/start.json.ts b/src/routes/services/[id]/vaultwarden/start.json.ts index f977adda3..ae13d9015 100644 --- a/src/routes/services/[id]/vaultwarden/start.json.ts +++ b/src/routes/services/[id]/vaultwarden/start.json.ts @@ -5,6 +5,7 @@ import yaml from 'js-yaml'; import type { RequestHandler } from '@sveltejs/kit'; import { getServiceImage, ErrorHandler } from '$lib/database'; import { makeLabelForServices } from '$lib/buildPacks/common'; +import type { ComposeFile } from '$lib/types/composeFile'; export const post: RequestHandler = async (event) => { const { teamId, status, body } = await getUserDetails(event); @@ -32,7 +33,7 @@ export const post: RequestHandler = async (event) => { config.environmentVariables[secret.name] = secret.value; }); } - const composeFile = { + const composeFile: ComposeFile = { version: '3.8', services: { [id]: { diff --git a/src/routes/services/[id]/vscodeserver/start.json.ts b/src/routes/services/[id]/vscodeserver/start.json.ts index 6f51fcf2a..dbe0c120c 100644 --- a/src/routes/services/[id]/vscodeserver/start.json.ts +++ b/src/routes/services/[id]/vscodeserver/start.json.ts @@ -5,6 +5,7 @@ import yaml from 'js-yaml'; import type { RequestHandler } from '@sveltejs/kit'; import { ErrorHandler, getServiceImage } from '$lib/database'; import { makeLabelForServices } from '$lib/buildPacks/common'; +import type { ComposeFile } from '$lib/types/composeFile'; export const post: RequestHandler = async (event) => { const { teamId, status, body } = await getUserDetails(event); @@ -41,7 +42,7 @@ export const post: RequestHandler = async (event) => { config.environmentVariables[secret.name] = secret.value; }); } - const composeFile = { + const composeFile: ComposeFile = { version: '3.8', services: { [id]: { diff --git a/src/routes/services/[id]/wordpress/start.json.ts b/src/routes/services/[id]/wordpress/start.json.ts index 98e7d6aab..c0a28e0bd 100644 --- a/src/routes/services/[id]/wordpress/start.json.ts +++ b/src/routes/services/[id]/wordpress/start.json.ts @@ -5,6 +5,7 @@ import yaml from 'js-yaml'; import type { RequestHandler } from '@sveltejs/kit'; import { ErrorHandler, getServiceImage } from '$lib/database'; import { makeLabelForServices } from '$lib/buildPacks/common'; +import type { ComposeFile } from '$lib/types/composeFile'; export const post: RequestHandler = async (event) => { const { teamId, status, body } = await getUserDetails(event); @@ -65,7 +66,7 @@ export const post: RequestHandler = async (event) => { config.wordpress.environmentVariables[secret.name] = secret.value; }); } - const composeFile = { + const composeFile: ComposeFile = { version: '3.8', services: { [id]: {