Complete addition of GET option. Build container.

This commit is contained in:
Fred Boniface 2023-09-08 11:43:22 +01:00
parent 99a1a25254
commit 9007e7e916
4 changed files with 5 additions and 3 deletions

View File

@ -6,8 +6,10 @@ RUN go test ./...
RUN CGO_ENABLED=0 go build . RUN CGO_ENABLED=0 go build .
# Final stage # Final stage
#FROM gcr.io/distroless/static
FROM scratch FROM scratch
EXPOSE 8500 EXPOSE 8500
WORKDIR /bin
COPY --from=build /build/templates /bin/templates COPY --from=build /build/templates /bin/templates
COPY --from=build /build/static /bin/static COPY --from=build /build/static /bin/static
COPY --from=build /build/barcodes /bin/barcodes COPY --from=build /build/barcodes /bin/barcodes

View File

@ -7,6 +7,6 @@ import (
) )
func main() { func main() {
fmt.Println("Starting `barcodes` server") fmt.Println("Starting `barcodes` server (Version 0.0.1-alpha)")
web.StartServer() web.StartServer()
} }

View File

@ -23,7 +23,7 @@ func helpTemplate(w http.ResponseWriter, r *http.Request) {
BarcodeOptions: barcodeOptions, 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 { if err != nil {
fmt.Println("Error parsing templates: ", err) fmt.Println("Error parsing templates: ", err)
http.Error(w, "Unable to parse templates", 500) http.Error(w, "Unable to parse templates", 500)

View File

@ -15,7 +15,7 @@ func rootHandler(w http.ResponseWriter, r *http.Request) {
templatePath := "templates" + path + ".html" templatePath := "templates" + path + ".html"
if _, err := os.Stat(templatePath); err == nil { 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 { if err != nil {
fmt.Println("Error parsing template: ", err) fmt.Println("Error parsing template: ", err)
http.Error(w, "Error parsing template", http.StatusInternalServerError) http.Error(w, "Error parsing template", http.StatusInternalServerError)