From 49b20743412760d046ef80f336bb51f62c031f0f Mon Sep 17 00:00:00 2001 From: sneak Date: Wed, 30 Sep 2020 22:12:41 -0700 Subject: [PATCH 1/4] try same OS for build/run images, per feedback https://lobste.rs/s/dzaeid/go_http_server_project_template#c_vs0btd --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 25ffc94..705d287 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN golangci-lint run ## build image: #ARG GO_VERSION=1.15 -FROM golang:1.15-alpine AS builder +FROM golang:1.15-buster AS builder RUN mkdir /user && \ echo 'nobody:x:65534:65534:nobody:/:' > /user/passwd && \ @@ -32,7 +32,7 @@ RUN go mod vendor RUN tar -c . | bzip2 > /src.tbz2 ## output image: -FROM ubuntu:focal AS final +FROM debian:buster-slim AS final COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=builder /build/httpd /app/httpd COPY --from=builder /src.tbz2 /usr/local/src/src.tbz2 From db049e3b672f33645eefe733939339a3460a3e93 Mon Sep 17 00:00:00 2001 From: sneak Date: Wed, 30 Sep 2020 22:24:52 -0700 Subject: [PATCH 2/4] fixes --- httpserver/handlepanic.go | 2 -- httpserver/routes.go | 12 ++++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/httpserver/handlepanic.go b/httpserver/handlepanic.go index 19c5975..ddbe0bc 100644 --- a/httpserver/handlepanic.go +++ b/httpserver/handlepanic.go @@ -1,7 +1,6 @@ package httpserver import ( - "fmt" "net/http" ) @@ -11,6 +10,5 @@ import ( func (s *server) handlePanic() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { panic("y tho") - fmt.Fprintf(w, "hello world") } } diff --git a/httpserver/routes.go b/httpserver/routes.go index 395e7d9..26fa9d0 100644 --- a/httpserver/routes.go +++ b/httpserver/routes.go @@ -16,20 +16,20 @@ func (s *server) routes() { // wrapper) on a specific HandleFunc route, you need to take the // .ServeHTTP of the http.Handler to get its HandleFunc, viz: s.router.HandleFunc( - "/login", - authMiddleware(s.handleLogin()).ServeHTTP + "/login", + authMiddleware(s.handleLogin()).ServeHTTP, ).Methods("GET") s.router.HandleFunc( - "/.well-known/healthcheck.json", - s.handleHealthCheck(), + "/.well-known/healthcheck.json", + s.handleHealthCheck(), ).Methods("GET") // route that panics for testing // CHANGEME remove this s.router.HandleFunc( - "/panic", - s.handlePanic() + "/panic", + s.handlePanic(), ).Methods("GET") // the Gorilla mux .Use() takes a http.Handler wrapper func, like From 93f2bfef4d6d11d91d2be6cc35bb32f5cc9227c8 Mon Sep 17 00:00:00 2001 From: sneak Date: Wed, 30 Sep 2020 23:04:47 -0700 Subject: [PATCH 3/4] should work now --- Dockerfile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 705d287..27fe03c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,15 +7,9 @@ COPY ./ ./ RUN golangci-lint run ## build image: -#ARG GO_VERSION=1.15 FROM golang:1.15-buster AS builder -RUN mkdir /user && \ - echo 'nobody:x:65534:65534:nobody:/:' > /user/passwd && \ - echo 'nobody:x:65534:' > /user/group -RUN apk add --no-cache ca-certificates git bzip2 make gcc libc-dev - -#RUN GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.31.0 +RUN apt update && apt install -y make bzip2 RUN mkdir -p /build WORKDIR /build From 6d9095b12d13d842b55016f8f2186f7bf9945bc0 Mon Sep 17 00:00:00 2001 From: sneak Date: Thu, 1 Oct 2020 00:48:30 -0700 Subject: [PATCH 4/4] don't try to tag the image, just build it --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index c9efb44..dc193bc 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,6 +7,7 @@ steps: settings: repo: foo/bar dry_run: true + target: final tags: - ${DRONE_COMMIT_SHA} - ${DRONE_BRANCH}