2

I am new to dockers and trying to make a docker container for a simple Go application. I am using Godep for dependency management.

Here is my Dockerfile:

FROM pottava/golang:1.5

RUN go get github.com/tools/godep \
      && rm -rf /go/pkg /go/src

ADD ./ /go

ENV GOPATH /go
RUN godep go build -v -o ./bin/main ./src/main.go

When I try to build the image, I get the following error:

...
 ---> 5cb6dd001eb3
Removing intermediate container 15eb0b298adb
Step 5 : ENV GOPATH /go
 ---> Running in 1c0043c3e963
 ---> 6cd0498af200
Removing intermediate container 1c0043c3e963
Step 6 : RUN godep go build -v -o ./bin/main ./src/main.go
 ---> Running in af2386d13c9a
godep: [WARNING]: godep should only be used inside a valid go package directory and
godep: [WARNING]: may not function correctly. You are probably outside of your $GOPATH.
godep: [WARNING]:   Current Directory: /go
godep: [WARNING]:   $GOPATH: /go
src/main.go:18:2: cannot find package "github.com/Sirupsen/logrus" in any of:
    /usr/local/go/src/github.com/Sirupsen/logrus (from $GOROOT)
    /go/Godeps/_workspace/src/github.com/Sirupsen/logrus (from $GOPATH)
    /go/src/github.com/Sirupsen/logrus
...
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
desi Joe
  • 363
  • 5
  • 18

1 Answers1

0

If you set GOPATH, that means you define a go workspace

Executing godep "in a valid package" means executing it in:

$GOPATH/src/a/package

Make sure to execute godep within a existing go project, cloned in GOPATH/src.

Simple test: try that same command on your computer (not in a docker image being built), and when it is working, reproduce the setup and commands in your Dockerfile.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250