From 71f3fecc48528d4b2c005b6410a54fcddb4596eb Mon Sep 17 00:00:00 2001 From: Andres Morey Date: Mon, 4 Mar 2024 01:46:10 +0300 Subject: [PATCH] Fixes issue with missing template directory in docker image (#30) Fixes https://github.com/kubetail-org/kubetail/issues/29 --- Dockerfile | 3 +++ backend/internal/ginapp/ginapp.go | 11 ++++++----- hack/config.yaml | 32 +++++++++++++++++++++++++------ 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2a3d43eb..50e5cde0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -69,6 +69,8 @@ COPY --from=backend-builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ # copy backend COPY --from=backend-builder /backend/server /app/server +COPY --from=backend-builder /backend/templates /app/templates + # copy frontend COPY --from=frontend-builder /frontend/dist /app/website @@ -87,6 +89,7 @@ COPY --from=backend-builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ # copy backend COPY --from=backend-builder /backend/server /app/server +COPY --from=backend-builder /backend/templates /app/templates # copy frontend COPY --from=frontend-builder /frontend/dist /app/website diff --git a/backend/internal/ginapp/ginapp.go b/backend/internal/ginapp/ginapp.go index 0fc228c2..a2c8a48b 100644 --- a/backend/internal/ginapp/ginapp.go +++ b/backend/internal/ginapp/ginapp.go @@ -16,9 +16,8 @@ package ginapp import ( "net/http" + "os" "path" - "path/filepath" - "runtime" "github.com/gin-contrib/gzip" "github.com/gin-contrib/requestid" @@ -72,9 +71,11 @@ func NewGinApp(config Config) (*GinApp, error) { }) } - // get project basepath - _, b, _, _ := runtime.Caller(0) - basepath := path.Join(filepath.Dir(b), "../../") + // get project basepath (use working directory for now) + basepath, err := os.Getwd() + if err != nil { + panic(err) + } // register templates app.SetHTMLTemplate(mustLoadTemplatesWithFuncs(path.Join(basepath, "templates/*"))) diff --git a/hack/config.yaml b/hack/config.yaml index 08397bc3..bf2f3a2d 100644 --- a/hack/config.yaml +++ b/hack/config.yaml @@ -42,6 +42,14 @@ gin-mode: release # kube-config: ${HOME}/.kube/config +## base-path ## +# +# Sets the url path prefix (useful for deploying on a sub-path behind a reverse proxy) +# +# Default value: / +# +base-path: / + ## csrf ## # csrf: @@ -156,13 +164,25 @@ logging: # format: json - ## access-log-enabled ## + ## access-log ## # - # Enables web access logs for app - # - # Default value: true - # - access-log-enabled: true + access-log: + + ## enabled ## + # + # Enables web access logs for app + # + # Default value: true + # + enabled: true + + ## hide-health-checks ## + # + # Hides health checks from access log + # + # Default: false + # + hide-health-checks: false ## session ## #