diff --git a/Dockerfile b/Dockerfile index be29126..bdd4384 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ FROM golang:alpine AS builder RUN apk add build-base -COPY src /src -RUN cd /src && go build . +COPY . /src +RUN cd /src/cmd/WatchYourLAN/ && CGO_ENABLED=0 go build -o /WatchYourLAN . FROM alpine @@ -12,7 +12,6 @@ WORKDIR /app RUN apk add --no-cache tzdata arp-scan \ && mkdir /data -COPY src/templates /app/templates -COPY --from=builder /src/watchyourlan /app/ +COPY --from=builder /WatchYourLAN /app/ -ENTRYPOINT ["./watchyourlan"] \ No newline at end of file +ENTRYPOINT ["./WatchYourLAN"] \ No newline at end of file diff --git a/internal/web/index.go b/internal/web/index.go index 2109fb1..d3a06f8 100644 --- a/internal/web/index.go +++ b/internal/web/index.go @@ -17,7 +17,8 @@ func indexHandler(w http.ResponseWriter, r *http.Request) { guiData.Hosts = AllHosts guiData.Icon = Icon - tmpl, _ := template.ParseFiles(TemplPath+"index.html", TemplPath+"header.html", TemplPath+"footer.html") + // tmpl, _ := template.ParseFiles(TemplPath+"index.html", TemplPath+"header.html", TemplPath+"footer.html") + tmpl, _ := template.ParseFS(TemplHTML, TemplPath+"index.html", TemplPath+"header.html", TemplPath+"footer.html") err := tmpl.ExecuteTemplate(w, "header", guiData) check.IfError(err) err = tmpl.ExecuteTemplate(w, "index", guiData) diff --git a/internal/web/on-off-line.go b/internal/web/on-off-line.go index f5147e2..d38af11 100644 --- a/internal/web/on-off-line.go +++ b/internal/web/on-off-line.go @@ -21,7 +21,8 @@ func offlineHandler(w http.ResponseWriter, r *http.Request) { } } - tmpl, _ := template.ParseFiles(TemplPath+"offline.html", TemplPath+"header.html", TemplPath+"footer.html") + // tmpl, _ := template.ParseFiles(TemplPath+"offline.html", TemplPath+"header.html", TemplPath+"footer.html") + tmpl, _ := template.ParseFS(TemplHTML, TemplPath+"offline.html", TemplPath+"header.html", TemplPath+"footer.html") err := tmpl.ExecuteTemplate(w, "header", guiData) check.IfError(err) err = tmpl.ExecuteTemplate(w, "offline", guiData) @@ -41,7 +42,8 @@ func onlineHandler(w http.ResponseWriter, r *http.Request) { } } - tmpl, _ := template.ParseFiles(TemplPath+"offline.html", TemplPath+"header.html", TemplPath+"footer.html") + // tmpl, _ := template.ParseFiles(TemplPath+"offline.html", TemplPath+"header.html", TemplPath+"footer.html") + tmpl, _ := template.ParseFS(TemplHTML, TemplPath+"offline.html", TemplPath+"header.html", TemplPath+"footer.html") err := tmpl.ExecuteTemplate(w, "header", guiData) check.IfError(err) err = tmpl.ExecuteTemplate(w, "offline", guiData) diff --git a/internal/web/webgui.go b/internal/web/webgui.go index 3c1fd29..7932ed0 100644 --- a/internal/web/webgui.go +++ b/internal/web/webgui.go @@ -1,7 +1,7 @@ package web import ( - // "embed" + "embed" "log" "net/http" @@ -19,11 +19,15 @@ var ( AllHosts []models.Host ) -////go:embed templates/* -// var TemplHTML embed.FS +// TemplHTML - embed templates +// +//go:embed templates/* +var TemplHTML embed.FS // TemplPath - path to html templates -const TemplPath = "../../internal/web/templates/" +const TemplPath = "templates/" + +// const TemplPath = "../../internal/web/templates/" // Gui - start web GUI func Gui(appConfig models.Conf) {