diff --git a/Dockerfile b/Dockerfile index 72c3543..ea4e217 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,12 +43,12 @@ COPY --from=builder /build/${BINARY_NAME} ./app # Copy migrations directory COPY --from=builder /build/migrations ./migrations -COPY config.yaml . -COPY db.yaml . -COPY ui.html . -COPY ui_dbedit.html . -COPY ui_admin_chats.html . -COPY ui_admin_login.html . +# Create necessary directories +RUN mkdir -p config web_templates + +# Copy config and template files +COPY --from=builder /build/config/ ./config/ +COPY --from=builder /build/web_templates/ ./web_templates/ EXPOSE 8080 # Run binary directly ENTRYPOINT ["./app"] diff --git a/Makefile b/Makefile index a59373e..71afcc1 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ DB_SSLMODE ?= disable db_env = PGHOST=$(DB_HOST) PGPORT=$(DB_PORT) PGUSER=$(DB_USER) PGPASSWORD=$(DB_PASSWORD) PGDATABASE=$(DB_NAME) PGSSLMODE=$(DB_SSLMODE) # Run the Go server (assumes Ollama is running) with DB env vars -run: ollama-pull +run: $(db_env) OPENAI_API_KEY=ollama OPENAI_BASE_URL=http://localhost:11434/api/chat OPENAI_MODEL=qwen3:latest go run . # Run without pulling model (faster if already present) diff --git a/config.yaml b/config/config.yaml similarity index 100% rename from config.yaml rename to config/config.yaml diff --git a/db.yaml b/config/db.yaml similarity index 100% rename from db.yaml rename to config/db.yaml diff --git a/maindb.yaml b/config/maindb.yaml similarity index 100% rename from maindb.yaml rename to config/maindb.yaml diff --git a/controllers.go b/controllers.go index ee2c453..b88a68a 100644 --- a/controllers.go +++ b/controllers.go @@ -67,7 +67,7 @@ func (ctrl *Controller) AdminUI(c *gin.Context) { // Handler for download db.yaml func (ctrl *Controller) DownloadDB(c *gin.Context) { - c.File("db.yaml") + c.File("config/db.yaml") } // Handler for saving knowledgeModel (snapshot) diff --git a/db.go b/db.go index 8de8842..e602410 100644 --- a/db.go +++ b/db.go @@ -45,9 +45,9 @@ func (vdb *VisitDB) init() { } else { panic(err) } - err := vdb.loadYAMLDB("db.yaml") + err := vdb.loadYAMLDB("config/db.yaml") if err != nil { - logrus.Fatalf("Failed to load db.yaml: %v", err) + logrus.Fatalf("Failed to load config/db.yaml: %v", err) panic(err) } } diff --git a/main.go b/main.go index 3ac965d..9ff1ba1 100644 --- a/main.go +++ b/main.go @@ -27,22 +27,22 @@ func main() { logrus.SetFormatter(&logrus.TextFormatter{FullTimestamp: true}) logrus.SetLevel(logrus.InfoLevel) - if err := loadConfig("config.yaml"); err != nil { - logrus.Fatalf("Failed to load config.yaml: %v", err) + if err := loadConfig("config/config.yaml"); err != nil { + logrus.Fatalf("Failed to load config/config.yaml: %v", err) } logrus.Infof("Loaded config: %+v", appConfig) visitDB := NewVisitDB() - if err := loadUITemplate("ui.html"); err != nil { - logrus.Fatalf("Failed to load ui.html: %v", err) + if err := loadUITemplate("web_templates/ui.html"); err != nil { + logrus.Fatalf("Failed to load web_templates/ui.html: %v", err) } - if err := loadDBEditTemplate("ui_dbedit.html"); err != nil { - logrus.Fatalf("Failed to load ui_dbedit.html: %v", err) + if err := loadDBEditTemplate("web_templates/ui_dbedit.html"); err != nil { + logrus.Fatalf("Failed to load web_templates/ui_dbedit.html: %v", err) } - if err := loadAdminChatsTemplate("ui_admin_chats.html"); err != nil { - logrus.Fatalf("Failed to load ui_admin_chats.html: %v", err) + if err := loadAdminChatsTemplate("web_templates/ui_admin_chats.html"); err != nil { + logrus.Fatalf("Failed to load web_templates/ui_admin_chats.html: %v", err) } - uiAdminLoginTmpl := &TemplateWrapper{Tmpl: template.Must(template.ParseFiles("ui_admin_login.html"))} + uiAdminLoginTmpl := &TemplateWrapper{Tmpl: template.Must(template.ParseFiles("web_templates/ui_admin_login.html"))} // Initialize PostgreSQL repository first dsn := buildDefaultDSN() diff --git a/run.sh b/scripts/run.sh similarity index 100% rename from run.sh rename to scripts/run.sh diff --git a/test.sh b/scripts/test.sh similarity index 100% rename from test.sh rename to scripts/test.sh diff --git a/test_copy.sh b/scripts/test_copy.sh similarity index 100% rename from test_copy.sh rename to scripts/test_copy.sh diff --git a/ui.html b/web_templates/ui.html similarity index 100% rename from ui.html rename to web_templates/ui.html diff --git a/ui_admin_chats.html b/web_templates/ui_admin_chats.html similarity index 100% rename from ui_admin_chats.html rename to web_templates/ui_admin_chats.html diff --git a/ui_admin_login.html b/web_templates/ui_admin_login.html similarity index 100% rename from ui_admin_login.html rename to web_templates/ui_admin_login.html diff --git a/ui_dbedit.html b/web_templates/ui_dbedit.html similarity index 100% rename from ui_dbedit.html rename to web_templates/ui_dbedit.html