From 0410e9999133b56c77fddbfffbf0125e4d024c26 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Mon, 25 Nov 2019 16:19:14 +0100 Subject: [PATCH] chore: embed static content in docker --- .gitignore | 2 ++ Dockerfile | 2 ++ internal/dvserver/server.go | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 6c7a999f2..bf820a036 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ coverage.txt .#* depviz.db /vendor/ +packrd/ +*-packr.go diff --git a/Dockerfile b/Dockerfile index 08c12a584..73076b4eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,11 +6,13 @@ ARG VERSION # build FROM golang:1.13-alpine as build RUN apk add --update --no-cache git gcc musl-dev make +RUN GO111MODULE=off go get github.com/gobuffalo/packr/v2/packr2 WORKDIR /go/src/moul.io/depviz ENV GO111MODULE=on COPY go.* ./ RUN go mod download COPY . ./ +RUN cd ./internal/dvserver && packr2 RUN make install # minimalist runtime diff --git a/internal/dvserver/server.go b/internal/dvserver/server.go index ce7c8f8c4..e7e837b60 100644 --- a/internal/dvserver/server.go +++ b/internal/dvserver/server.go @@ -13,7 +13,7 @@ import ( "github.com/cayleygraph/cayley/schema" "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" - "github.com/gobuffalo/packr/v2" + packr "github.com/gobuffalo/packr/v2" "github.com/gogo/gateway" grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" grpc_zap "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap" @@ -196,7 +196,7 @@ func New(ctx context.Context, h *cayley.Handle, schema *schema.Config, opts Opts } // static content - box := packr.New("web", "./web") + box := packr.New("web", "../../web") chiutil.FileServer(r, "/", box) http.DefaultServeMux = http.NewServeMux() // disables default handlers registere by importing net/http/pprof for security reasons