dnephin / dobi

A build automation tool for Docker applications
https://dnephin.github.io/dobi/
Apache License 2.0
309 stars 36 forks source link

config variables not expanded in cache-from #163

Closed Fuco1 closed 4 years ago

Fuco1 commented 5 years ago

It seems like the config variables are not expanded in cache-from

meta:
  project: project

image=server:
  image: {project}
  pull-base-image-on-build: false
  target: server
  cache-from:
    - {project}:latest   ##### <==== seems to have no effect, cache is never used.
  context: .
  tags:
    - latest

When I replace {project} with project (the expansion) manually dobi uses cache for build.

dnephin commented 5 years ago

That's correct, only some fields support variable expansion: http://dnephin.github.io/dobi/variables.html#config-fields

It should be easy to add here https://github.com/dnephin/dobi/blob/master/config/image.go#L144-L170, using resolver.ResolveSlice

Fuco1 commented 5 years ago

okay, I know nothing about go development but followed some guide, ended up with cloning the project into github.com/dnephin/dobi inside my $GOPATH and then I run go get, it downloaded a bunch of stuff and then failed at

~/dev/go/src/github.com/dnephin/dobi$ go get -v
# github.com/dnephin/dobi
/usr/lib/go-1.10/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/tmp/go-link-414185749/000024.o: In function `_cgo_f404b13b0081_Cfunc_sysconf':
/tmp/go-build/cgo-gcc-prolog:32: multiple definition of `_cgo_f404b13b0081_Cfunc_sysconf'
/tmp/go-link-414185749/000018.o:/tmp/go-build/cgo-gcc-prolog:32: first defined here
collect2: error: ld returned 1 exit status
$ go version
go version go1.10.4 linux/amd64

any pointers? I'd like to take a stab at this. I like the project and there are still some things I'd like to add, so why not I guess :D

dnephin commented 5 years ago

Oh wow, that's a strange error. I would try export CGO_ENABLED=0 to turn off CGO (https://golang.org/cmd/cgo/).

Thanks for working on this!

Fuco1 commented 5 years ago

Thanks, that helped, I can now compile the project and get a binary.

Now I'm trying to run the tests. When I did just go test I get

> go test
?       github.com/dnephin/dobi [no test files]

I've installed go get gotest.tools/assert since it was complaining the library was missing.

dnephin commented 5 years ago

In Go the default is to only run tests in the current directory, you can run go test ./... to run them all