Extend typings
This commit is contained in:
		
							parent
							
								
									a7ed3e58db
								
							
						
					
					
						commit
						d18bb9cc74
					
				| @ -20,12 +20,9 @@ import { | |||||||
| 	setDefaultConfiguration | 	setDefaultConfiguration | ||||||
| } from '$lib/buildPacks/common'; | } from '$lib/buildPacks/common'; | ||||||
| import yaml from 'js-yaml'; | import yaml from 'js-yaml'; | ||||||
|  | import type { ComposeFile } from '$lib/types/composeFile'; | ||||||
| 
 | 
 | ||||||
| export default async function (job) { | export default async function (job) { | ||||||
| 	/* |  | ||||||
| 	Edge cases: |  | ||||||
| 	1 - Change build pack and redeploy, what should happen? |  | ||||||
|   */ |  | ||||||
| 	let { | 	let { | ||||||
| 		id: applicationId, | 		id: applicationId, | ||||||
| 		repository, | 		repository, | ||||||
| @ -274,7 +271,7 @@ export default async function (job) { | |||||||
| 					} | 					} | ||||||
| 				}; | 				}; | ||||||
| 			}); | 			}); | ||||||
| 			const compose = { | 			const composeFile: ComposeFile = { | ||||||
| 				version: '3.8', | 				version: '3.8', | ||||||
| 				services: { | 				services: { | ||||||
| 					[imageId]: { | 					[imageId]: { | ||||||
| @ -283,7 +280,7 @@ export default async function (job) { | |||||||
| 						volumes, | 						volumes, | ||||||
| 						env_file: envFound ? [`${workdir}/.env`] : [], | 						env_file: envFound ? [`${workdir}/.env`] : [], | ||||||
| 						networks: [docker.network], | 						networks: [docker.network], | ||||||
| 						labels: labels, | 						labels, | ||||||
| 						depends_on: [], | 						depends_on: [], | ||||||
| 						restart: 'always' | 						restart: 'always' | ||||||
| 					} | 					} | ||||||
| @ -295,7 +292,7 @@ export default async function (job) { | |||||||
| 				}, | 				}, | ||||||
| 				volumes: Object.assign({}, ...composeVolumes) | 				volumes: Object.assign({}, ...composeVolumes) | ||||||
| 			}; | 			}; | ||||||
| 			await fs.writeFile(`${workdir}/docker-compose.yml`, yaml.dump(compose)); | 			await fs.writeFile(`${workdir}/docker-compose.yml`, yaml.dump(composeFile)); | ||||||
| 			await asyncExecShell( | 			await asyncExecShell( | ||||||
| 				`DOCKER_HOST=${host} docker compose --project-directory ${workdir} up -d` | 				`DOCKER_HOST=${host} docker compose --project-directory ${workdir} up -d` | ||||||
| 			); | 			); | ||||||
|  | |||||||
| @ -1,5 +1,3 @@ | |||||||
| import { makeLabelForServices } from '../buildPacks/common'; |  | ||||||
| 
 |  | ||||||
| export type ComposeFile = { | export type ComposeFile = { | ||||||
| 	version: ComposerFileVersion; | 	version: ComposerFileVersion; | ||||||
| 	services: Record<string, ComposeFileService>; | 	services: Record<string, ComposeFileService>; | ||||||
| @ -11,10 +9,12 @@ export type ComposeFileService = { | |||||||
| 	container_name: string; | 	container_name: string; | ||||||
| 	image?: string; | 	image?: string; | ||||||
| 	networks: string[]; | 	networks: string[]; | ||||||
| 	environment: Record<string, unknown>; | 	environment?: Record<string, unknown>; | ||||||
| 	volumes?: string[]; | 	volumes?: string[]; | ||||||
| 	ulimits?: unknown; | 	ulimits?: unknown; | ||||||
| 	labels?: string[]; | 	labels?: string[]; | ||||||
|  | 	env_file?: string[]; | ||||||
|  | 	extra_hosts?: string[]; | ||||||
| 	restart: ComposeFileRestartOption; | 	restart: ComposeFileRestartOption; | ||||||
| 	depends_on?: string[]; | 	depends_on?: string[]; | ||||||
| 	command?: string; | 	command?: string; | ||||||
|  | |||||||
| @ -4,6 +4,7 @@ import { decrypt, encrypt } from '$lib/crypto'; | |||||||
| import * as db from '$lib/database'; | import * as db from '$lib/database'; | ||||||
| import { generateDatabaseConfiguration, ErrorHandler, generatePassword } from '$lib/database'; | import { generateDatabaseConfiguration, ErrorHandler, generatePassword } from '$lib/database'; | ||||||
| import { checkContainer, startTcpProxy, stopTcpHttpProxy } from '$lib/haproxy'; | import { checkContainer, startTcpProxy, stopTcpHttpProxy } from '$lib/haproxy'; | ||||||
|  | import type { ComposeFile } from '$lib/types/composeFile'; | ||||||
| import type { RequestHandler } from '@sveltejs/kit'; | import type { RequestHandler } from '@sveltejs/kit'; | ||||||
| import cuid from 'cuid'; | import cuid from 'cuid'; | ||||||
| import fs from 'fs/promises'; | import fs from 'fs/promises'; | ||||||
| @ -108,7 +109,7 @@ export const post: RequestHandler = async (event) => { | |||||||
| 					}/${id}.sh:/etc/sftp.d/chmod.sh` | 					}/${id}.sh:/etc/sftp.d/chmod.sh` | ||||||
| 				]; | 				]; | ||||||
| 
 | 
 | ||||||
| 				const compose = { | 				const compose: ComposeFile = { | ||||||
| 					version: '3.8', | 					version: '3.8', | ||||||
| 					services: { | 					services: { | ||||||
| 						[`${id}-ftp`]: { | 						[`${id}-ftp`]: { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user