From ead67c221fe384e0fead8f1ec99fca9b5251d33d Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Wed, 14 Oct 2020 23:41:45 -0700 Subject: [PATCH] updates dockerfile to work with latest golang, adds .dockerignore, fixes CI (#4) * adds support for https://github.com/golang/go/issues/32479 * updated dockerfile to work with latest golang, added .dockerignore --- .dockerignore | 1 + Dockerfile | 2 +- server.go | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9414382 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +Dockerfile diff --git a/Dockerfile b/Dockerfile index cfc9157..c56bf66 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,5 +15,5 @@ COPY . /go/src/pastebin RUN go get -v -d RUN go get github.com/GeertJohan/go.rice/rice -RUN rice embed-go +RUN GOROOT=/go rice embed-go RUN go install -v diff --git a/server.go b/server.go index 173ce27..3b3b1eb 100644 --- a/server.go +++ b/server.go @@ -8,6 +8,7 @@ import ( "log" "net/http" "net/url" + "strconv" "strings" "time" @@ -19,7 +20,7 @@ import ( "github.com/rcrowley/go-metrics/exp" "github.com/thoas/stats" - "github.com/GeertJohan/go.rice" + rice "github.com/GeertJohan/go.rice" "github.com/julienschmidt/httprouter" "github.com/patrickmn/go-cache" "github.com/renstrom/shortuuid" @@ -160,7 +161,7 @@ func (s *Server) DownloadHandler() httprouter.Handle { w.Header().Set("Content-Disposition", "attachment; filename="+uuid) w.Header().Set("Content-Type", "application/octet-stream") - w.Header().Set("Content-Length", string(content.Size())) + w.Header().Set("Content-Length", strconv.FormatInt(content.Size(), 10)) http.ServeContent(w, r, uuid, time.Now(), content) }