MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / makeAppComposeFile

Function makeAppComposeFile

vmm/ui/src/composables/useVmManager.ts:712–768  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

710 }
711
712 async function makeAppComposeFile() {
713 const appCompose: Record<string, unknown> = {
714 manifest_version: 2,
715 name: vmForm.value.name,
716 runner: 'docker-compose',
717 docker_compose_file: vmForm.value.dockerComposeFile,
718 gateway_enabled: vmForm.value.gateway_enabled,
719 public_logs: vmForm.value.public_logs,
720 public_sysinfo: vmForm.value.public_sysinfo,
721 public_tcbinfo: vmForm.value.public_tcbinfo,
722 key_provider_id: vmForm.value.key_provider_id,
723 allowed_envs: vmForm.value.encryptedEnvs.map((env) => env.key),
724 no_instance_id: !vmForm.value.gateway_enabled,
725 secure_time: false,
726 };
727
728 if (vmForm.value.key_provider !== undefined) {
729 appCompose.key_provider = vmForm.value.key_provider;
730
731 // For backward compatibility
732 if (vmForm.value.key_provider === 'kms') {
733 appCompose.kms_enabled = true;
734 }
735 if (vmForm.value.key_provider === 'local') {
736 appCompose.local_key_provider_enabled = true;
737 }
738 }
739
740 if (vmForm.value.storage_fs) {
741 appCompose.storage_fs = vmForm.value.storage_fs;
742 }
743
744 if (vmForm.value.initScript?.trim()) {
745 appCompose.init_script = vmForm.value.initScript;
746 }
747
748 if (vmForm.value.preLaunchScript?.trim()) {
749 appCompose.pre_launch_script = vmForm.value.preLaunchScript;
750 }
751
752 const swapBytes = Math.max(0, Math.round(vmForm.value.swap_size || 0));
753 if (swapBytes > 0) {
754 appCompose.swap_size = swapBytes;
755 }
756
757 const launchToken = vmForm.value.encryptedEnvs.find((env) => env.key === 'APP_LAUNCH_TOKEN');
758 if (launchToken) {
759 appCompose.launch_token_hash = await calcComposeHash(launchToken.value);
760 }
761
762 const imgFeatures = imageVersionFeatures(imageVersion(vmForm.value.image));
763 if (imgFeatures.compose_version < 3) {
764 appCompose.tproxy_enabled = appCompose.gateway_enabled;
765 delete appCompose.gateway_enabled;
766 }
767 return JSON.stringify(appCompose);
768 }
769

Callers 3

useVmManagerFunction · 0.85
encryptEnvFunction · 0.85
createVmFunction · 0.85

Calls 3

calcComposeHashFunction · 0.85
imageVersionFeaturesFunction · 0.85
imageVersionFunction · 0.85

Tested by

no test coverage detected