Docker-compose cannot find package (golang)
I am writing a simple application in GO and I have this folder structure
Docker-compose.yml file content:
version: '2'
services:
db:
image: rethinkdb:latest
ports:
- "38080:8080"
- "38015:28015"
- "39015:29015"
api:
image: golang:1.8-alpine
volumes:
- .:/go/src/test_server/
working_dir: /go/src/test_server
command: go run server.go
container_name: test_server
ports:
- "8085:8085"
links:
- db
tty: true
Every time I run docker build I get this error message:
test_server | controllers /users.go: 4: 3: Cannot find package "_ / go / src / test_server / vendor / github.com / gin-gonic / gin" in any of: test_server |
/usr/local/go/src/_/go/src/test_server/vendor/github.com/gin-gonic/gin (from $ GOROOT) test_server |
/go/src/_/go/src/test_server/vendor/github.com/gin-gonic/gin (from $ GOPATH)
This refers to the controller package. I am using github.com/kardianos/govendor for my package vendors. Do you know what's going on?
source to share
After a few hours, I was finally able to fix it. I ended up using a version of doker golang that didn't have git in it. I have to use golang: 1.8
I modified my Dockerfile like this and now it works like a charm
FROM golang:1.8
RUN go get github.com/gin-gonic/gin
WORKDIR /go/src/app
COPY . .
RUN go install -v
CMD ["app"]
source to share