diff --git a/Dockerfile b/Dockerfile index 8be64cc..8df03b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,8 +6,10 @@ RUN go test ./... RUN CGO_ENABLED=0 go build . # Final stage +#FROM gcr.io/distroless/static FROM scratch EXPOSE 8500 +WORKDIR /bin COPY --from=build /build/templates /bin/templates COPY --from=build /build/static /bin/static COPY --from=build /build/barcodes /bin/barcodes diff --git a/main.go b/main.go index 2b98ec8..192684c 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,6 @@ import ( ) func main() { - fmt.Println("Starting `barcodes` server") + fmt.Println("Starting `barcodes` server (Version 0.0.1-alpha)") web.StartServer() } diff --git a/web/help.route.go b/web/help.route.go index 4fd14aa..e7007ef 100644 --- a/web/help.route.go +++ b/web/help.route.go @@ -23,7 +23,7 @@ func helpTemplate(w http.ResponseWriter, r *http.Request) { BarcodeOptions: barcodeOptions, } - tmpl, err := template.ParseFiles("templates/base.html", "templates/help.html") + tmpl, err := template.ParseFiles("./templates/base.html", "./templates/help.html") if err != nil { fmt.Println("Error parsing templates: ", err) http.Error(w, "Unable to parse templates", 500) diff --git a/web/root.route.go b/web/root.route.go index dedf8b5..8bf2c1d 100644 --- a/web/root.route.go +++ b/web/root.route.go @@ -15,7 +15,7 @@ func rootHandler(w http.ResponseWriter, r *http.Request) { templatePath := "templates" + path + ".html" if _, err := os.Stat(templatePath); err == nil { - tmpl, err := template.ParseFiles("templates/base.html", templatePath) + tmpl, err := template.ParseFiles("./templates/base.html", "./"+templatePath) if err != nil { fmt.Println("Error parsing template: ", err) http.Error(w, "Error parsing template", http.StatusInternalServerError)