Skip to content

Commit

Permalink
Fix build and use packerv2
Browse files Browse the repository at this point in the history
  • Loading branch information
LKaemmerling committed Nov 26, 2022
1 parent 99f4c3a commit 854fd02
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 55 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ fathom

assets/build
assets/dist
bin/
4 changes: 2 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ builds:
ldflags:
- -extldflags "-static" -s -w -X "main.version={{.Version}}" -X "main.commit={{.Commit}}" -X "main.date={{.Date}}"
hooks:
pre: $GOBIN/packr
post: $GOBIN/packr clean
pre: packr2
post: packr2 clean
checksum:
name_template: 'checksums.txt'
snapshot:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ COPY assets/ ./assets/
RUN npm install && NODE_ENV=production ./node_modules/gulp/bin/gulp.js

FROM golang:latest AS binarybuilder
RUN go install github.com/gobuffalo/packr/packr@latest
RUN go install github.com/gobuffalo/packr/v2/packr2@latest
WORKDIR /go/src/github.com/usefathom/fathom
COPY . /go/src/github.com/usefathom/fathom
COPY --from=assetbuilder /app/assets/build ./assets/build
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ $(EXECUTABLE): $(GO_SOURCES) assets/build
go build -o $@ $(MAIN_PKG)

.PHONY: docker
docker: $(GO_SOURCES) $(GOPATH)/bin/packr
GOOS=$(OS) GOARCH=$(ARCH) $(GOPATH)/bin/packr build -v -ldflags '-w $(LDFLAGS)' -o $(EXECUTABLE) $(MAIN_PKG)
docker: $(GO_SOURCES) $(GOPATH)/bin/packr2
GOOS=$(OS) GOARCH=$(ARCH) $(GOPATH)/bin/packr2 build -v -ldflags '-w $(LDFLAGS)' -o $(EXECUTABLE) $(MAIN_PKG)

$(GOPATH)/bin/packr:
GOBIN=$(GOPATH)/bin go install github.com/gobuffalo/packr/packr@latest
$(GOPATH)/bin/packr2:
GOBIN=$(GOPATH)/bin go install github.com/gobuffalo/packr/v2/packr2@latest

.PHONY: npm
npm:
Expand Down
10 changes: 7 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.19

require (
github.com/go-sql-driver/mysql v1.6.0
github.com/gobuffalo/packr v1.30.1
github.com/gobuffalo/packr/v2 v2.8.3
github.com/google/uuid v1.3.0
github.com/gorilla/context v1.1.1
github.com/gorilla/handlers v1.5.1
Expand All @@ -26,14 +26,18 @@ require (
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/go-gorp/gorp/v3 v3.0.2 // indirect
github.com/gobuffalo/envy v1.7.0 // indirect
github.com/gobuffalo/logger v1.0.6 // indirect
github.com/gobuffalo/packd v1.0.1 // indirect
github.com/gorilla/securecookie v1.1.2-0.20180608144417-78f3d318a8bf // indirect
github.com/rogpeppe/go-internal v1.8.0 // indirect
github.com/karrick/godirwalk v1.16.1 // indirect
github.com/markbates/errx v1.1.0 // indirect
github.com/markbates/oncer v1.0.0 // indirect
github.com/markbates/safe v1.0.1 // indirect
github.com/russross/blackfriday/v2 v2.0.1 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/ziutek/mymysql v1.5.5-0.20171217234033-ff6cc86d3d93 // indirect
golang.org/x/net v0.2.0 // indirect
golang.org/x/sys v0.2.0 // indirect
golang.org/x/term v0.2.0 // indirect
golang.org/x/text v0.4.0 // indirect
)
40 changes: 2 additions & 38 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/api/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"net/http"

"github.com/gobuffalo/packr"
"github.com/gobuffalo/packr/v2"
log "github.com/sirupsen/logrus"
)

Expand Down
10 changes: 5 additions & 5 deletions pkg/api/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package api
import (
"net/http"

"github.com/gobuffalo/packr"
"github.com/gobuffalo/packr/v2"
"github.com/gorilla/mux"
)

Expand Down Expand Up @@ -35,11 +35,11 @@ func (api *API) Routes() *mux.Router {

// static assets & 404 handler
box := packr.NewBox("./../../assets/build")
r.Path("/tracker.js").Handler(serveTrackerFile(&box))
r.Path("/").Handler(serveFileHandler(&box, "index.html"))
r.Path("/index.html").Handler(serveFileHandler(&box, "index.html"))
r.Path("/tracker.js").Handler(serveTrackerFile(box))
r.Path("/").Handler(serveFileHandler(box, "index.html"))
r.Path("/index.html").Handler(serveFileHandler(box, "index.html"))
r.PathPrefix("/assets").Handler(http.StripPrefix("/assets", http.FileServer(box)))
r.NotFoundHandler = NotFoundHandler(&box)
r.NotFoundHandler = NotFoundHandler(box)

return r
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/datastore/sqlstore/sqlstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"

_ "github.com/go-sql-driver/mysql" // mysql driver
"github.com/gobuffalo/packr"
"github.com/gobuffalo/packr/v2"
"github.com/jmoiron/sqlx"
_ "github.com/lib/pq" // postgresql driver
_ "github.com/mattn/go-sqlite3" //sqlite3 driver
Expand Down

0 comments on commit 854fd02

Please sign in to comment.