Skip to content

Commit

Permalink
Fixes issue with missing template directory in docker image (#30)
Browse files Browse the repository at this point in the history
Fixes #29
  • Loading branch information
amorey authored Mar 3, 2024
1 parent 540b0cf commit 71f3fec
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
11 changes: 6 additions & 5 deletions backend/internal/ginapp/ginapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ package ginapp

import (
"net/http"
"os"
"path"
"path/filepath"
"runtime"

"github.com/gin-contrib/gzip"
"github.com/gin-contrib/requestid"
Expand Down Expand Up @@ -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/*")))
Expand Down
32 changes: 26 additions & 6 deletions hack/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 ##
#
Expand Down

0 comments on commit 71f3fec

Please sign in to comment.