fragmenta / fragmenta-cms

A user-friendly CMS written in Go (golang)
http://fragmenta.eu
MIT License
586 stars 70 forks source link

restructure project to use `gb` for reproducible builds #12

Closed cmosetick closed 8 years ago

cmosetick commented 8 years ago

gb is the preferred tool now for building and managing go projects, because gb can guarantee reproducible builds. This means that everything is self contained in the "project dir" and simplifies the differences between development and production environments. http://getgb.io/docs/usage/ video intro to gb

Also, review the vendor plugin: https://godoc.org/github.com/constabulary/gb/cmd/gb-vendor

I'm having issues with fragmenta no matter where my project is located on my local system.

I'm having issues with absolute paths. Here, I placed my fragmenta "site" in my "gocode dir", which is in my path, but even in another location, I'm having trouble.

fragmenta
12:23:24
------
Fragmenta version: 1.3.1
------
12:23:24 Building server...
12:23:24 Running goimports at ./
12:23:24 Building server at /Users/chris/src/gocode/fragmenta/bin/fragmenta-server-local
12:23:24 CMD go build -o /Users/chris/src/gocode/fragmenta/bin/fragmenta-server-local server.go
server.go:8:2: import "/Users/chris/src/gocode/fragmenta/src/app": cannot import absolute path
12:23:24 Error running build exit status 1
12:23:24 Error building server: exit status 1
cmosetick commented 8 years ago

Created a PR to get this started: https://github.com/fragmenta/fragmenta-cms/pull/13

kennygrant commented 8 years ago

I'm not sure about switching to the gb layout, I'll look into it at some point but there are very few external dependencies, so gb is not required and not a priority for me right now. I do want to keep the project go gettable (which is why the server.go file is in the main directory), and I think using gb precludes that and forces you to use the gb tool.

Re your problem above, I suspect your GOPATH is in fact /Users/chris, since you have a src dir under there. Fragmenta should probably refuse to generate and give you an error rather than generating with absolute paths though.

kennygrant commented 8 years ago

I've had a think about this and would prefer to keep the project go gettable I'm afraid (which is mostly why server.go is in the root folder).

I'm leaving this issue open for discussion of gb or future vendoring solutions.

kennygrant commented 8 years ago

Would it be acceptable to recognise an app which had server.go inside the src dir as a valid app as well? If so I'd be open to doing that, keeping the default go-gettable but allowing use of gb if people want to use it.

As the blessed approach to vendoring uses go get and a /vendor dir, I think I will be using that approach in my own projects using something like govend or godep.