Skip to content

Commit

Permalink
put templates in /app, force docroot opt to be provided
Browse files Browse the repository at this point in the history
  • Loading branch information
xvandish committed Jan 1, 2025
1 parent 44d10cc commit ac67aa9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Dockerfile.fileviewer
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ RUN apk add --no-cache ca-certificates bind-tools tini
# We copy from the locally built zoekt image
COPY --from=zoekt /usr/local/bin/zoekt-fileviewer /usr/local/bin/

# Create the /app directory
RUN mkdir -p /app

# Copy the templates folder
COPY cmd/zoekt-fileviewer/templates /usr/local/bin/templates
COPY cmd/zoekt-fileviewer/templates /app/templates

# zoekt-webserver has a large stable heap size (10s of gigs), and as such the
# default GOGC=100 could be better tuned. https://dave.cheney.net/tag/gogc
Expand Down
6 changes: 5 additions & 1 deletion cmd/zoekt-fileviewer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
var (
zoektRepoCache = flag.String("zoekt-repo-cache", "", "path to zoekt bare git repos")
listen = flag.String("listen", ":8080", "listen on this address.")
docRoot = flag.String("doc-root", "", "where to find runtime files")
)

const (
Expand All @@ -40,11 +41,14 @@ func main() {
if *zoektRepoCache == "" {
log.Fatal("--zoekt-repo-cache is required")
}
if *docRoot == "" {
log.Fatal("--doc-root is required")
}

// Create server configuration
cfg := &config{
ZoektRepoCache: *zoektRepoCache,
DocRoot: ".",
DocRoot: *docRoot,
ReadTimeout: 30 * time.Second,
WriteTimeout: 30 * time.Second,
Port: *listen,
Expand Down
1 change: 0 additions & 1 deletion cmd/zoekt-fileviewer/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,6 @@ func getFuncs() map[string]interface{} {
}

func LoadTemplates(base string, templates map[string]*template.Template) error {
log.Printf("in LoadTemplates\n")
pattern := base + "/templates/common/*.html"
common := template.New("").Funcs(getFuncs())
common = template.Must(common.ParseGlob(pattern))
Expand Down

0 comments on commit ac67aa9

Please sign in to comment.