I have a simple Dockerfile that I am trying to build and run my Go REST API server.
My Dockerfile so far is:
FROM golang:latest
RUN mkdir /app
ADD . /app/
WORKDIR /app
RUN go build -o main .
CMD ["/app/main"]
When I run docker-compose up I get this error:
main.go:12:2: cannot find package "github.com/bradfitz/gomemcache/memcache" in any of:
I am using godeps and my vendor folder has all the libraries vendored, why isn't the build working in this case?
Do I have to tell it to look in the vendor folder?
The
vendordirectory does not function as expected if your source code lies outside ofGOPATH(see https://github.com/golang/go/issues/14566). In the currentgolang:latestDocker image,GOPATHis set to/goso the simplest solution would be to copy your code into a subdirectory of/go/srcand build from there.