Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose cannot find package

I'm writing a simple app in GO and I have this folder structure

enter image description here

The docker-compose.yml file content is:

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

Everytime I run docker-compose up I receive 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)

It's referring to the controllers package. I'm using github.com/kardianos/govendor to vendor my packages. Do you know what's going on?

like image 557
utiq Avatar asked Jul 15 '26 23:07

utiq


1 Answers

After many hours I finally could fix it. Resulted that I was using a docker golang version that it doesn't have git included. I should 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"]
like image 180
utiq Avatar answered Jul 17 '26 15:07

utiq



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!