MCPcopy
hub / github.com/Dokploy/dokploy / duplicateService

Function duplicateService

apps/dokploy/server/api/routers/project.ts:862–1192  ·  view source on GitHub ↗
(id: string, type: string)

Source from the content-addressed store, hash-verified

860 const servicesToDuplicate = input.selectedServices || [];
861
862 const duplicateService = async (id: string, type: string) => {
863 switch (type) {
864 case "application": {
865 const {
866 applicationId,
867 domains,
868 security,
869 ports,
870 registry,
871 redirects,
872 previewDeployments,
873 mounts,
874 appName,
875 refreshToken,
876 ...application
877 } = await findApplicationById(id);
878 const newAppName = appName.substring(
879 0,
880 appName.lastIndexOf("-"),
881 );
882
883 const newApplication = await createApplication({
884 ...application,
885 appName: newAppName,
886 name: input.duplicateInSameProject
887 ? `${application.name} (copy)`
888 : application.name,
889 environmentId: targetProject?.environmentId || "",
890 });
891
892 for (const domain of domains) {
893 const { domainId, ...rest } = domain;
894 await createDomain({
895 ...rest,
896 applicationId: newApplication.applicationId,
897 domainType: "application",
898 });
899 }
900
901 for (const port of ports) {
902 const { portId, ...rest } = port;
903 await createPort({
904 ...rest,
905 applicationId: newApplication.applicationId,
906 });
907 }
908
909 for (const mount of mounts) {
910 const { mountId, ...rest } = mount;
911 await createMount({
912 ...rest,
913 serviceId: newApplication.applicationId,
914 serviceType: "application",
915 });
916 }
917
918 for (const redirect of redirects) {
919 const { redirectId, ...rest } = redirect;

Callers 1

project.tsFile · 0.85

Calls 15

findApplicationByIdFunction · 0.90
createApplicationFunction · 0.90
createDomainFunction · 0.90
createPortFunction · 0.90
createMountFunction · 0.90
createRedirectFunction · 0.90
createSecurityFunction · 0.90
createPreviewDeploymentFunction · 0.90
findComposeByIdFunction · 0.90
createComposeFunction · 0.90
findLibsqlByIdFunction · 0.90
createLibsqlFunction · 0.90

Tested by

no test coverage detected