fix: Correct Swagger spec template path discovery (#5078)

* fix: Correct Swagger spec template path discovery

* fix: removed unneeded init function
diff --git a/backend/Dockerfile b/backend/Dockerfile
index f388457..99b8c79 100644
--- a/backend/Dockerfile
+++ b/backend/Dockerfile
@@ -142,7 +142,7 @@
 RUN curl -sSL https://install.python-poetry.org | python3 -
 RUN ln -sf /root/.local/bin/poetry /usr/local/bin
 # Build Python plugins
-RUN find /app/python/ -name "*.sh" | xargs -I{} chmod +x {} 
+RUN find /app/python/ -name "*.sh" | xargs -I{} chmod +x {}
 RUN /app/python/build.sh
 
 
@@ -156,7 +156,7 @@
 
 # apps
 COPY --from=build /app/bin /app/bin
-COPY --from=build /app/resources/tap /app/resources/tap
+COPY --from=build /app/resources /app/resources
 
 ENV PATH="/app/bin:${PATH}"
 
diff --git a/backend/core/config/config_viper.go b/backend/core/config/config_viper.go
index c05165b..4302f2d 100644
--- a/backend/core/config/config_viper.go
+++ b/backend/core/config/config_viper.go
@@ -76,6 +76,7 @@
 	v.SetDefault("TEMPORAL_TASK_QUEUE", "DEVLAKE_TASK_QUEUE")
 	v.SetDefault("TAP_PROPERTIES_DIR", "resources/tap")
 	v.SetDefault("REMOTE_PLUGIN_DIR", "python/plugins")
+	v.SetDefault("SWAGGER_DOCS_DIR", "resources/swagger")
 }
 
 // replaceNewEnvItemInOldContent replace old config to new config in env file content
diff --git a/backend/server/services/remote/plugin/doc/open_api_spec.json.tmpl b/backend/resources/swagger/open_api_spec.json.tmpl
similarity index 100%
rename from backend/server/services/remote/plugin/doc/open_api_spec.json.tmpl
rename to backend/resources/swagger/open_api_spec.json.tmpl
diff --git a/backend/server/services/remote/plugin/doc/open_api.go b/backend/server/services/remote/plugin/doc/open_api.go
index 811c193..1d0e2db 100644
--- a/backend/server/services/remote/plugin/doc/open_api.go
+++ b/backend/server/services/remote/plugin/doc/open_api.go
@@ -19,10 +19,10 @@
 
 import (
 	"encoding/json"
+	"github.com/apache/incubator-devlake/core/config"
 	"io"
 	"os"
-	"path"
-	"runtime"
+	"path/filepath"
 	"strings"
 	"text/template"
 
@@ -62,7 +62,11 @@
 }
 
 func specTemplate() (*template.Template, errors.Error) {
-	file, err := os.Open(specTemplatePath())
+	path := config.GetConfig().GetString("SWAGGER_DOCS_DIR")
+	if path == "" {
+		return nil, errors.Default.New("path for Swagger docs resources is not set")
+	}
+	file, err := os.Open(filepath.Join(path, "open_api_spec.json.tmpl"))
 	if err != nil {
 		return nil, errors.Default.Wrap(err, "could not open swagger doc template")
 	}
@@ -76,8 +80,3 @@
 	}
 	return specTemplate, nil
 }
-
-func specTemplatePath() string {
-	_, currentFile, _, _ := runtime.Caller(0)
-	return path.Join(path.Dir(currentFile), "open_api_spec.json.tmpl")
-}